private async Task <System.Security.Claims.ClaimsPrincipal> CreateUserAsync(ApiKey key) { var claims = new List <System.Security.Claims.Claim>(); if (_keyStore.SupportsClaims) { claims.AddRange(await _keyStore.GetClaimsAsync(key)); } else { claims.Add(new System.Security.Claims.Claim(System.Security.Claims.ClaimTypes.Name, key.ClientID)); } var identity = new System.Security.Claims.ClaimsIdentity(claims, this.Options.AuthenticationType); return(new System.Security.Claims.ClaimsPrincipal(identity)); }
private async Task <AuthenticatedEventContext> CreateIdentityAsync(ApiKey key) { var claims = new List <System.Security.Claims.Claim>(); if (_keyStore.SupportsClaims) { claims.AddRange(await _keyStore.GetClaimsAsync(key)); } else { claims.Add(new System.Security.Claims.Claim(System.Security.Claims.ClaimTypes.Name, key.ClientID)); } var identity = new System.Security.Claims.ClaimsIdentity(claims, this.Options.AuthenticationType); var eventContext = new AuthenticatedEventContext(this.Context, this.Scheme, this.Options, key.ClientID, identity); await this.Options.Events.OnAuthenticatedAsync(eventContext); return(eventContext); }