Repository navigation
Description
Summary
The go-processor (AuthProxy ext_proc) currently uses a static TARGET_SCOPES environment variable for all outbound token exchanges. This means every exchanged token gets the same set of scopes regardless of what scopes the original user token contained.
For scope-based access control to work (e.g., Alice with public access vs Bob with privileged access), the go-processor must forward the original token's scopes through the token exchange, not use a fixed set.
Current Behavior
TARGET_SCOPESis set in theauthbridge-configConfigMap (e.g.,"openid github-tool-aud github-full-access")- When any user's request reaches the agent, AuthBridge exchanges the token using the static
TARGET_SCOPES - The exchanged token always contains
github-full-access, even if the original user (e.g., Alice) did not have that scope - The downstream tool always sees
github-full-accessand uses the privileged PAT for all users
Expected Behavior
The go-processor should extract the scope claim from the incoming JWT (subject token) and intersect it with TARGET_SCOPES before making the token exchange request:
- If the incoming token has
scope: "openid email profile"andTARGET_SCOPESis"openid github-tool-aud github-full-access", the exchange should requestscope=openid github-tool-aud(intersection, plus required scopes likegithub-tool-aud) - If the incoming token has
scope: "openid email profile github-full-access", the exchange should requestscope=openid github-tool-aud github-full-access
This preserves per-user scope differentiation through the exchange.
Proposed Implementation
Add a new configuration option to go-processor:
SCOPE_FORWARDING(env var, default:"disabled")"disabled"— current behavior: use staticTARGET_SCOPESfor all exchanges"intersect"— extract scopes from subject token, intersect withTARGET_SCOPES"forward"— extract scopes from subject token, merge withTARGET_SCOPES
Implementation in handleOutbound():
- Parse the incoming JWT's
scopeclaim (decode without full validation — the token was already validated inbound) - Split into a set of scopes
- Apply the selected strategy (
intersectorforward) withTARGET_SCOPES - Pass the resulting scope set to
exchangeToken()
Use Case
The GitHub Issue Agent demo Step 10 shows two users:
- Alice gets a token without
github-full-access— should result inPUBLIC_ACCESS_PATat the tool - Bob gets a token with
github-full-access— should result inPRIVILEGED_ACCESS_PATat the tool
Without scope forwarding, both users get github-full-access in the exchanged token because TARGET_SCOPES is static.
Affected Files
AuthBridge/AuthProxy/go-processor/main.go—handleOutbound()andloadConfig()AuthBridge/demos/github-issue/k8s/configmaps.yaml— addSCOPE_FORWARDING: "intersect"toauthbridge-config
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
huang195 commentedon Feb 24, 2026
Alternative Approach: Keycloak Role-Based Scope Gating
Thanks for the detailed write-up — the problem statement is spot-on. Static
TARGET_SCOPESbreaks per-user access control through token exchange.I wanted to suggest an alternative approach that avoids adding scope-parsing logic to the go-processor entirely, by leveraging Keycloak's native role-based access control instead.
Core Idea
Rather than having the go-processor inspect the subject token's scopes and decide what to request, let Keycloak make that decision. Keycloak already knows the user identity during token exchange (it's in the
subject_token) — it just needs to be told which users are entitled to which scopes.How It Works
github-privilegedrealm role in Keycloakgithub-full-accessfromTARGET_SCOPES— set it to just"openid github-tool-aud"(the infrastructure scopes needed for the exchange mechanism itself)github-toolclient that exposes the user's roles (e.g., viarealm_access.rolesor a custom claim)The go-processor continues to request the same static scopes for every exchange — but the exchanged token now carries per-user role information that the downstream tool can use for authorization.
scope=openid github-tool-audgithub-privileged)scope=openid github-tool-audgithub-privileged)Changes Required
setup_keycloak.pygithub-privilegedrealm role, assign to Bob, ensure role mapper ongithub-toolclientconfigmaps.yamlTARGET_SCOPES: "openid github-tool-aud"github-tooldeploymentrealm_access.rolesforgithub-privileged(instead ofscopeclaim)The
setup_keycloak.pyadditions would be roughly:Trade-offs
Advantages:
setup_keycloak.py: "In a production system you would enforce per-user scope access via role-based policies"Considerations:
Happy to discuss or help with implementation if this direction is interesting.
github-actions commentedon Apr 25, 2026
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. If this issue is still relevant, please comment or remove the stale label.
github-actions commentedon May 9, 2026
This issue was closed because it has been stale for 14 days with no activity. Feel free to reopen if this is still relevant.
omerboehm commentedon May 14, 2026
I've implemented a similar approach to the one proposed above by Hai Huang, on branch fix/github-issue-demo "Keycloak Role-Based Scope Gating") that achieves the same end-to-end behavior without modifying the go-processor:
Move scope gating into Keycloak rather than the AuthProxy. Realm roles (regular, privileged) are assigned to users (alice → regular, bob → privileged) and mapped to client roles / client scopes via a declarative policy.yaml.
Proxy requests only openid — authbridge/demos/github-issue/k8s/configmaps.yaml drops token_scopes from "openid github-tool-aud github-full-access" to "openid". Keycloak then issues only the scopes the user's role authorizes, so alice gets github-tool-aud while bob also gets github-full-access.
No code changes in the go-processor. The new config.yaml and policy.yaml plus an updated setup_keycloak.py express the access model declaratively.
Feat: AIAC OPA plugin integration + live enforcement (phase 2, PR 1) (#…
test: Surface raw outbound (code, body) on UC1 convergence timeout
Fix: Harden UC-1 integration pod resolution against rolling-restart race
Feat: AIAC OPA plugin integration + live enforcement (phase 2, PR 1) (#…
Test: Bind onboard port-forward to live Controller pod
Test: Bind onboard port-forward to live Controller pod
Feat: AIAC OPA plugin integration + live enforcement (phase 2, PR 1) (#…
Test: Bind onboard port-forward to live Controller pod
test: Surface raw outbound (code, body) on UC1 convergence timeout
Fix: Harden UC-1 integration pod resolution against rolling-restart race