feat(auth): enable OAuth with permission-group controls - #7588
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
Greptile SummaryThis PR enables the OAuth provider whenever authentication is enabled and introduces permission-group enforcement throughout the OAuth lifecycle.
Confidence Score: 5/5The PR appears safe to merge; the two previously identified refresh-policy races are resolved and no new actionable failures remain. Refresh now acquires the organization mutation locks before reading Enterprise entitlement on the same transaction, then evaluates OAuth policy under the permission-group lock before consuming or rotating the token family. The executor reaches the underlying entitlement queries and is distinct from the earlier preflight cache key. Both previous findings are fully fixed, and the current changes add regression coverage for concurrent policy restriction and Enterprise activation.
|
| Filename | Overview |
|---|---|
| apps/sim/lib/auth/oauth-token-family.ts | Refresh rotation now rechecks the Enterprise permission regime within the locked transaction before applying current OAuth policy. |
| apps/sim/lib/permission-groups/resolve.server.ts | Permission-regime resolution accepts a transaction executor so entitlement reads cannot reuse an earlier preflight result. |
| apps/sim/app/api/auth/oauth2/authorize/route.ts | Authorization is tied to authentication availability and forwards access denials only to validated client callbacks. |
| apps/sim/app/api/auth/oauth2/token/route.ts | Token issuance and refresh enforce current OAuth access policy while retaining protocol-safe error handling. |
| apps/sim/lib/api/server/routes/v2-api-key-auth.ts | OAuth bearer-token API requests gain permission-group enforcement without changing existing API-key behavior. |
| apps/sim/app/api/organizations/[id]/permission-groups/[groupId]/route.ts | Permission-group updates are serialized and preserve stored policy during partial or metadata-only edits. |
Sequence Diagram
sequenceDiagram
participant Client as OAuth Client
participant Auth as Authorization Server
participant Policy as Permission Groups
participant Tokens as Token Store
participant API as Sim API
Client->>Auth: Authorization request with PKCE
Auth->>Policy: Check oauth_apps.use and CLI policy
alt Access permitted
Auth-->>Client: Authorization code
Client->>Auth: Exchange code
Auth->>Policy: Recheck current policy
Auth->>Tokens: Issue token family
Auth-->>Client: Access and refresh tokens
Client->>API: Access token
API->>Policy: Check current workspace/account policy
API-->>Client: Authorized response
else Access restricted
Auth-->>Client: access_denied at verified callback
end
Client->>Auth: Refresh token
Auth->>Policy: Read entitlement and policy under locks
alt Still permitted
Auth->>Tokens: Atomically rotate token family
Auth-->>Client: Replacement tokens
else Permission revoked
Auth-->>Client: invalid_grant without consuming token
end
Reviews (4): Last reviewed commit: "fix(auth): recheck OAuth entitlement und..." | Re-trigger Greptile
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
Summary
Type of Change
Testing
Checklist