public static void UseCors(this IAppBuilder app, ICorsPolicyService corsPolicyService)
 {
     app.UseCors(new Microsoft.Owin.Cors.CorsOptions
     {
         PolicyProvider = new CorsPolicyProvider(corsPolicyService, Constants.RoutePaths.CorsPaths)
     });
 }
Пример #2
0
        public void CorsPolicy()
        {
            IClientStore store = Fixture.GetService <IClientStore>();

            Client client = CreateClient();

            client.AllowedCorsOrigins = new List <string>()
            {
                "aaa", "bbb"
            };

            Client result = store.FindClientByIdAsync(client.ClientId).Result;

            Assert.Null(result);

            Provider.AddClientAsync(client).Wait();

            result = store.FindClientByIdAsync(client.ClientId).Result;
            Assert.NotNull(result);

            ICorsPolicyService cors = Fixture.GetService <ICorsPolicyService>();

            Assert.False(cors.IsOriginAllowedAsync("ccc").Result);
            Assert.True(cors.IsOriginAllowedAsync("aaa").Result);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="CachingResourceStore{T}"/> class.
 /// </summary>
 /// <param name="options">The options.</param>
 /// <param name="inner">The inner.</param>
 /// <param name="corsCache">The CORS origin cache.</param>
 public CachingCorsPolicyService(IdentityServerOptions options,
                                 T inner,
                                 ICache <CorsCacheEntry> corsCache)
 {
     Options   = options;
     Inner     = inner;
     CorsCache = corsCache;
 }
        public CorsPolicyProvider(ICorsPolicyService corsPolicyService, IEnumerable<string> allowedPaths)
        {
            if (allowedPaths == null) throw new ArgumentNullException("allowedPaths");
            if (corsPolicyService == null) throw new ArgumentNullException("corsPolicyService");

            this.paths = allowedPaths.Select(Normalize).ToArray();
            this.corsPolicyService = corsPolicyService;
        }
Пример #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CachingResourceStore{T}"/> class.
 /// </summary>
 /// <param name="options">The options.</param>
 /// <param name="inner">The inner.</param>
 /// <param name="corsCache">The CORS origin cache.</param>
 /// <param name="logger">The logger.</param>
 public CachingCorsPolicyService(IdentityServerOptions options,
                                 T inner,
                                 ICache <CorsCacheEntry> corsCache,
                                 ILogger <CachingCorsPolicyService <T> > logger)
 {
     Options   = options;
     Inner     = inner;
     CorsCache = corsCache;
     Logger    = logger;
 }
Пример #6
0
        public PolicyProvider(
            ILogger<PolicyProvider> logger,
            IEnumerable<string> allowedPaths, 
            ICorsPolicyService corsPolicyService)
        {
            if (allowedPaths == null) throw new ArgumentNullException("allowedPaths");

            _logger = logger;
            _allowedPaths = allowedPaths.Select(Normalize).ToArray();
            _corsPolicyService = corsPolicyService;
        }
 public CorsPolicyProvider(
     ILogger <CorsPolicyProvider> logger,
     Decorator <ICorsPolicyProvider> inner,
     IdentityServerOptions options,
     ICorsPolicyService corsPolicyService)
 {
     _logger            = logger;
     _inner             = inner.Instance;
     _options           = options;
     _corsPolicyService = corsPolicyService;
 }
Пример #8
0
        public PolicyProvider(
            ILogger <PolicyProvider> logger,
            IEnumerable <string> allowedPaths,
            ICorsPolicyService corsPolicyService)
        {
            if (allowedPaths == null)
            {
                throw new ArgumentNullException("allowedPaths");
            }

            _logger            = logger;
            _allowedPaths      = allowedPaths.Select(Normalize).ToArray();
            _corsPolicyService = corsPolicyService;
        }
Пример #9
0
 public CorsPolicyService_Tests()
 {
     _corsPolicyService = GetRequiredService <ICorsPolicyService>();
     _clientRepository  = GetRequiredService <IClientRepository>();
     _unitOfWorkManager = GetRequiredService <IUnitOfWorkManager>();
 }
        public TestCorsPolicyProvider(ICorsPolicyService corsPolicyService, IEnumerable<string> paths)
            : base(corsPolicyService, paths)
        {

        }
Пример #11
0
 public AbpWildcardSubdomainCorsPolicyService_Tests()
 {
     _corsPolicyService = GetRequiredService <ICorsPolicyService>();
 }
 public FabricCorsPolicyProvider(ICorsPolicyService corsPolicyService, ILogger logger)
 {
     _corsPolicyService = corsPolicyService ?? throw new ArgumentNullException(nameof(corsPolicyService));
     _logger            = logger ?? throw new ArgumentNullException(nameof(logger));
 }
Пример #13
0
 public CorsPolicyService_Tests()
 {
     _corsPolicyService = GetRequiredService <ICorsPolicyService>();
     _clientRepository  = GetRequiredService <IClientRepository>();
 }