Skip to content

Enforce system-app authorization on OAuth provider endpoints#16112

Open
TristanInSec wants to merge 1 commit intocdapio:developfrom
TristanInSec:enforce-oauth-authorization
Open

Enforce system-app authorization on OAuth provider endpoints#16112
TristanInSec wants to merge 1 commit intocdapio:developfrom
TristanInSec:enforce-oauth-authorization

Conversation

@TristanInSec
Copy link
Copy Markdown

Summary

The data pipeline StudioService's OAuthHandler exposes PUT/DELETE/GET endpoints for managing OAuth providers and stored credentials under v1/oauth/provider/.... OAuth providers are a cluster-wide resource — the stored loginURL, tokenRefreshURL, and client credentials are shared across the instance — but the handler previously performed no authorization check beyond the CDAP baseline, so any authenticated user of the instance could register, modify, delete or fetch OAuth providers and their credentials.

This PR wires the existing ContextAccessEnforcer from the SystemHttpServiceContext and gates every endpoint on enforceOnParent(SYSTEM_APP_ENTITY, SYSTEM, permission):

  • Read endpoints (getAuthURL, getOAuthCredential, getOAuthCredentialValidity) enforce StandardPermission.GET.
  • Mutating endpoints (putOAuthProvider, putOAuthCredential) enforce StandardPermission.UPDATE.
  • deleteOAuthProvider enforces StandardPermission.DELETE.

After this change, only users with system-app administration permissions in the system namespace can call these endpoints.

This mirrors the ContextAccessEnforcer usage already adopted by ConnectionHandler and DraftHandler in the same module.

Test plan

  • Existing data-pipeline-base tests still pass.
  • Manual check: with authorization enabled, a user who holds system-app permissions in the system namespace can PUT/GET/DELETE an OAuth provider as before.
  • Manual check: a user without those permissions receives a 403 from the same endpoints.

The data pipeline StudioService's OAuthHandler exposes PUT/DELETE/GET
endpoints for managing OAuth providers and stored credentials. These
are cluster-wide resources, but the handler previously performed no
authorization check beyond CDAP's baseline authentication, so any
authenticated user of the instance could register, modify, delete, or
fetch credentials for any OAuth provider.

Wire the existing ContextAccessEnforcer from the SystemHttpServiceContext
and gate every endpoint on enforceOnParent(SYSTEM_APP_ENTITY, SYSTEM)
with the matching StandardPermission (GET for reads, UPDATE for
PUT-based mutations, DELETE for the delete endpoint). Only users with
system-app administration permissions in the system namespace can now
use these endpoints.

This mirrors the ContextAccessEnforcer usage already adopted by
ConnectionHandler and DraftHandler in the same module.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants