@@ -51,33 +51,31 @@ public int getOrder() {
5151
5252 @ Override
5353 public void processing (String serviceName , String operationPath , RoutingContext context ) throws InvocationException {
54- if (isNotRequiredVerificationUserServiceMethod (serviceName , operationPath )) {
55- return ;
56- }
57-
58- String token = context . request (). headers (). get ( AUTHORIZATION );
59- if (StringUtils .isNotEmpty (token )) {
60- String userName = template
61- . getForObject ( "cse://" + USER_SERVICE_NAME + "/validate?token={token}" , String . class , token );
62- if ( StringUtils . isNotEmpty ( userName )) {
63- //Add header
64- context . request (). headers (). add ( EDGE_AUTHENTICATION_NAME , userName );
54+ if (isInvocationNeedValidate (serviceName , operationPath )) {
55+ String token = context . request (). headers (). get ( AUTHORIZATION ) ;
56+ if ( StringUtils . isNotEmpty ( token )) {
57+ String userName = template
58+ . getForObject ( "cse://" + USER_SERVICE_NAME + "/validate?token={token}" , String . class , token );
59+ if (StringUtils .isNotEmpty (userName )) {
60+ //Add header
61+ context . request (). headers (). add ( EDGE_AUTHENTICATION_NAME , userName );
62+ } else {
63+ throw new InvocationException ( Status . UNAUTHORIZED , "authentication failed, invalid token" );
64+ }
6565 } else {
66- throw new InvocationException (Status .UNAUTHORIZED , "authentication failed, invalid token " );
66+ throw new InvocationException (Status .UNAUTHORIZED , "authentication failed, missing AUTHORIZATION header " );
6767 }
68- } else {
69- throw new InvocationException (Status .UNAUTHORIZED , "authentication failed, missing AUTHORIZATION header" );
7068 }
7169 }
7270
73- private boolean isNotRequiredVerificationUserServiceMethod (String serviceName , String operationPath ) {
71+ private boolean isInvocationNeedValidate (String serviceName , String operationPath ) {
7472 if (USER_SERVICE_NAME .equals (serviceName )) {
7573 for (String method : NOT_REQUIRED_VERIFICATION_USER_SERVICE_METHODS ) {
7674 if (operationPath .startsWith (method )) {
77- return true ;
75+ return false ;
7876 }
7977 }
8078 }
81- return false ;
79+ return true ;
8280 }
8381}
0 commit comments