@@ -131,6 +131,7 @@ static ngx_int_t ngx_http_auth_jwt_handler(ngx_http_request_t *r)
131
131
time_t exp ;
132
132
time_t now ;
133
133
ngx_str_t auth_jwt_algorithm ;
134
+ int keylen ;
134
135
135
136
jwtcf = ngx_http_get_module_loc_conf (r , ngx_http_auth_jwt_module );
136
137
@@ -151,8 +152,9 @@ static ngx_int_t ngx_http_auth_jwt_handler(ngx_http_request_t *r)
151
152
auth_jwt_algorithm = jwtcf -> auth_jwt_algorithm ;
152
153
if (auth_jwt_algorithm .len == 0 || (auth_jwt_algorithm .len == sizeof ("HS256" ) - 1 && ngx_strncmp (auth_jwt_algorithm .data , "HS256" , sizeof ("HS256" ) - 1 )== 0 ))
153
154
{
154
- ngx_log_debug (NGX_LOG_DEBUG , r -> connection -> log , 0 , "got to 0" );
155
- keyBinary = ngx_palloc (r -> pool , jwtcf -> auth_jwt_key .len / 2 );
155
+ ngx_log_error (NGX_LOG_DEBUG , r -> connection -> log , 0 , "got to 0" );
156
+ keylen = jwtcf -> auth_jwt_key .len / 2 ;
157
+ keyBinary = ngx_palloc (r -> pool , keylen );
156
158
if (0 != hex_to_binary ((char * )jwtcf -> auth_jwt_key .data , keyBinary , jwtcf -> auth_jwt_key .len ))
157
159
{
158
160
ngx_log_error (NGX_LOG_ERR , r -> connection -> log , 0 , "failed to turn hex key into binary" );
@@ -162,15 +164,16 @@ static ngx_int_t ngx_http_auth_jwt_handler(ngx_http_request_t *r)
162
164
else if ( auth_jwt_algorithm .len == sizeof ("RS256" ) - 1 && ngx_strncmp (auth_jwt_algorithm .data , "RS256" , sizeof ("RS256" ) - 1 ) == 0 )
163
165
{
164
166
// in this case, 'Binary' is a misnomer, as it is the private key string itself
165
- ngx_log_debug (NGX_LOG_DEBUG , r -> connection -> log , 0 , "got to 1" );
167
+ ngx_log_error (NGX_LOG_DEBUG , r -> connection -> log , 0 , "got to 1" );
166
168
keyBinary = ngx_palloc (r -> pool , jwtcf -> auth_jwt_key .len );
167
169
ngx_memcpy (keyBinary , jwtcf -> auth_jwt_key .data , jwtcf -> auth_jwt_key .len );
168
-
170
+ keylen = jwtcf -> auth_jwt_key . len ;
169
171
}
170
172
171
173
// validate the jwt
172
- ngx_log_debug (NGX_LOG_DEBUG , r -> connection -> log , 0 , "trying to decode JWT" );
173
- jwtParseReturnCode = jwt_decode (& jwt , jwtCookieValChrPtr , keyBinary , jwtcf -> auth_jwt_key .len / 2 );
174
+ ngx_log_error (NGX_LOG_DEBUG , r -> connection -> log , 0 , "trying to decode JWT" );
175
+ jwtParseReturnCode = jwt_decode (& jwt , jwtCookieValChrPtr , keyBinary , keylen );
176
+
174
177
if (jwtParseReturnCode != 0 )
175
178
{
176
179
ngx_log_error (NGX_LOG_ERR , r -> connection -> log , 0 , "failed to parse jwt" );
0 commit comments