/// <summary>
 /// Initializes base class used for certain event contexts
 /// </summary>
 protected BaseValidatingClientContext(
     HttpContext context,
     OpenIdConnectServerOptions options,
     OpenIdConnectMessage request)
     : base(context, options) {
     Request = request;
 }
 /// <summary>
 /// Creates an instance of this context.
 /// </summary>
 internal CryptographyEndpointResponseContext(
     HttpContext context,
     OpenIdConnectServerOptions options,
     JObject payload)
     : base(context) {
     Options = options;
     Payload = payload;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ValidateAuthorizationRequestContext"/> class
 /// </summary>
 /// <param name="context"></param>
 /// <param name="options"></param>
 /// <param name="request"></param>
 internal ValidateAuthorizationRequestContext(
     HttpContext context,
     OpenIdConnectServerOptions options,
     OpenIdConnectMessage request)
     : base(context, options) {
     Request = request;
     Validated();
 }
 /// <summary>
 /// Creates an instance of this context
 /// </summary>
 internal LogoutEndpointContext(
     HttpContext context,
     OpenIdConnectServerOptions options,
     OpenIdConnectMessage request)
     : base(context) {
     Options = options;
     Request = request;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TokenEndpointContext"/> class
 /// </summary>
 /// <param name="context"></param>
 /// <param name="options"></param>
 /// <param name="request"></param>
 /// <param name="ticket"></param>
 internal TokenEndpointContext(
     HttpContext context,
     OpenIdConnectServerOptions options,
     OpenIdConnectMessage request,
     AuthenticationTicket ticket)
     : base(context) {
     Options = options;
     Request = request;
     Ticket = ticket;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DeserializeIdentityTokenContext"/> class
 /// </summary>
 /// <param name="context"></param>
 /// <param name="options"></param>
 /// <param name="request"></param>
 /// <param name="token"></param>
 internal DeserializeIdentityTokenContext(
     HttpContext context,
     OpenIdConnectServerOptions options,
     OpenIdConnectMessage request,
     string token)
     : base(context) {
     Options = options;
     Request = request;
     IdentityToken = token;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ProfileEndpointResponseContext"/> class
 /// </summary>
 /// <param name="context"></param>
 /// <param name="options"></param>
 /// <param name="request"></param>
 /// <param name="payload"></param>
 internal ProfileEndpointResponseContext(
     HttpContext context,
     OpenIdConnectServerOptions options,
     OpenIdConnectMessage request,
     JObject payload)
     : base(context) {
     Options = options;
     Request = request;
     Payload = payload;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DeserializeAuthorizationCodeContext"/> class
 /// </summary>
 /// <param name="context"></param>
 /// <param name="options"></param>
 /// <param name="request"></param>
 /// <param name="code"></param>
 internal DeserializeAuthorizationCodeContext(
     HttpContext context,
     OpenIdConnectServerOptions options,
     OpenIdConnectMessage request,
     string code)
     : base(context) {
     Options = options;
     Request = request;
     AuthorizationCode = code;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TokenEndpointResponseContext"/> class
 /// </summary>
 /// <param name="context"></param>
 /// <param name="options"></param>
 /// <param name="ticket"></param>
 /// <param name="request"></param>
 /// <param name="payload"></param>
 internal TokenEndpointResponseContext(
     HttpContext context,
     OpenIdConnectServerOptions options,
     AuthenticationTicket ticket,
     OpenIdConnectMessage request,
     JObject payload)
     : base(context) {
     Options = options;
     AuthenticationTicket = ticket;
     Request = request;
     Payload = payload;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SerializeAccessTokenContext"/> class
 /// </summary>
 /// <param name="context"></param>
 /// <param name="options"></param>
 /// <param name="request"></param>
 /// <param name="response"></param>
 /// <param name="ticket"></param>
 internal SerializeAccessTokenContext(
     HttpContext context,
     OpenIdConnectServerOptions options,
     OpenIdConnectMessage request,
     OpenIdConnectMessage response,
     AuthenticationTicket ticket)
     : base(context) {
     Options = options;
     Request = request;
     Response = response;
     AuthenticationTicket = ticket;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AuthorizationEndpointResponseContext"/> class
 /// </summary>
 /// <param name="context"></param>
 /// <param name="options"></param>
 /// <param name="ticket"></param>
 /// <param name="request"></param>
 /// <param name="response"></param>
 internal AuthorizationEndpointResponseContext(
     HttpContext context,
     OpenIdConnectServerOptions options,
     AuthenticationTicket ticket,
     OpenIdConnectMessage request,
     OpenIdConnectMessage response)
     : base(context) {
     Options = options;
     AuthenticationTicket = ticket;
     Request = request;
     Response = response;
 }
        /// <summary>
        /// Adds a new OpenID Connect server instance in the ASP.NET pipeline.
        /// </summary>
        /// <param name="app">The web application builder.</param>
        /// <param name="configuration">
        /// A delegate allowing to modify the options
        /// controlling the behavior of the OpenID Connect server.
        /// </param>
        /// <returns>The application builder.</returns>
        public static IApplicationBuilder UseOpenIdConnectServer(
            [NotNull] this IApplicationBuilder app,
            [NotNull] Action<OpenIdConnectServerOptions> configuration) {
            if (app == null) {
                throw new ArgumentNullException(nameof(app));
            }

            if (configuration == null) {
                throw new ArgumentNullException(nameof(configuration));
            }

            var options = new OpenIdConnectServerOptions();

            // By default, enable AllowInsecureHttp in development/testing environments.
            var environment = app.ApplicationServices.GetRequiredService<IHostingEnvironment>();
            options.AllowInsecureHttp = environment.IsDevelopment() || environment.IsEnvironment("Testing");

            configuration(options);
            return app.UseOpenIdConnectServer(options);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="MatchEndpointContext"/> class
 /// </summary>
 /// <param name="context"></param>
 /// <param name="options"></param>
 internal MatchEndpointContext(
     HttpContext context,
     OpenIdConnectServerOptions options)
     : base(context) {
     Options = options;
 }
 /// <summary>
 /// Creates an instance of this context.
 /// </summary>
 internal CryptographyEndpointContext(
     HttpContext context,
     OpenIdConnectServerOptions options)
     : base(context) {
     Options = options;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ValidateClientAuthenticationContext"/> class
 /// </summary>
 /// <param name="context"></param>
 /// <param name="options"></param>
 /// <param name="request"></param>
 internal ValidateClientAuthenticationContext(
     HttpContext context,
     OpenIdConnectServerOptions options,
     OpenIdConnectMessage request)
     : base(context, options, request) {
 }
 /// <summary>
 /// Creates an instance of this context.
 /// </summary>
 internal ConfigurationEndpointContext(
     HttpContext context,
     OpenIdConnectServerOptions options)
     : base(context) {
     Options = options;
 }
        private static void ServerOptions(OpenIdConnectServerOptions options)
        {
            options.Provider = new AuthorizationServerProvider();
            options.AllowInsecureHttp = true;
            options.AuthorizationEndpointPath = "/account/authorize";
            options.TokenEndpointPath = "/token";

            options.AccessTokenLifetime = TimeSpan.FromMinutes(1);
            options.RefreshTokenLifetime = TimeSpan.FromHours(10);
        }
 /// <summary>
 /// Initializes base class used for certain event contexts.
 /// </summary>
 protected BaseValidatingContext(
     HttpContext context,
     OpenIdConnectServerOptions options)
     : base(context) {
     Options = options;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ValidateClientLogoutRedirectUriContext"/> class
 /// </summary>
 /// <param name="context"></param>
 /// <param name="options"></param>
 /// <param name="request"></param>
 internal ValidateClientLogoutRedirectUriContext(
     HttpContext context,
     OpenIdConnectServerOptions options,
     OpenIdConnectMessage request)
     : base(context, options, request) {
 }