コード例 #1
0
 public object ExecuteTokenOperation(OAuth2Client client, ITokenService tokenService, string optionalCode)
 {
     throw new NotImplementedException();
 }
コード例 #2
0
 public Dictionary <string, string> ExecuteAuthorizeOperation(ClaimsPrincipal user, OAuth2Client client, ITokenService tokenService)
 {
     throw new NotImplementedException();
 }
コード例 #3
0
        /// <summary>
        /// We need to generate a token in this flow so just issue the JWT token for the given user
        /// </summary>
        /// <returns>The authorize operation.</returns>
        /// <param name="user">User.</param>
        /// <param name="client">Client.</param>
        /// <param name="tokenService">TokenService.</param>
        public Dictionary <string, string> ExecuteAuthorizeOperation(ClaimsPrincipal user, OAuth2Client client, ITokenService tokenService)
        {
            // give the custom implementation a chance to adapt the claims
            var claims = tokenService.GetTokenClaims(user);

            // issue the token
            var issuedToken = TokenIssueService.IssueToken(claims, tokenService.GetTokenIssuer(), tokenService.GetTokenIssuer(), 24 * 60 * 60, client.ClientSecret);

            // generate the result
            var result = new Dictionary <string, string>();

            result.Add("token_type", issuedToken.TokenType);
            result.Add("access_token", issuedToken.TokenValue);
            result.Add("expires_in", Convert.ToInt64((issuedToken.Expires - DateTime.UtcNow).TotalSeconds).ToString());

            // done
            return(result);
        }
コード例 #4
0
        public Dictionary <string, string> ExecuteAuthorizeOperation(ClaimsPrincipal user, OAuth2Client client, ITokenService tokenService)
        {
            // generate a code
            var code = Guid.NewGuid().ToString().Replace("-", "");

            // ask the token service to store this code in combination with this user and client request
            tokenService.StoreCode(user, code);

            // handout the code
            var result = new Dictionary <string, string>();

            result.Add("code", code);
            return(result);
        }