File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed
Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -58,7 +58,17 @@ function _M.validate(user_params)
5858 if jwks_item == nil then
5959 goto continue
6060 end
61- jwks_c .jwt_checker_setkey (checker , jwks_c .JWT_ALG_RS256 , jwks_item );
61+ local alg = jwks_c .jwks_item_alg (jwks_item );
62+
63+ if alg == jwks_c .JWT_ALG_NONE then
64+ return nil , _M .response_error (" No algorithm found on jwks" , params .return_unauthorized_default )
65+ end
66+
67+ if alg == jwks_c .JWT_ALG_INVAL then
68+ return nil , _M .response_error (" invalid algorithm found on jwks" , params .return_unauthorized_default )
69+ end
70+
71+ jwks_c .jwt_checker_setkey (checker , alg , jwks_item );
6272 local result = jwks_c .jwt_checker_verify (checker , token );
6373 if result == TOKEN_VALID then
6474 return parsed_token , " "
Original file line number Diff line number Diff line change @@ -25,18 +25,14 @@ typedef enum {
2525 JWT_ALG_INVAL , /* *< An invalid algorithm from the caller or the token */
2626} jwt_alg_t ;
2727
28-
29- struct jwk_item {
30- jwt_alg_t alg ;
31- };
32-
3328typedef struct jwk_item jwk_item_t ;
3429
3530int jwt_checker_setkey (jwt_checker_t * checker , const jwt_alg_t alg , const jwk_item_t * key );
3631typedef struct jwk_set jwk_set_t ;
3732jwk_set_t *jwks_create (const char * jwk_json_str );
3833const jwk_item_t *jwks_item_get (const jwk_set_t * jwk_set , size_t index );
3934jwk_item_t *jwks_find_bykid (jwk_set_t * jwk_set , const char * kid );
35+ jwt_alg_t jwks_item_alg (const jwk_item_t * item );
4036]]
4137
4238local libjwt = ffi .load (" libjwt" );
You can’t perform that action at this time.
0 commit comments