Skip to content

Commit

Permalink
fix: ClaimStrategy validation bypass type principle changed to princi…
Browse files Browse the repository at this point in the history
…pal (#493)

* fix: ClaimStrategy validation bypass type principle changed to principal

* chore: docs fix
  • Loading branch information
AndrewTriesToCode authored Nov 16, 2021
1 parent 65507bf commit fbfd022
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
5 changes: 2 additions & 3 deletions docs/ConfigurationAndUsage.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,11 @@ public void Configure(IApplicationBuilder app)
{
app.UseRouting(); // In ASP.NET Core 3.1 this should be before UseMultiTenant!
...
app.UseMultiTenant(); // Before UseAuthentication and UseMvc!
app.UseMultiTenant(); // Before UseAuthentication and UseEndpoints
...
app.UseAuthentication();
...
//app.UseMvc(); // for .NET Core 3.1
app.UseEndpoints(...); // for .NET 5.0+
app.UseEndpoints(...);
}
```

Expand Down
5 changes: 2 additions & 3 deletions docs/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ Finally, in the `Configure` method call `UseMultiTenant()` to register the middl
public void Configure(IApplicationBuilder app)
{
...
app.UseMultiTenant(); // Before UseMvc!
app.UseMultiTenant(); // Before UseEndponts
...
//app.UseMvc(); // for .NET Core 3.1
app.UseEndpoints(...); // for .NET 5.0+
app.UseEndpoints(...);
}
```

Expand Down
7 changes: 7 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"sdk": {
"version": "6.0.0",
"rollForward": "latestMajor",
"allowPrerelease": false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ public async Task<string> GetIdentifierAsync(object context)

var handler = (IAuthenticationHandler)ActivatorUtilities.CreateInstance(httpContext.RequestServices, authScheme.HandlerType);
await handler.InitializeAsync(authScheme, httpContext);
httpContext.Items[$"{Constants.TenantToken}__bypass_validate_principle__"] = "true"; // Value doesn't matter.
httpContext.Items[$"{Constants.TenantToken}__bypass_validate_principal__"] = "true"; // Value doesn't matter.
var handlerResult = await handler.AuthenticateAsync();
httpContext.Items.Remove($"{Constants.TenantToken}__bypass_validate_principle__");
httpContext.Items.Remove($"{Constants.TenantToken}__bypass_validate_principal__");

var identifier = handlerResult.Principal?.FindFirst(_tenantKey)?.Value;
return await Task.FromResult(identifier);
Expand Down

0 comments on commit fbfd022

Please sign in to comment.