@@ -41,39 +41,39 @@ public EndpointAuthorizationMiddleware(RequestDelegate next, IOptions<Authentica
4141 _logger = logger ;
4242 }
4343
44- public async Task InvokeAsync ( HttpContext httpcontext )
44+ public async Task InvokeAsync ( HttpContext httpContext )
4545 {
4646 if ( _options . Value . BypassAuth ( _logger ) )
4747 {
48- await _next ( httpcontext ) . ConfigureAwait ( false ) ;
48+ await _next ( httpContext ) . ConfigureAwait ( false ) ;
4949 return ;
5050 }
5151
52- if ( httpcontext . User is not null
53- && httpcontext . User . Identity is not null
54- && httpcontext . User . Identity . IsAuthenticated )
52+ if ( httpContext . User is not null
53+ && httpContext . User . Identity is not null
54+ && httpContext . User . Identity . IsAuthenticated )
5555 {
56- if ( httpcontext . GetRouteValue ( "controller" ) is string controller )
56+ if ( httpContext . GetRouteValue ( "controller" ) is string controller )
5757 {
58- _logger . UserAccessingController ( httpcontext . User . Identity . Name , controller ) ;
59- var validEndpoints = httpcontext . GetValidEndpoints ( _options . Value . OpenId ! . Claims ! . AdminClaims ! , _options . Value . OpenId ! . Claims ! . UserClaims ! ) ;
58+ _logger . UserAccessingController ( httpContext . User . Identity . Name , controller ) ;
59+ var validEndpoints = httpContext . GetValidEndpoints ( _logger , _options . Value . OpenId ! . Claims ! . AdminClaims ! , _options . Value . OpenId ! . Claims ! . UserClaims ! ) ;
6060 var result = validEndpoints . Any ( e => e . Equals ( controller , StringComparison . InvariantCultureIgnoreCase ) ) || validEndpoints . Contains ( "all" ) ;
6161
6262 if ( result is false )
6363 {
64- _logger . UserAccessDenied ( httpcontext . User . Identity . Name , string . Join ( ',' , validEndpoints ) ) ;
65- httpcontext . Response . StatusCode = ( int ) HttpStatusCode . Forbidden ;
64+ _logger . UserAccessDenied ( httpContext . User . Identity . Name , string . Join ( ',' , validEndpoints ) ) ;
65+ httpContext . Response . StatusCode = ( int ) HttpStatusCode . Forbidden ;
6666
67- await httpcontext . Response . CompleteAsync ( ) . ConfigureAwait ( false ) ;
67+ await httpContext . Response . CompleteAsync ( ) . ConfigureAwait ( false ) ;
6868
6969 return ;
7070 }
7171 }
72- await _next ( httpcontext ) . ConfigureAwait ( false ) ;
72+ await _next ( httpContext ) . ConfigureAwait ( false ) ;
7373 }
7474 else
7575 {
76- httpcontext . Response . StatusCode = ( int ) HttpStatusCode . Unauthorized ;
76+ httpContext . Response . StatusCode = ( int ) HttpStatusCode . Unauthorized ;
7777 }
7878 }
7979 }
0 commit comments