public static ClaimsIdentity CreateIdentity(IdentityManager identityManager, IEnumerable <Claim> claims, string authenticationType) { if (identityManager == null) { throw new ArgumentNullException("identityManager"); } if (claims == null) { throw new ArgumentNullException("claims"); } IdentityAuthenticationOptions options = identityManager.Settings.GetAuthenticationOptions(); return(new ClaimsIdentity(claims, authenticationType, options.UserNameClaimType, options.RoleClaimType)); }
public static IServiceCollection AddIdsAuthentication(this IServiceCollection builder, IdentityAuthenticationOptions options) { builder.AddAuthentication(options.Scheme) .AddIdentityServerAuthentication(opt => { opt.Authority = options.Authority; opt.RequireHttpsMetadata = options.RequireHttps; opt.ApiSecret = options.ApiSecret; opt.ApiName = options.ApiName; opt.SupportedTokens = SupportedTokens.Both; }); return(builder); }