IdentityModel.AspNetCore.OAuth2Introspection icon indicating copy to clipboard operation
IdentityModel.AspNetCore.OAuth2Introspection copied to clipboard

Support for actor claim type

Open matiii opened this issue 4 years ago • 4 comments

Hi,

Could you provide similar support for actors as AddJwtBearer handler does ?

matiii avatar Sep 24 '20 12:09 matiii

I need more details.

leastprivilege avatar Sep 24 '20 14:09 leastprivilege

Based on actort claim, lib should create Actor ClaimIdentity. Docs below https://docs.microsoft.com/en-us/dotnet/api/system.security.claims.claimsidentity.actor?view=netcore-3.1 https://docs.microsoft.com/en-us/dotnet/api/system.security.claims.claimtypes.actor?view=netcore-3.1

My custom implementation

.AddOAuth2Introspection("introspection", o => {;
                o.Events.OnCreatingTicket = principal => {
                    var actor = principal?.Claims.FirstOrDefault(x => x.Type == "actort");

                    if (actor != null)
                    {
                        var handler = new JwtSecurityTokenHandler();
                        var actorToken = handler.ReadJwtToken(actor.Value);

                        if (actorToken != null)
                        {
                            principal.Identities.First().Actor = new ClaimsIdentity(actorToken.Claims);
                        }
                    }

                    return Task.CompletedTask;
                };

            });

matiii avatar Sep 25 '20 13:09 matiii

Hey,

sorry this has been sitting here for a long time...

couple of questions -

  • where does the actort claim type come from - the closest I could think of is act from the token exchange spec
  • your assumption seems to be that there is a JWT on that claim - who produces this?

thanks

leastprivilege avatar Jan 30 '21 08:01 leastprivilege

Hi sorry, for late replying

Ad.1 Yep, i think act is the closest to actort, however I suspect abbreavation means actor token Ad.2 I produce it on my custom grant type flow

matiii avatar May 04 '21 10:05 matiii