@@ -85,9 +85,11 @@ ngx_module_t ngx_http_auth_jwt_module = {
85
85
86
86
static ngx_int_t ngx_http_auth_jwt_handler (ngx_http_request_t * r )
87
87
{
88
+ static const ngx_str_t jwtCookieName = ngx_string ("rampartjwt" );
89
+ static const ngx_str_t passportKeyCookieName = ngx_string ("PassportKey" );
90
+ static const ngx_str_t authorizationHeaderName = ngx_string ("Authorization" );
91
+ static const int BEARER_LEN = 7 ; // strlen("Bearer ");
88
92
ngx_int_t n ;
89
- ngx_str_t jwtCookieName = ngx_string ("rampartjwt" );
90
- ngx_str_t passportKeyCookieName = ngx_string ("PassportKey" );
91
93
ngx_str_t jwtCookieVal ;
92
94
char * jwtCookieValChrPtr ;
93
95
char * return_url ;
@@ -98,7 +100,7 @@ static ngx_int_t ngx_http_auth_jwt_handler(ngx_http_request_t *r)
98
100
jwt_alg_t alg ;
99
101
time_t exp ;
100
102
time_t now ;
101
- int BEARER_LEN = 7 ; // strlen("Bearer ") ;
103
+ ngx_table_elt_t * authorizationHeader ;
102
104
103
105
jwtcf = ngx_http_get_module_loc_conf (r , ngx_http_auth_jwt_module );
104
106
@@ -167,8 +169,6 @@ static ngx_int_t ngx_http_auth_jwt_handler(ngx_http_request_t *r)
167
169
}
168
170
169
171
// if an Authorization header exists, it must match the cookie
170
- ngx_table_elt_t * authorizationHeader ;
171
- ngx_str_t authorizationHeaderName = ngx_string ("Authorization" );
172
172
authorizationHeader = search_headers_in (r , authorizationHeaderName .data , authorizationHeaderName .len );
173
173
if (authorizationHeader != NULL )
174
174
{
@@ -179,14 +179,12 @@ static ngx_int_t ngx_http_auth_jwt_handler(ngx_http_request_t *r)
179
179
goto redirect ;
180
180
}
181
181
182
+ // compare content
182
183
if (0 != strncmp ((const char * )(authorizationHeader -> value .data + BEARER_LEN ), (const char * )jwtCookieVal .data , jwtCookieVal .len ))
183
184
{
184
185
ngx_log_error (NGX_LOG_ERR , r -> connection -> log , 0 , "Authorization and Cookie do not match content" );
185
186
goto redirect ;
186
187
}
187
-
188
- char * authvalue = ngx_str_t_to_char_ptr (r -> pool , authorizationHeader -> value );
189
- ngx_log_error (NGX_LOG_ERR , r -> connection -> log , 0 , "authorization header %s" , authvalue );
190
188
}
191
189
192
190
return NGX_OK ;
0 commit comments