Add OAuth 2.0 / JWT Bearer token authentication - #664
Draft
jakeichikawasalesforce wants to merge 8 commits into
Draft
Add OAuth 2.0 / JWT Bearer token authentication#664jakeichikawasalesforce wants to merge 8 commits into
jakeichikawasalesforce wants to merge 8 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds OAuth 2.0 / JWT Bearer token authentication as an alternative (or
complement) to TabPy's existing password-file basic auth. This lets
per-user credentials issued by an external identity provider (IdP) be
used instead of, or alongside, a single shared password-file credential.
issuer, audience, expiry/nbf, and optionally required scopes.
TABPY_OAUTH_ENABLED,TABPY_OAUTH_ISSUER,TABPY_OAUTH_JWKS_URI,TABPY_OAUTH_AUDIENCE,TABPY_OAUTH_REQUIRED_SCOPES(optional),TABPY_OAUTH_LOG_USER(optional, default
true).is selected per-request based on the
Authorizationheader scheme(
BasicvsBearer), so both can coexist on the same server.TABPY_OAUTH_ISSUERandTABPY_OAUTH_JWKS_URIare required to usehttps://— the JWKS response is the trust anchor for verifying JWTsignatures, so fetching it over plain HTTP would let an on-path
attacker substitute their own keys.
algorithm, never trusted from the token header, to prevent
algorithm-confusion attacks (e.g. RS256→HS256 substitution,
alg=none).by an unrecognized
kid) is rate-limited so repeated boguskids froman unauthenticated caller can't force unbounded blocking network fetches
on TabPy's single IO-loop thread.
docs/server-config.md.Testing
test_jwt_auth.py), OAuthrequest handling end-to-end (
test_oauth_handler.py), and OAuth configvalidation (
test_config.py).valid token accepted, expired/wrong-issuer/wrong-audience tokens
rejected with 401, and the request-context log line correctly includes
the authenticated
TabPy userwhenTABPY_LOG_DETAILSandTABPY_OAUTH_LOG_USERare enabled.