Inheritance: Microsoft.AspNetCore.Builder.AuthenticationOptions
        private static Action<IApplicationBuilder> ApiAuthentication(IConfiguration configuration)
        {
            var options = new OAuthValidationOptions
            {
                AutomaticAuthenticate = true,
                AutomaticChallenge = true
            };

            options.Audiences.Add(configuration.ApiHostName());

            return branch => branch.UseOAuthValidation(options);
        }
Example #2
0
        /// <summary>
        /// Adds a new instance of the OAuth2 validation middleware in the ASP.NET 5 pipeline.
        /// </summary>
        /// <param name="app">The application builder.</param>
        /// <param name="options">The options used to configure the validation middleware.</param>
        /// <returns>The application builder.</returns>
        public static IApplicationBuilder UseOAuthValidation(
            this IApplicationBuilder app,
            OAuthValidationOptions options)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }

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

            return(app.UseMiddleware <OAuthValidationMiddleware>(options));
        }
        /// <summary>
        /// Adds a new instance of the OAuth2 validation middleware in the ASP.NET 5 pipeline.
        /// </summary>
        /// <param name="app">The application builder.</param>
        /// <param name="configuration">The delegate used to configure the validation options.</param>
        /// <returns>The application builder.</returns>
        public static IApplicationBuilder UseOAuthValidation(
            [NotNull] this IApplicationBuilder app,
            [NotNull] Action<OAuthValidationOptions> configuration) {
            if (app == null) {
                throw new ArgumentNullException(nameof(app));
            }

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

            var options = new OAuthValidationOptions();
            configuration(options);

            return app.UseOAuthValidation(options);
        }
Example #4
0
        /// <summary>
        /// Adds a new instance of the OAuth2 validation middleware in the ASP.NET 5 pipeline.
        /// </summary>
        /// <param name="app">The application builder.</param>
        /// <param name="configuration">The delegate used to configure the validation options.</param>
        /// <returns>The application builder.</returns>
        public static IApplicationBuilder UseOAuthValidation(
            this IApplicationBuilder app,
            Action <OAuthValidationOptions> configuration)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }

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

            var options = new OAuthValidationOptions();

            configuration(options);

            return(app.UseOAuthValidation(options));
        }