コード例 #1
0
        private ClaimsPrincipal CreatePrincipal(string apiKeyValue)
        {
            var apiKeyClaim = new Claim(ApiKeyConstants.ClaimName, apiKeyValue);
            var clientName  = apiKeyService.GetClientName(apiKeyValue);
            var nameClaim   = new Claim(ClaimTypes.Name, clientName);

            var principal = new ClaimsPrincipal(new ClaimsIdentity(new List <Claim>
            {
                apiKeyClaim,
                nameClaim
            }, ApiKeyConstants.AuthenticationType));

            return(principal);
        }