Skip to content

Allow a more flexible AllowOrigin response #2379

Closed
@aspnet-hello

Description

@aspnet-hello

From @mharthoorn on Wednesday, October 5, 2016 12:43:56 PM

Instead of the CorsService peeking into the CorsPolicy

   policy.Origins.Contains(origin)

A method OriginAllowed(string origin) would allow for a much more flexible lookup policy. The service would then call:

  policy.OriginAllowed(origin)

This allows the policy to respond with a more ad hoc response like a (database) lookup.
The default would simply be:

        public virtual bool OriginAllowed(string origin)
        {
            return this.Origins.Contains(origin);
        }

But an override policy could become something like:

        public override bool OriginAllowed(string origin)
        {
            return repository.Exists<Sites>(s => s.Origin == origin);
        }

Copied from original issue: aspnet/CORS#89

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templates

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions