I’m trying to get appRoles in a .net framework application using OpenIDConnect with OWIN.
The user can authenticate but i don’t get the roles along with the claim. Unsure where i went wrong:
Public Sub ConfigureAuth(app As IAppBuilder)
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType)
app.UseCookieAuthentication(New CookieAuthenticationOptions())
app.UseOpenIdConnectAuthentication(New OpenIdConnectAuthenticationOptions() With {
.ClientId = clientId,
.Authority = authority,
.PostLogoutRedirectUri = postLogoutRedirectUri,
.Notifications = New OpenIdConnectAuthenticationNotifications() With {
.SecurityTokenValidated = Function(context)
Dim name As String = context.AuthenticationTicket.Identity.FindFirst("preferred_username").Value
context.AuthenticationTicket.Identity.AddClaim(New Claim(ClaimTypes.Name, name, String.Empty))
Return Task.FromResult(0)
End Function,
.AuthenticationFailed = Function(context)
Return Task.FromResult(0)
End Function
}
})
app.UseStageMarker(PipelineStage.Authenticate)
End Sub