Skip to content

[Bug] ClaimActions not being invoked #749

Description

@tonytilbo

Which version of Microsoft Identity Web are you using?
E.g. Microsoft Identity Web 1.2.0

Where is the issue?

  • Web app
    • Sign-in users
    • Sign-in users and call web APIs
  • Web API
    • Protected web APIs (validating tokens)
    • Protected web APIs (validating scopes)
    • Protected web APIs call downstream web APIs
  • Token cache serialization
    • In-memory caches
    • Session caches
    • Distributed caches
  • Other (please describe)
    This is a new app or an experiment.

Repro
We are attempting to use a custom ClaimAction that will do some additional mapping of JWT claims to custom claims on the identity.

public class CustomClaimAction : ClaimAction
{
	public CustomClaimAction(string claimType, string valueType): base (claimType, valueType) { }
        public override void Run(JsonElement userData, ClaimsIdentity identity, string issuer) 
                                  => throw new System.NotImplementedException();
}

services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
  .AddMicrosoftIdentityWebApi(jwt => { }, options =>
  {
      options.TenantId = Configuration["AzureAd:TenantId"];
      options.ClientId = Configuration["AzureAd:ClientId"];
      options.Domain = Configuration["AzureAd:Domain"];
      options.Instance = Configuration["AzureAd:Instance"];

       options.ClaimActions.Add(new CustomClaimAction (ClaimTypes.Role, ClaimValueTypes.String));
 });

Expected behavior
I expect the Run method of the CustomClaimAction to be invoked.

Actual behavior
Method is not called.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2bugSomething isn't workingenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions