Skip to content

Conversation

hectormmg
Copy link
Member

This PR:

  • Adds the httpMethod and authorizePostBodyParameters options to BaseAuthRequest
  • Enables calls to the /authorize endpoint using HTTP method "POST" using the Redirect, Popup, and SilentIFrame flows
  • Ensures extraQueryParameters are still encoded into the request URL in POST flow
  • Ensures httpMethod cannot be set to 'GET' when using the EAR protocol mode (throws when the request is validated)
  • Ensures request validation to make sure the combinations of httpMethod and authorizePostBodyParameters as well as httpMethod and protocol mode happens before synchronous popup is opened.

This PR:
- Adds the `httpMethod` and `authorizePostBodyParameters` options to
`BaseAuthRequest`
- Enables calls to the `/authorize` endpoint using HTTP method "POST"
using the `Redirect`, `Popup`, and `SilentIFrame` flows
- Ensures `extraQueryParameters` are still encoded into the request URL
in `POST` flow
- Ensures `httpMethod` cannot be set to 'GET' when using the EAR
protocol mode (throws when the request is validated)
- Ensures request validation to make sure the combinations of
`httpMethod` and `authorizePostBodyParameters` as well as `httpMethod`
and protocol mode happens before synchronous popup is opened.
@Copilot Copilot AI review requested due to automatic review settings August 13, 2025 22:43
@github-actions github-actions bot added documentation Related to documentation. samples Related to the samples apps for the library. msal-browser Related to msal-browser package msal-common Related to msal-common package labels Aug 13, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for calling the /authorize endpoint using HTTP POST method across all browser authentication flows. The implementation includes new request validation logic that ensures proper combinations of HTTP method, protocol mode, and body parameters while maintaining backward compatibility with existing GET-based flows.

  • Adds httpMethod and authorizePostBodyParameters fields to the BaseAuthRequest interface
  • Implements POST flow support for Redirect, Popup, and SilentIFrame authentication flows
  • Ensures validation prevents invalid combinations like GET method with body parameters or GET method with EAR protocol mode

Reviewed Changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
lib/msal-common/src/utils/Constants.ts Adds HttpMethod enum with GET and POST values
lib/msal-common/src/request/BaseAuthRequest.ts Extends request interface with httpMethod and authorizePostBodyParameters fields
lib/msal-common/src/error/ClientConfigurationErrorCodes.ts Adds validation error codes for invalid request method configurations
lib/msal-common/src/request/RequestParameterBuilder.ts Adds utility function to handle POST body parameters
lib/msal-browser/src/request/RequestHelpers.ts Implements request validation logic for HTTP method combinations
lib/msal-browser/src/protocol/Authorize.ts Adds getCodeForm function for creating POST forms
lib/msal-browser/src/interaction_handler/SilentHandler.ts Implements POST flow support for silent iframe requests
lib/msal-browser/src/interaction_client/StandardInteractionClient.ts Integrates request validation into authorization request initialization
lib/msal-browser/src/interaction_client/SilentIframeClient.ts Adds POST method support to silent iframe flow
lib/msal-browser/src/interaction_client/RedirectClient.ts Implements POST flow execution for redirect authentication
lib/msal-browser/src/interaction_client/PopupClient.ts Adds POST method support to popup authentication flow
Sample files Updates test app to demonstrate POST method usage
Test files Adds comprehensive test coverage for new functionality
Change files Documents API changes for both msal-common and msal-browser packages

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

/**
* Adds authorize body parameters to the request parameters
* @param parameters
* @param bodyParameters
Copy link
Preview

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

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

Missing hyphen after parameter name in JSDoc comment. Should be '@param parameters - Description of parameters'

Suggested change
* @param bodyParameters
* @param parameters - The map to which body parameters will be added.
* @param bodyParameters - The body parameters to add to the map.

Copilot uses AI. Check for mistakes.

/**
* Adds authorize body parameters to the request parameters
* @param parameters
* @param bodyParameters
Copy link
Preview

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

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

Missing hyphen after parameter name in JSDoc comment. Should be '@param bodyParameters - Description of bodyParameters'

Suggested change
* @param bodyParameters
* @param parameters - Map to which body parameters will be added
* @param bodyParameters - Key-value pairs to add to the parameters map

Copilot uses AI. Check for mistakes.

// Warning: (ae-missing-release-tag) "addPostBodyParameters" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public
function addPostBodyParameters(parameters: Map<string, string>, bodyParameters: StringDict): void;
Copy link
Preview

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

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

Missing release tag (@Alpha, @beta, @public, or @internal) for the addPostBodyParameters function as indicated by the API extractor warning

Copilot uses AI. Check for mistakes.

// Warning: (ae-missing-release-tag) "HttpMethod" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
// Warning: (ae-missing-release-tag) "HttpMethod" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
Copy link
Preview

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

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

Missing release tag (@Alpha, @beta, @public, or @internal) for the HttpMethod constant as indicated by the API extractor warning

Suggested change
// @public (undocumented)
// @public

Copilot uses AI. Check for mistakes.

@hectormmg hectormmg marked this pull request as draft August 14, 2025 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Related to documentation. msal-browser Related to msal-browser package msal-common Related to msal-common package samples Related to the samples apps for the library.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant