Bearer token support in ForwardAuth + OAuth2 client_credentials grant #10
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Enable server-to-server access to ForwardAuth-protected services (e.g., WebDAV) by:
/api/verifyto acceptAuthorization: Bearertokens (not just session cookies)client_credentialsgrant type so services can obtain tokens without a browserUse Case
Canister (media organizer) needs to access a WebDAV server that sits behind Clinch's ForwardAuth. There's no browser involved — it's pure server-to-server.
Part 1: Bearer token validation in
/api/verifyCurrently
/api/verifyonly checks session cookies. Add support forAuthorization: Bearer <token>header:Authorization: Bearerheader first, fall back to session cookieoidc_access_tokens(same tokens issued by the token endpoint)Remote-User,Remote-Email,Remote-Groups, etc.)This is the core feature — both API keys and client_credentials tokens are validated the same way.
Part 2:
client_credentialsgrant on/oauth/tokenAdd
client_credentialsas a supported grant type:Returns an access token directly. No browser, no redirects, no human. The application authenticates with its client_secret and gets a short-lived bearer token.
grant_types_supportedin discovery endpointPart 3 (optional): API Keys as an alternative
For simpler setups, allow admins to create long-lived API keys per application via the UI. Same validation path in
/api/verify, just a different way to create the token.How the pieces fit together
Implementation order
/api/verify(unblocks everything)client_credentialsgrant (proper token issuance)Add OAuth2 client_credentials grant for server-to-server authenticationto Bearer token support in ForwardAuth + OAuth2 client_credentials grant