Exemple #1
0
        public static void AddSwagger(
            this IServiceCollection services,
            string xmlCommentsFilePath,
            ApiResource apiResource,
            AuthorityOptions authority,
            params Scope[] scopes
            )
        {
            services.AddSwagger(
                authority.ExternalUrl,
                apiResource.Name,
                apiResource.DisplayName,
                apiResource.Description,
                xmlCommentsFilePath,
                options =>
            {
                options.MapType <DecimalValue>(
                    () => new OpenApiSchema
                {
                    Type = "number"
                });

                options.MapType <Timestamp>(
                    () => new OpenApiSchema
                {
                    Type = "integer"
                });

                options.EnableAnnotations(true);

                options.DescribeAllEnumerationsAsStrings();

                options.OperationFilter <SecurityRequirementsOperationFilter>(
                    new SwaggerOperationOptions(
                        Scopes.IdentityApi,
                        Scopes.PaymentApi,
                        Scopes.CashierApi,
                        Scopes.NotificationsApi,
                        Scopes.ChallengesApi,
                        Scopes.GamesApi,
                        Scopes.ClansApi,
                        Scopes.ChallengesWebAggregator,
                        Scopes.CashierWebAggregator));

                //options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
                //{
                //    Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"",
                //    Name = "Authorization",
                //    In = ParameterLocation.Header,
                //    Type = SecuritySchemeType.ApiKey
                //});
            },
                scopes);
        }
        public static AuthorityOptions AddMemoryAuthStore(this AuthorityOptions authority, Action <MemoryAuthStoreOptions> config = null)
        {
            if (authority == null)
            {
                throw new ArgumentNullException(nameof(authority));
            }

            var options = new MemoryAuthStoreOptions();

            config?.Invoke(options);
            return(AddMemoryAuthStore(authority, options));
        }
        public static IServiceCollection AddReyAuthority(this IServiceCollection services, Action <AuthorityOptions> config = null)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            var options = new AuthorityOptions(services);

            config?.Invoke(options);
            return(AddReyAuthority(services, options));
        }
        public static AuthorityOptions AddMemoryAuthStore(this AuthorityOptions authority, MemoryAuthStoreOptions options)
        {
            if (authority == null)
            {
                throw new ArgumentNullException(nameof(authority));
            }

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

            authority.Services.AddSingleton(options);
            authority.Services.AddSingleton <IAuthStore, MemoryAuthStore>();
            return(authority);
        }
        public static IServiceCollection AddReyAuthority(this IServiceCollection services, AuthorityOptions options)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

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

            services.AddSingleton(options);
            return(services);
        }
 public static IHealthChecksBuilder AddCustomIdentityServer(this IHealthChecksBuilder builder, AuthorityOptions authority)
 {
     return(builder.AddIdentityServer(new Uri(authority.InternalUrl)));
 }