ENG-3001: Protect default_oauth_client#7720
Conversation
The seeded default_oauth_client is a system-internal FK owner for default policies and should not be visible or modifiable via the OAuth client API. - Add _is_system_client() predicate covering both root client and default_oauth_client - Update _get_client_or_error and _get_client_or_none to use the predicate - Filter default_oauth_client from list_clients results Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
Greptile SummaryThis PR protects the seeded Key changes:
Issue found:
Confidence Score: 2/5
Important Files Changed
Last reviewed commit: "Protect default_oaut..." |
| query = ( | ||
| ClientDetail.query(db=db) | ||
| .filter(ClientDetail.id != CONFIG.security.oauth_root_client_id) | ||
| .filter(ClientDetail.fides_key != DEFAULT_OAUTH_CLIENT_KEY) |
There was a problem hiding this comment.
NULL fides_key clients excluded from list
In SQL, NULL != 'default_oauth_client' evaluates to NULL (unknown), not TRUE. Because fides_key is defined as nullable=True in the ClientDetail model, any user-created client that has no fides_key (i.e., fides_key IS NULL) will fail this filter condition and be silently excluded from the paginated results.
In practice, regular clients created through the create_client endpoint do not set a fides_key, so they will all have fides_key = NULL, meaning this endpoint would return an empty list for all non-system clients — breaking the entire listing functionality.
The fix is to explicitly allow NULL values:
| .filter(ClientDetail.fides_key != DEFAULT_OAUTH_CLIENT_KEY) | |
| .filter(or_(ClientDetail.fides_key.is_(None), ClientDetail.fides_key != DEFAULT_OAUTH_CLIENT_KEY)) |
Note: or_ would also need to be imported from sqlalchemy (it is not currently imported in this file).
The seeded default_oauth_client is a system-internal FK owner for default
policies and should not be visible or modifiable via the OAuth client API.
Ticket ENG-3001
Description Of Changes
Hides a default client that is generated for policies in seed data. Deleting this could cause problems we so want to prevent it from being changed by clients.
Code Changes
Steps to Confirm
/api/v1/oauth/clientnot longer returns any results on a fresh db.Pre-Merge Checklist
CHANGELOG.mdupdatedmaindowngrade()migration is correct and works