@@ -228,12 +228,14 @@ static ngx_int_t ngx_oauth2_post_config(ngx_conf_t *cf)
228228
229229static ngx_int_t ngx_oauth2_handler (ngx_http_request_t * r )
230230{
231+ bool rc = false;
231232 ngx_int_t rv = NGX_DECLINED ;
232233 oauth2_nginx_request_context_t * ctx = NULL ;
233234 ngx_oauth2_cfg_t * cfg = NULL ;
234235 ngx_str_t ngx_source_token ;
235236 char * source_token = NULL ;
236237 json_t * json_payload = NULL ;
238+ oauth2_http_status_code_t status_code = 0 ;
237239
238240 if (r != r -> main )
239241 // do not goto end because ctx->log is not available
@@ -286,9 +288,11 @@ static ngx_int_t ngx_oauth2_handler(ngx_http_request_t *r)
286288 oauth2_debug (ctx -> log , "enter: source_token=%s, initial_request=%d" ,
287289 source_token , (r != r -> main ));
288290
289- if (oauth2_token_verify (ctx -> log , ctx -> request , cfg -> verify ,
290- source_token , & json_payload ) == false) {
291- oauth2_warn (ctx -> log , "Token could not be verified." );
291+ rc = oauth2_token_verify (ctx -> log , ctx -> request , cfg -> verify ,
292+ source_token , & json_payload , & status_code );
293+
294+ if (rc == false) {
295+ oauth2_warn (ctx -> log , "Token could not be verified [HTTP status code=%d]." , (int )status_code );
292296 rv = NGX_HTTP_UNAUTHORIZED ;
293297 goto end ;
294298 }
0 commit comments