feat: add organization policy enforcement - #135
Open
kishore7snehil wants to merge 4 commits into
Open
kishore7snehil wants to merge 4 commits into
kishore7snehil wants to merge 4 commits into
Conversation
Adds organization_policy ("allow"/"required") and organization_id
allowlist options. When required, verify_access_token now rejects
tokens missing org_id or carrying an org_id outside the allowlist.
Passing organization_id with policy "allow" raises ConfigurationError
at construction time.
Adds coverage for missing org_id under "required" policy, org_id outside the allowlist, an allowed org_id succeeding, default "allow" policy not requiring org_id, and the construction-time ConfigurationError when organization_id is set without policy "required". Each test is co-located with the existing tests for the surface it exercises.
Top-level select/ignore/per-file-ignores are deprecated in current ruff versions; rule sets are unchanged.
kishore7snehil
force-pushed
the
feat/org-policy-enforcement
branch
from
October 5, 2026 16:32
19320d8 to
8f87351
Compare
kishore7snehil
marked this pull request as ready for review
October 6, 2026 06:41
This branch has not been deployed
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.
📋 Changes
This PR adds organization policy enforcement to auth0-api-python, letting an API require that incoming access tokens carry an
org_idclaim and optionally pin accepted tokens to a specific organization or allowlist.✨ Features
organization_policyoption onApiClientOptions. "allow" accepts tokens with or withoutorg_idand matches existing behavior. "required" rejects tokens withoutorg_id.organization_idoption that pins accepted tokens to a single organization or an allowlist. Valid only when the policy is "required".verify_access_token()now enforces the configured organization policy during verification.MissingOrganizationError(subclassesVerifyAccessTokenError), raised when a token has noorg_idand the policy is "required".OrganizationNotAllowedError(subclassesVerifyAccessTokenError), raised when a token'sorg_idis not in theorganization_idallowlist.🔧 API Changes
organization_policy(str, default"allow") toApiClientOptionsorganization_id(str or list of str, defaultNone) toApiClientOptions, valid only with the "required" policyMissingOrganizationError,OrganizationNotAllowedError(both subclassVerifyAccessTokenError)verify_access_token()now enforces the organization policy📖 Documentation
docs/OrganizationPolicy.mddescribing the policy modes and the organization allowlistREADME.mdwith an organization policy section🧪 Testing
Contributor Checklist