Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Resolve service endpoint from a URI environment variable #37

Closed
paulhowardarm opened this issue Jul 9, 2020 · 3 comments · Fixed by #73
Closed

Resolve service endpoint from a URI environment variable #37

paulhowardarm opened this issue Jul 9, 2020 · 3 comments · Fixed by #73
Assignees
Labels
enhancement New feature or request medium Effort label

Comments

@paulhowardarm
Copy link
Contributor

Summary

Introduce a mechanism in the Rust client (which would also apply uniformly to all clients) whereby a well-known and documented environment variable can be used for discovery of the correct Parsec service endpoint.

Rationale

Currently, the rust client is defaulting two things in the code:

  • The nature of the IPC handler (currently defaulting to Unix socket, chiefly because that's the only form of IPC that Parsec supports today).
  • The address of the endpoint (namely the socket path for Unix socket).

These things can be overridden if the caller passes in alternatives. However:

  • If the caller is the SE driver (C client), then there is no means of passing through this information. This means the C client would break if the socket endpoint were configured to be anything other than the hard-coded default.
  • Even when the caller has the ability to pass in the information, where should they get it from? Who has enough intelligence about the overall deployment to know what the service endpoint should be? Application developers won't typically have this intelligence - they will simply want to "use Parsec".

An environment variable would be an idiomatic way to allow configuration to be decided in the external environment, rather than in the client code. It would also allow different client processes to be directed at different service endpoints if Parsec evolves to support multiple endpoints, which it may do. This could be done with identical code on the client side.

Requirements

  • Define and document an environment variable such as PARSEC_SERVICE_ENDPOINT.
  • The variable should be defined as a URI (RFC 3986) so that it can specify a scheme as well as an endpoint address, such as unix:///tmp/parsec/parsec.sock.
  • The rust client should obtain the value of this environment variable, but fall back on unix:///tmp/parsec/parsec.sock where it is undefined.
  • The rust client should use both the scheme and the address segments of the URI to create a correct IPC handler pointed at the correct service endpoint. It remains the case that unix: would be the only supported scheme initially.
  • Use of the environment variable should be default behaviour, although it should still be possible for callers to pass in explicit values to override this.
  • Update the Parsec book to describe this behaviour of clients. It will need to become a general rule for client library development, since the same discovery logic will need to be replicated in the Go client and all other clients.

Discussion

In addition to endpoint discovery, it might also make sense for the authentication scheme to be set by an environment variable as well. But if we want to do that, then that's probably a separate request.

We'd need to think about how this impacts the threat model and its mitigations within the code, such as the permission check on the socket path. Presumably this permission check could still occur, because the check is performed on whatever socket path is configured. It's only the preferred source of the data that is changing.

@hug-dev
Copy link
Member

hug-dev commented Feb 9, 2021

Putting here as a reference that this can also be done in the parsec-tool less controversially

@ionut-arm
Copy link
Member

Work for the initial design proposal has been done in #73, with one change: the unix scheme does not support an authority value and thus the correct value for encoding an address is unix:/path/to/socket

@hug-dev
Copy link
Member

hug-dev commented Feb 16, 2021

I think this was inspired from SPIFFE, so I raised this related issue.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request medium Effort label
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants