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

refactor: verifyRequest => validateOauthSecurity #1494

Merged
merged 2 commits into from
Feb 4, 2025

Conversation

csmig
Copy link
Member

@csmig csmig commented Feb 2, 2025

Resolves #1482

The existing verifyRequest() does too much work for a utility function (non-middleware) attached to EOV:

  • validates tokens
  • creates the request's userObject property
  • creates/updates a user's lastClaims
  • checks for improper use of the parameter elevate=true
  • checks scopes for the request

This PR separates these tasks into two new Express middlewares and limits the renamed EOV utility function to checking scopes.

As far as handling OP outages, the current code actually does a fair job with that. There are three scenarios to handle:

  1. OP host is gone (connection requests are ignored)
  2. OP host is up but OP service is down (connection requests are actively refused by host OS)
  3. OP host and service are up but are slow or unresponsive (connections accepted but slow/no data flows)

In real-world testing, the current code and this PR both handle scenario 2 well, although the error message has been improved in this PR. Scenarios 1 and 3 are handled better by this PR since the timeouts for the JWKS request were reduced from 30s to 5s.

Recommend refactoring our JWKS key fetch/cache/log/retrieve operations and consider moving much of it to local code and remove the jwks-rsa dependency. But that's for another day.

@csmig csmig added API OIDC OpenID Connect labels Feb 2, 2025
@csmig csmig marked this pull request as ready for review February 3, 2025 22:31
Copy link

sonarqubecloud bot commented Feb 3, 2025

@cd-rite cd-rite merged commit 2b6492e into main Feb 4, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API OIDC OpenID Connect
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor verifyRequest() in auth.js
2 participants