public ClaimsPrincipal ValidateApiKey(ApiKeyValidationContext context, string apiKey, out ValidatedApiKey validatedApiKey)
 {
     if (errorType != null)
     {
         var err = (Exception)Activator.CreateInstance(errorType);
         throw err;
     }
     throw new Exception();
 }
예제 #2
0
        public ClaimsPrincipal ValidateApiKey(ApiKeyValidationContext context, string apiKey, out ValidatedApiKey validatedApiKey)
        {
            validatedApiKey = new ValidatedApiKey();
            _tokenValidator?.Invoke(apiKey);
            var claims = new[]
            {
                // Make sure to use a different name identifier
                // than the one defined by CustomTokenValidated.
                new Claim(ClaimTypes.NameIdentifier, "Bob le Tout Puissant"),
                new Claim(ClaimTypes.Email, "*****@*****.**"),
                new Claim(ClaimsIdentity.DefaultNameClaimType, "bob"),
            };

            return(new ClaimsPrincipal(new ClaimsIdentity(claims, context.Options.AuthenticationScheme)));
        }