Ejemplo n.º 1
0
        /// <inheritdoc />
        public Task <ISecurityTokenService> CreateSecurityTokenService(SecurityTokensElement configuration)
        {
            var signingKey         = (HexEncodedSecurityKey)configuration.GetString("signingKey");
            var fallbackSigningKey = (HexEncodedSecurityKey)configuration.GetString("fallbackSigningKey");
            var defaultTtl         = configuration.GetTimeSpan("defaultTtl").GetValueOrDefault();
            var options            = new JwtSecurityTokenServiceOptions
            {
                SigningKey         = signingKey,
                FallbackSigningKey = fallbackSigningKey,
                DefaultTTL         = defaultTtl
            };
            var securityTokenService = new JwtSecurityTokenService(options);

            return(Task.FromResult <ISecurityTokenService>(securityTokenService));
        }
Ejemplo n.º 2
0
        /// <inheritdoc />
        public Task <ISecurityTokenService> CreateSecurityTokenService(IConfiguration configuration)
        {
            var signingKey         = (HexEncodedSecurityKey)configuration?["signingKey"];
            var fallbackSigningKey = (HexEncodedSecurityKey)configuration?["fallbackSigningKey"];

            var options = new JwtSecurityTokenServiceOptions
            {
                SigningKey         = signingKey,
                FallbackSigningKey = fallbackSigningKey
            };

            var defaultTtl = configuration?.GetValue <TimeSpan>("defaultTtl");

            if (defaultTtl > TimeSpan.Zero)
            {
                options.DefaultTTL = defaultTtl.Value;
            }

            var securityTokenService = new JwtSecurityTokenService(options);

            return(Task.FromResult <ISecurityTokenService>(securityTokenService));
        }