public void Enrich(HandlerContext context)
        {
            var dic = new JObject
            {
                { UserClaims.Subject, context.User.Id }
            };

            if (context.Request.AuthDateTime != null)
            {
                dic.Add(OAuthClaims.AuthenticationTime, context.Request.AuthDateTime.Value.ConvertToUnixTimestamp());
            }

            foreach (var record in context.Request.Data)
            {
                dic.Add(record.Key, record.Value);
            }

            var authCode = _grantedTokenHelper.BuildAuthorizationCode(dic);

            context.Response.Add(AuthorizationResponseParameters.Code, authCode);
            var isScopeCOntainsOfflineAccess = context.Request.Data.GetScopesFromAuthorizationRequest().Contains(SIDOpenIdConstants.StandardScopes.OfflineAccessScope.Name);

            if (isScopeCOntainsOfflineAccess)
            {
                _tokenBuilders.First(t => t.Name == TokenResponseParameters.RefreshToken).Build(context.Request.Data.GetScopesFromAuthorizationRequest(), context, dic);
            }
        }
Ejemplo n.º 2
0
        public void Enrich(HandlerContext context)
        {
            var dic = new JObject();

            foreach (var record in context.Request.Data)
            {
                dic.Add(record.Key, record.Value);
            }

            CheckPKCEParameters(context);
            var authCode = _grantedTokenHelper.BuildAuthorizationCode(dic);

            context.Response.Add(AuthorizationResponseParameters.Code, authCode);
        }