Skip to content

Validate authorization response state in MSAL Node middleware - #139

Merged
Robbie-Microsoft merged 1 commit into
mainfrom
robbie-microsoft-b2c-callback-sample-fix
Sep 24, 2026
Merged

Robbie-Microsoft merged 1 commit into
mainfrom
robbie-microsoft-b2c-callback-sample-fix

Conversation

@Robbie-Microsoft

@Robbie-Microsoft Robbie-Microsoft commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Pull Request

Purpose

  • Validate that the authorization response state matches the state stored in the session before redeeming the authorization code.
  • Use the documented one-argument ConfidentialClientApplication.acquireTokenByCode API.
  • Add focused tests for matching, missing, and mismatched state values and the token redemption call shape.

Does this introduce a breaking change

    [ ] Yes
    [x] No

Pull request type

    [x] Bugfix
    [ ] Feature
    [ ] Code style update (formatting, local variables)
    [ ] Documentation content changes
    [ ] Other... Please describe:

How to test

  • From Common/msal-node-wrapper, run:
    npm ci
    npm test -- --runInBand test/middleware/handlers/redirectHandler.spec.ts
    npx tsc --noEmit
    npx eslint src/middleware/handlers/redirectHandler.ts test/middleware/handlers/redirectHandler.spec.ts

What to check

  • A matching authorization response state allows token redemption and redirect handling to continue.
  • Missing or mismatched state is rejected before token redemption.
  • acquireTokenByCode receives only the authorization code request.

Other Information

N/A

assistance: agentic-cli
type: bug
agent-tool: copilot-cli
agent-model: gpt-5.6-sol
work-item: AB#n/a

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@Robbie-Microsoft Robbie-Microsoft added agentic-cli Bulk of changes driven by a terminal coding agent bug Something isn't working labels Sep 24, 2026
@Robbie-Microsoft
Robbie-Microsoft merged commit c8a3b57 into main Sep 24, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agentic-cli Bulk of changes driven by a terminal coding agent bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants