Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OAuth2 scope support #156

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

lionello
Copy link

@lionello lionello commented Jan 16, 2025

Fixes #5

First time contributing and new to bun/hono, so let me know if something is out of style. Particularly not sure about usage of test.each for testing with and without scopes.

The OAuth2 spec is pretty thin wrt scope. In particular, the corner cases seem to differ between implementations. For this PR, I've considered the absence of scope different from the empty scope, ie. &scope=. Additionally, in the token/refresh request I ignore scopes that were not part of the auth request, instead of for example returning invalid_scope error.

Since the resource server will have to check the issued scopes, I've added scopes to the JWT, iff scope was specified in the auth request.

Copy link

changeset-bot bot commented Jan 16, 2025

🦋 Changeset detected

Latest commit: 3461f7c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@openauthjs/openauth Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@@ -38,22 +38,22 @@
*
* @packageDocumentation
*/
import type { v1 } from "@standard-schema/spec"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These got reordered because of Organize Imports. Let me know if you want me to revert this part.

* }
* ```
*/
scopes_supported?: string[]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would also be a good place to add default_scopes or so, which would be used if the auth request has no scope.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is right. Haven't used this before either.

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.

Oauth Access Token Scopes
2 participants