Search code examples
c#authenticationazure-active-directoryadalclaims

ADAL JavaScript: Adding additional claims (ADAL JS)


I ran the ADAL JS sample SPA project from Github against my Azure AD.

That works well, but I want to add claims to the token after authentication.

In the SPA sample, you add middle-ware as follows:

app.UseWindowsAzureActiveDirectoryBearerAuthentication(
            new WindowsAzureActiveDirectoryBearerAuthenticationOptions
            {
                Audience = ConfigurationManager.AppSettings["ida:Audience"],
                Tenant = ConfigurationManager.AppSettings["ida:Tenant"]
            });

From here, do you have to add additional OAuth middleware to get access to something like Notifications to get to the ClaimsIdentity and AddClaim?


Solution

  • You can use the TokenValidationParamenters. See ValidateToken or TokenValidationParameters.CreateClaimsIdentity