Skip to content

Owin Identity Construction crash if "preferred_username" claim is not present #2388

@guillaumejay

Description

@guillaumejay

Microsoft.Identity.Web Library

Microsoft.Identity.Web

Microsoft.Identity.Web version

2.11.1

Web app

Sign-in users

Web API

Protected web APIs (validating tokens)

Token cache serialization

In-memory caches

Description

Current Owin code looks for a very specific claims preferred_username and crash if not present

Reproduction steps

Use Owin ( test/devapps/asp.net MVC/OwinWebApp application ) on Azure AD B2C without this claims.

Error message

System.NullReferenceException

Id Web logs

No response

Relevant code snippets

This is the problematic webcode :
 string name = context.AuthenticationTicket.Identity.FindFirst("preferred_username").Value;
Microsoft.identy.web.Owin/AppBuilderExtension.Cs
https://github.com/AzureAD/microsoft-identity-web/blob/master/src/Microsoft.Identity.Web.OWIN/AppBuilderExtension.cs#L180

Regression

No response

Expected behavior

Read the the claim name from the ClaimNameType name ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    answeredquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions