Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Adds support for the OAuth password grant (“rxlab sign in API”) by extending token request validation and implementing password-based token issuance in the OAuth token endpoint.
Changes:
- Adds
grant_type=passwordvalidation and unit coverage. - Implements password grant handling with user lookup, password verification, scope validation, sign-in permission checks, and token issuance.
- Adds endpoint tests for successful and failed password-grant requests.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
lib/validations/oauth.ts |
Adds schema support for password grant requests. |
lib/validations/oauth.test.ts |
Adds validation tests for password grant inputs and unsupported grant types. |
app/api/oauth/token/route.ts |
Adds password grant routing and token issuance logic. |
app/api/oauth/token/password-grant.test.ts |
Adds API tests for password grant success and common failure cases. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+488
to
+507
| // Resolve allowed scopes; default to client's allowed scopes when omitted | ||
| const allowedScopes: string[] = JSON.parse(client.allowedScopes); | ||
| let requestedScopes: string[]; | ||
| if (data.scope) { | ||
| requestedScopes = data.scope.split(" ").filter(Boolean); | ||
| const invalidScopes = requestedScopes.filter( | ||
| (s) => !allowedScopes.includes(s), | ||
| ); | ||
| if (invalidScopes.length > 0) { | ||
| return NextResponse.json( | ||
| { | ||
| error: "invalid_scope", | ||
| error_description: `Requested scope(s) not allowed: ${invalidScopes.join(", ")}`, | ||
| }, | ||
| { status: 400 }, | ||
| ); | ||
| } | ||
| } else { | ||
| requestedScopes = allowedScopes; | ||
| } |
Comment on lines
+525
to
+526
| const passwordValid = await verifyPassword(user.passwordHash, data.password); | ||
| if (!passwordValid) { |
Comment on lines
+584
to
+585
| email: requestedScopes.includes("email") ? user.email : undefined, | ||
| email_verified: requestedScopes.includes("email") |
…rty clients Adds `grant_type=password` to /api/oauth/token (extends tokenRequestSchema with a password branch and routes to a handlePasswordGrant) and a new /api/oauth/signup JSON route that wraps the existing register action so native clients like the macOS RxAuthSwift test app can sign up and sign in without the web UI's server-action RPC. Includes tests for both. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
No description provided.