Skip to content

Conversation

@seantleonard
Copy link
Contributor

@seantleonard seantleonard commented Nov 18, 2022

Why make this change?

  • Closes Improve X-MS-CLIENT-PRINCIPAL payload parsing and error handling #864 for AppService EasyAuth Parsing
    • Before this change, an EasyAuth payload unable to be deserialized into AppService ClientPrincipal would result in silently handling the request as "anonymous" with no indication that EasyAuth payload was invalid.
    • After this change, correctly notify client when EasyAuth payload is invalid via HTTP 401 Unauthorized response because a properly configured EasyAuth environment guarantees that an EasyAuth payload will be present for authenticated requests.
      • Note: No EasyAuth payload indicates an anonymous request. Applicable when the runtime config's authentication provider is StaticWebApps or AppService
      • Note: An EasyAuth payload that fails deserialization suggests there is an EasyAuth environment issue.

What is this change?

  • This change modifies previous EasyAuth authentication behavior. Now, requests with an invalid EasyAuth payload will result in HTTP 401 because the StaticWebApps/AppService Authentication Handler interprets a null identity as an EasyAuth authentication failure.
    • identity is null when:
    1. The EasyAuth header value fails to deserialize into the expected AppServiceClientPrincipal types.
    2. The EasyAuth header deserializes into the expected AppServiceClientPrincipal but property Auth_typ is null. Auth_typ signifies the authentication method (provider) and a null value is not expected.

How was this tested?

  • Integration Tests
  • Unit Tests added and updated to pass with the new behavior. Also updated authenticateDevModeRequests legacy behavior to handle this change.

Sample Request(s)

  • REST
    • Set X-MS-CLIENT-PRINCIPAL header as the following JSON when authentication provider is AppService
{"message": "hello world"}

…g and handling. Updated and added unit tests to reflect new behavior: invalid EasyAuth payload results in HTTP 401.
@seantleonard seantleonard changed the title Enhanced EasyAuth Payload Processing Enhanced AppService EasyAuth Payload Processing Nov 18, 2022
Copy link
Collaborator

@Aniruddh25 Aniruddh25 left a comment

Choose a reason for hiding this comment

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

LGTM after answering few questions :)

Copy link
Contributor

@ayush3797 ayush3797 left a comment

Choose a reason for hiding this comment

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

LGTM!

@seantleonard seantleonard enabled auto-merge (squash) November 30, 2022 17:22
Copy link
Contributor

@ayush3797 ayush3797 left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for resolving the comments, Sean!

@seantleonard seantleonard merged commit 3878fd2 into main Nov 30, 2022
@seantleonard seantleonard deleted the dev/seleonar/easyAuthParseEnahance branch November 30, 2022 17:47
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.

Improve X-MS-CLIENT-PRINCIPAL payload parsing and error handling

4 participants