public static void UseCors(this IAppBuilder app, ICorsPolicyService corsPolicyService) { app.UseCors(new Microsoft.Owin.Cors.CorsOptions { PolicyProvider = new CorsPolicyProvider(corsPolicyService, Constants.RoutePaths.CorsPaths) }); }
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; }
/// <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; }
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; }
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 CorsPolicyService_Tests() { _corsPolicyService = GetRequiredService <ICorsPolicyService>(); _clientRepository = GetRequiredService <IClientRepository>(); _unitOfWorkManager = GetRequiredService <IUnitOfWorkManager>(); }
public TestCorsPolicyProvider(ICorsPolicyService corsPolicyService, IEnumerable<string> paths) : base(corsPolicyService, paths) { }
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)); }
public CorsPolicyService_Tests() { _corsPolicyService = GetRequiredService <ICorsPolicyService>(); _clientRepository = GetRequiredService <IClientRepository>(); }