Skip to content

MapSpaYarp prevents usage of AllowAnonymous #32

@bve-wd

Description

@bve-wd

We are using Authentication and Authorization in our application and enabled them by default if no authorize attribute is used.
In such scenarios, MapSpaProxy hides the access to the route configuration.

I created PR #31 which removes the optional policyName attribute and adds IEndpointConventionBuilder as return value instead.
This allows to decide how to handle route conventions similar to when controllers or static files are mapped.

app = builder.Build();
...
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
...
app.UseSpaYarpMiddleware();
// allow anonymous access to fallback routes (index.html and angular dev-server assets)
app.MapSpaYarp().AllowAnonymous();

// alternative usage:
app.MapSpaYarp().RequireAuthorization(); // requires the default policy
app.MapSpaYarp().RequireAuthorization("SpaYarpPolicyName"); // requires a custom policy
// mixed setup with authorized and public SPA proxy paths
app.MapSpaYarp("EndpointPath1","https://localhost:7890").RequireAuthorization();
app.MapSpaYarp("EndpointPath2","https://localhost:7880").AllowAnonymous();

As quickfix, I added a custom implementation of the MapSpaYarp method in our project but it would be nice if you can merge it and create a new nuget package version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions