示例#1
0
        private static AuthenticationBuilder AddCodeFlow(AuthenticationBuilder builder, OktaMvcOptions options)
        {
            var events = new OpenIdConnectEvents
            {
                OnRedirectToIdentityProvider = BeforeRedirectToIdentityProviderAsync,
            };

            JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();

            builder.AddOpenIdConnect(oidcOptions => OpenIdConnectOptionsHelper.ConfigureOpenIdConnectOptions(options, events, oidcOptions));

            return(builder);
        }
示例#2
0
        private static AuthenticationBuilder AddCodeFlow(AuthenticationBuilder builder, OktaMvcOptions options)
        {
            var events = new OpenIdConnectEvents
            {
                OnRedirectToIdentityProvider = BeforeRedirectToIdentityProviderAsync,
            };

            if (options.AuthenticationTicketExpiryInMinutes.HasValue)
            {
                events.OnTicketReceived = async(context) =>
                {
                    context.Properties.ExpiresUtc = DateTime.UtcNow.AddMinutes(options.AuthenticationTicketExpiryInMinutes.Value);
                };
            }

            JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();

            builder.AddOpenIdConnect(oidcOptions => OpenIdConnectOptionsHelper.ConfigureOpenIdConnectOptions(options, events, oidcOptions));

            return(builder);
        }