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

OAuth2 implementation #2

Merged
merged 48 commits into from
Sep 24, 2024
Merged

OAuth2 implementation #2

merged 48 commits into from
Sep 24, 2024

Conversation

ldgit
Copy link
Owner

@ldgit ldgit commented Sep 24, 2024

Working OAuth2 implementation that uses Authorization Code flow with PKCE support.

Using PKCE (Proof Key for Code Exchange) secures the flow against CSRF and authorization code injection attacks.

Helmet plugin sets the headers that tell browsers not to embed the authorization URL in an iframe to prevent clickjacking attacks.

It only partially supports OpenID Connect (e.g. no ID token yet), this will be done in a separate PR.

ldgit added 30 commits July 27, 2024 23:05
  - /approve route
  - /authorize route
- redirect to /approve page after successful login if oauth2 query parameters are set
- create dummy client for development
- run playwright using dev server locally, but use production build for CI tests
- api routes
- db tables for access and authorization tokens
- happy path e2e test
- TODO: actual authentication, parameter validation, error handling
- checking that redirect_uri matches the client on the `/authorize` endpoint
- warn resource owner (user) if redirect_uri does not match the client
- bugfix: links to favicon and styles in layout
- changed scope parameter to a value that is client agnostic
- disable biome.js noForEach rule
- prioritize warning the user if client id or redirect uri are invalid
- redirect to `redirect_uri` with error info if response_type is invalid
- fixed some typescript interfaces that didn't make sense
- check if user is signed in
- validate query string same as in `GET /authorize` route
- change expected scope from `basic-info` to `openid`
- these endpoints are "back channel", ie. they are not meant to be accessed by user's browser or use their auth server session cookie
- `/userinfo` endpoint should instead use the provided access token to fetch correct user info
new validations include:
- missing request parameters
- invalid client credentials
- mismatched redirect_uri
Also:
- /authorize endpoint now returns actual authorization code
Note: had to change created_at column type in the database for this to work
also /userinfo now expects authorization header value to be base64 encoded
@ldgit ldgit merged commit 3751697 into main Sep 24, 2024
1 check passed
@ldgit ldgit deleted the oauth2 branch September 24, 2024 16:32
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.

1 participant