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

[Feature Request] Leverage the new .WithCssRoutingHint in MSAL.NET 4.34.0 #1303

Closed
jmprieur opened this issue Jul 8, 2021 · 1 comment
Closed

Comments

@jmprieur
Copy link
Collaborator

jmprieur commented Jul 8, 2021

Is your feature request related to a problem? Please describe.

  • Microsoft.Identity.Web:

  • MSAL.ENT 4.33.0 retro-fitted a similar API

    public sealed class AcquireTokenByAuthorizationCodeParameterBuilder : 
      AbstractConfidentialClientAcquireTokenParameterBuilder<AcquireTokenByAuthorizationCodeParameterBuilder> {
          public AcquireTokenByAuthorizationCodeParameterBuilder WithCcsRoutingHint(string userName);
          public AcquireTokenByAuthorizationCodeParameterBuilder WithCcsRoutingHint(string userObjectIdentifier, string tenantIdentifier);
      }
      public sealed class AcquireTokenOnBehalfOfParameterBuilder : 
      AbstractConfidentialClientAcquireTokenParameterBuilder<AcquireTokenOnBehalfOfParameterBuilder> {
          public AcquireTokenOnBehalfOfParameterBuilder WithCcsRoutingHint(string userName);
          public AcquireTokenOnBehalfOfParameterBuilder WithCcsRoutingHint(string userObjectIdentifier, string tenantIdentifier);
      }
      public sealed class GetAuthorizationRequestUrlParameterBuilder : 
      AbstractConfidentialClientAcquireTokenParameterBuilder<GetAuthorizationRequestUrlParameterBuilder> {
          public GetAuthorizationRequestUrlParameterBuilder WithCcsRoutingHint(string userObjectIdentifier, string tenantIdentifier);
      }

Describe the solution you'd like

  • Update the current code in Id.Web (still nice as it takes a ClaimsPrincipal), to use the new MSAL.NET 4.34.0 API

    public static AbstractAcquireTokenParameterBuilder<T> WithCcsRoutingHint<T>(
    this AbstractAcquireTokenParameterBuilder<T> builder,
    ClaimsPrincipal? user)
    where T : AbstractAcquireTokenParameterBuilder<T>
    {
    builder.WithExtraHttpHeaders(new Dictionary<string, string>
    {
    { Constants.XAnchorMailbox, CreateCcsRoutingHintFromHttpContext(user) },
    });
    return builder;
    }
    internal static string CreateCcsRoutingHintFromHttpContext(ClaimsPrincipal? user)
    {
    if (user != null)
    {
    string? oid = user.GetObjectId();
    string? tid = user.GetTenantId();
    if (!string.IsNullOrEmpty(oid) && !string.IsNullOrEmpty(tid))
    {
    return $"oid:{oid}@{tid}";
    }
    }
    return string.Empty;
    }

  • Use the new API instead of the .WithExtraHttpHeaders:

    .WithExtraHttpHeaders(new Dictionary<string, string> { { Constants.XAnchorMailbox, ccsRoutingHint } });

Describe alternatives you've considered
Leave the current code in Id.Web

@jmprieur jmprieur added this to the 1.15 milestone Jul 8, 2021
@jmprieur jmprieur changed the title [Feature Request] Leverage the new .WithCssRoutingHint in MSAL.NET 4.33.0 [Feature Request] Leverage the new .WithCssRoutingHint in MSAL.NET 4.34.0 Jul 8, 2021
@jennyf19 jennyf19 removed this from the 1.14.1 milestone Jul 15, 2021
@jennyf19
Copy link
Collaborator

Included in 1.15 release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants