예제 #1
0
        public AutomaticValueResult GetAutomaticValueForClaim(ClaimKey claim, TokenBuilderContext context)
        {
            Ensure.That(claim).IsNotNull();
            Ensure.That(context).IsNotNull();

            if (claim == ClaimKey.Expires)
            {
                if (context.Configuration?.GetRefreshTokenLength() != null)
                {
                    var expiry = context.ReferenceTime
                                 .Add(context.Configuration.GetRefreshTokenLength().Value)
                                 .ToUnixTimestamp();

                    return(AutomaticValueResult.CreateSuccess(claim, expiry));
                }
                else
                {
                    return(AutomaticValueResult.CreateFail(claim,
                                                           "Refresh token length value not found in configuration."));
                }
            }
            else
            {
                return(AutomaticValueResult.CreateFail(claim,
                                                       $"{claim} can not be automatically derived."));
            }
        }
예제 #2
0
        public ITokenBuilder WithClaim <T>(ClaimKey claimKey, T value)
        {
            this.throwOnDuplicateClaim(claimKey);

            this.payload[claimKey] = value;

            return(this);
        }
예제 #3
0
        public ITokenBuilder WithClaim(ClaimKey claimKey)
        {
            this.throwOnDuplicateClaim(claimKey);

            this.automaticClaims.Add(claimKey);

            return(this);
        }