Repository navigation
Description
Problem
FOCA's typed backend lists name the credentials of each backend (ServiceEntry.auth: client_credentials, basic or none; RegistryEntry.auth; Backend.auth; OutboundRequest.auth), but FOCA doesn't resolve them. Every gateway implements this itself: proTES has an OAuth 2.0 client credentials client with a thread-safe token cache, per-backend audiences, OIDC discovery of the token endpoint, environment variables for the client ID and secret and for Basic credentials, and startup checks (pro_tes/ga4gh/tes/backends.py: TokenProvider, TokenKey, get_env; pro_tes/security.py: check_backends). proWES needs the same (elixir-cloud-aai/prowes#120), and a second copy of a security-sensitive token client would have to be kept in sync by hand.
What to do
Move proTES's implementation into FOCA, generic over the API of the gateway:
- A config model for the gateway's own client (as proTES's
ClientCredentials:issuerortoken_endpoint,scope,audience_parameter,auth_method,refresh_before,timeout, allowed URL schemes), placed next to the backend list config so gateways embed it under their key (e.g.,custom.tes,custom.wes). - A token provider (client credentials grant, RFC 6749 section 4.4; cached per process and key, refreshed before expiry, one fetch per key at a time, cached token used while a refresh fails) whose client ID and secret come from environment variables the gateway names (e.g.,
PROTES_CLIENT_ID,PROWES_CLIENT_ID). - A resolver from a backend's
authto request credentials (Authorizationheader or arequestsauth object): token (for the backend's audience, if configured), Basic from the named environment variables, or none; never.netrc, never the caller's headers. - Startup checks as in
pro_tes/security.py(missing environment variables,httpwarnings, logging which backends get tokens), callable by any gateway. - proTES switches to it in a follow-up (issue in proTES after the FOCA release).
Done when
- Unit tests of the provider (cache, refresh, concurrency, discovery, errors without secrets in messages) and of each credential mode, at 100% coverage.
- Docs ("Backend lists" / plugins docs: credentials of backends), changelog.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity