No event emitted for failure to completeAuthorizationRequestIfPossible() in browser
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1k
- Forks
- 165
- PR merge metrics
- No merged PRs in 30d
Description
Expected Behaviour
[REQUIRED] Describe expected behavior
When there is a state or redirect_uri mismatch, an event should emitted that can be used to detect this mismatch instead of simply logging to the console.
Describe the problem
When an authorization request fails due to a state or request_uri mismatch, there is nothing to hook into or listen to, that can be used to detect when that happens.
[REQUIRED] Actual Behavior
As part of our OIDC PKCE flow for authenticating application users, we use the completeAuthorizationRequestIfPossible() method to process a response from the OpenID Connect Provider.
We noticed an issue in our application where users were bookmarking (or their browser autocompletes to) the /callback route in our application. This callback route uses AppAuth-JS to process the response from the IdP. The problem is, users are bookmarking this callback route containing an old auth code and state.
When a user accesses this URL, it ultimately leads to a state mismatch as there is no pending request in local storage.
At this point, the authentication process ends with a log to the console.
From what I can see, there is no event emitted that we can listen to when this happens or relevant error thrown, which leaves our application "idle" without us knowing.
Is there currently something that we can hook into or listen to which indicates that this has happened?
If not, can something be provided?
Note: There are other instances that can lead to this failure path e.g. a user bookmarking an OpenID Connect Provider URL containing our application's
redirect_uribut astatefrom a previous request. After authenticating with the IdP, the user is redirected successfully but hits a "dead end".
[REQUIRED] Steps to reproduce the behavior
Options to reproduce:
- Remove the pending request from the browser local storage before attempting to process a response OR
- Include an invalid
statein the URL that does not match the state in the pending request stored in the browser local storage
[REQUIRED] Environment
- AppAuth-JS version: 1.3.2
- AppAuth-JS Environment (Node, Browser (UserAgent), ...): Browser
- Source code snippts (inline or JSBin) N/A
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with completeAuthorizationRequestIfPossible() and inspect the failure path in src/authorization_request_handler.ts around line 128, then follow the state-mismatch handling in src/redirect_based_handler.ts around line 138. Reproduce the cases by removing the pending request from browser local storage or using an invalid state, and verify that the failure becomes observable without relying only on console logging.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- authentication
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100