public static async Task <ClaimsIdentity> GetIdentityFromExternalProvider(this IOwinContext context) { if (context == null) { throw new ArgumentNullException("context"); } var id = await context.GetIdentityFromExternalSignIn(); if (id != null) { // this is mapping from the external IdP's issuer to the name of the // katana middleware that's registered in startup var result = await context.GetAuthenticationFrom(Constants.ExternalAuthenticationType); if (!result.Properties.Dictionary.Keys.Contains(Constants.Authentication.KatanaAuthenticationType)) { throw new InvalidOperationException("Missing KatanaAuthenticationType"); } var provider = result.Properties.Dictionary[Constants.Authentication.KatanaAuthenticationType]; var newClaims = id.Claims.Select(x => new Claim(x.Type, x.Value, x.ValueType, provider)); id = new ClaimsIdentity(newClaims, id.AuthenticationType); } return(id); }
static async Task <ClaimsIdentity> GetIdentityFrom(this IOwinContext context, string authenticationType) { var result = await context.GetAuthenticationFrom(authenticationType); if (result != null && result.Identity != null && result.Identity.IsAuthenticated) { return(result.Identity); } return(null); }
internal static async Task <string> GetSignInIdFromExternalProvider(this IOwinContext context) { var result = await context.GetAuthenticationFrom(Constants.ExternalAuthenticationType); if (result != null) { string val; if (result.Properties.Dictionary.TryGetValue(Constants.Authentication.SigninId, out val)) { return(val); } } return(null); }
public static async Task <ClaimsIdentity> GetIdentityFrom(this IOwinContext context, string authenticationType) { if (context == null) { throw new ArgumentNullException("context"); } var result = await context.GetAuthenticationFrom(authenticationType); if (result != null && result.Identity != null && result.Identity.IsAuthenticated) { return(result.Identity); } return(null); }
public static async Task <string> GetSignInIdFromExternalProvider(this IOwinContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } var result = await context.GetAuthenticationFrom(Constants.ExternalAuthenticationType); if (result != null) { string val; if (result.Properties.Dictionary.TryGetValue(Constants.Authentication.SigninId, out val)) { return(val); } } return(null); }