Replies: 2 comments
-
LGTM in general. Would you mind opening an issue in github.com/EngFlow/credential-helper-spec for the new fields though please so we can standardize them? I‘d like to avoid having slightly different flavours of the protocol 😅 |
Beta Was this translation helpful? Give feedback.
0 replies
-
We've recently standardized expiration of credentials in EngFlow/credential-helper-spec#2 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Background
Reclient has the following authentication mechanisms to talk to a corresponding RBE server:
Methods (1) and (2) provide support for authenticating with an RBE server implementation running on GCP and method (3) is sufficient to authenticate with RBE servers that expect an “Authorization: Bearer <token>” token. While in method (3) the user can specify that they want to provide a custom token, there is no clear option in reclient for them to actually specify a token (creds_file can be used to specify the token, but its not clear how reproxy can refresh the credentials in this file).
In addition, there have been use cases where users want to provide custom HTTP headers for auth. Given this, the proposal in this doc is to implement support for a credentials helper interface in reclient.
Credentials Helper
A credentials helper would be a binary that can be provided to reclient. Reclient would call the binary to receive a set of headers to append to RBE RPCs along with information about when those headers expire.
Interface
Two new flags will be introduced:
Invoking the credentials helper
Return value of credentials helper
The credentials helper binary will be expected to return the following response.
Note that this is very similar to the interface of the Bazel credentials helper with two optional return options:
This is useful in cases where the credentials helper relies on an authentication mechanism that requires the user to periodically reauthenticate themselves. If no refreshExpiry is specified, it is assumed to be infinite.
This field is intended to only be used by the bootstrap binary. When bootstrap sees refresh_expiry to be valid, it would assume that reproxy would be able to obtain valid authorization headers from the credentials helper and continue with reproxy startup. Otherwise, bootstrap would fail the reproxy startup process and indicate to the user that they will need to reauthenticate.
For both expiry and refreshExpiry, “YYYY-MM-DD HH:MM:SS.000 <TIMEZONE>” format will be used.
Implementation
Header Injection
RBE RPCs
Once the right authorization headers are returned from reclient, there needs to be a way to insert these headers into the RPCs being sent to RBE. With gRPC, a custom TokenSource can be created to insert custom headers per RPC request. Here’s a short example:
Credentials Helper Flag Location
There are two places where the creds helper flags can be defined:
Option (1) - In reclient (i.e., in bootstrap and reproxy binaries)
In this option, both bootstrap and reproxy binaries (and any other binary that relies on the credentials helper like remotetool) will define this flag. When it is set, bootstrap / reproxy would call the credentials helper to get the headers, then inject them into RBE RPCs using the mechanism described in this section.
Cons
Option (2) - In remote-apis-sdks repository
In this option, the flags will be defined in the remote-apis-sdks repository alongside the other authorization flags. When the creds helper flag is specified, the SDK will do the following:
Even with this approach, bootstrap binary in reclient would still need to define the credentials helper flags since it doesn’t initialize the SDK and will need to be able to say if the specified credentials helper can be used to obtain valid credentials or not to fail the build early.
Proposed solution: Pick Option (2) but move the auth related flags to a separate auth package within the remote-apis-sdks. This auth package can then be imported by the SDK and other clients binaries like bootstrap that don’t necessarily initialize the RBE client in remote-apis-sdks.
Beta Was this translation helpful? Give feedback.
All reactions