fix AllowAnonymous
This commit is contained in:
parent
3bb4c88929
commit
af712c7ea8
@ -29,11 +29,11 @@ namespace ASC.Web.Api.Handlers
|
||||
var token = Context.Request.Cookies["asc_auth_key"] ?? Context.Request.Headers["Authorization"];
|
||||
var result = SecurityContext.AuthenticateMe(token);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
throw new AuthenticationException(HttpStatusCode.Unauthorized.ToString());
|
||||
}
|
||||
return Task.FromResult(AuthenticateResult.Success(new AuthenticationTicket(Context.User, new AuthenticationProperties(), Scheme.Name)));
|
||||
return Task.FromResult(
|
||||
result ?
|
||||
AuthenticateResult.Success(new AuthenticationTicket(Context.User, new AuthenticationProperties(), Scheme.Name)) :
|
||||
AuthenticateResult.Fail(new AuthenticationException(HttpStatusCode.Unauthorized.ToString()))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,11 @@ namespace ASC.Api.Core.Middleware
|
||||
try
|
||||
{
|
||||
await next(context);
|
||||
|
||||
if(context.Response.StatusCode == 401)
|
||||
{
|
||||
error = new AuthenticationException(HttpStatusCode.Unauthorized.ToString());
|
||||
}
|
||||
}
|
||||
catch(AuthenticationException exception)
|
||||
{
|
||||
|
@ -72,10 +72,10 @@ namespace ASC.Web.Api
|
||||
|
||||
app.UseRouting();
|
||||
|
||||
app.UseResponseWrapper();
|
||||
|
||||
app.UseAuthentication();
|
||||
|
||||
app.UseResponseWrapper();
|
||||
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
endpoints.MapControllers();
|
||||
|
Loading…
Reference in New Issue
Block a user