Exemple #1
0
        protected JwsPayload BuildPayload(IEnumerable <string> scopes, HandlerContext handlerContext)
        {
            var jwsPayload = _grantedTokenHelper.BuildAccessToken(new[]
            {
                handlerContext.Client.ClientId
            }, scopes, handlerContext.Request.IssuerName, handlerContext.Client.TokenExpirationTimeInSeconds);

            if (handlerContext.Request.Certificate != null)
            {
                var thumbprint = Hash(handlerContext.Request.Certificate.RawData);
                jwsPayload.Add(SimpleIdServer.Jwt.Constants.OAuthClaims.Cnf, new JObject
                {
                    { SimpleIdServer.Jwt.Constants.OAuthClaims.X5TS256, thumbprint }
                });
            }

            return(jwsPayload);
        }
Exemple #2
0
        public async virtual Task Build(IEnumerable <string> scopes, HandlerContext handlerContext, JObject claims = null)
        {
            var jwsPayload = _grantedTokenHelper.BuildAccessToken(new[]
            {
                handlerContext.Client.ClientId
            }, scopes, handlerContext.Request.IssuerName, handlerContext.Client.TokenExpirationTimeInSeconds);

            if (claims != null)
            {
                foreach (var cl in claims)
                {
                    jwsPayload.Add(cl.Key, cl.Value);
                }
            }

            var accessToken = await _jwtBuilder.BuildAccessToken(handlerContext.Client, jwsPayload);

            handlerContext.Response.Add(TokenResponseParameters.AccessToken, accessToken);
        }