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

Introduces IAuthorizationHeaderProviderExtension #129

Merged
merged 4 commits into from
Jun 20, 2024

Conversation

sruke
Copy link
Contributor

@sruke sruke commented Jun 14, 2024

What?
This PR updates the IAuthorizationHeaderProvider interface to include the CreateAuthorizationHeaderAsync API. This new API allows for acquiring an authorization header on behalf of either a user or an application. This is a breaking change. To accomodate it Microsoft.Identity.Abstractions will update its major version.

Why?
The current interface exposes separate APIs for obtaining headers on behalf of a user and an app.
The existing method for acquiring a header on behalf of an app does not accept a ClaimsPrincipal, limiting the flexibility and usability of the current API.

@sruke sruke requested a review from a team as a code owner June 14, 2024 00:14
@sruke sruke marked this pull request as draft June 14, 2024 00:20
@sruke sruke closed this Jun 15, 2024
@sruke sruke reopened this Jun 15, 2024
@sruke sruke force-pushed the sruthi/HeaderProviderExtension branch from 6f84321 to 762e446 Compare June 18, 2024 12:51
@sruke sruke self-assigned this Jun 20, 2024
@sruke sruke marked this pull request as ready for review June 20, 2024 16:35
/// <param name="cancellationToken">A token to cancel the operation.</param>
/// <returns>A string containing the authorization header, such as "Bearer token" or "PoP token".</returns>
Task<string> CreateAuthorizationHeaderAsync(
IEnumerable<string> scopes,
Copy link
Member

Choose a reason for hiding this comment

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

Do we have to pass IEnumerable can it be IList?

Copy link

Choose a reason for hiding this comment

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

IEnumerable is consistent with the CreateAuthorizationHeaderForUserAsync signature. However, sometimes we manipulate the scopes (like adding default ones), in that case IList would be better. I prefer the IList, unless you'd prefer IEnumerable for consistency.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's supposed to be immutable. No need to manipulate anything. IEnumerable is the base interface for string[], IList etc ...

Copy link
Contributor

@jmprieur jmprieur 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 @sruke

You might want to up the version in ?

<ClientSemVer Condition="'$(ClientSemVer)' == ''">5.2.0-local</ClientSemVer>

Copy link
Collaborator

@jennyf19 jennyf19 left a comment

Choose a reason for hiding this comment

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

:shipit:

@sruke sruke merged commit 0e09887 into main Jun 20, 2024
4 checks passed
@sruke sruke deleted the sruthi/HeaderProviderExtension branch June 20, 2024 23:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants