Skip to content

Commit 2c99890

Browse files
committed
Fix #157 : Update Id token in session after refreshing tokens
1 parent a743beb commit 2c99890

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/resty/openidc.lua

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -842,11 +842,17 @@ local function openidc_load_and_validate_jwt_id_token(opts, jwt_id_token, sessio
842842

843843
local jwt_obj, err = openidc_load_jwt_and_verify_crypto(opts, jwt_id_token, opts.secret, opts.client_secret)
844844
if err then
845+
local alg = (jwt_obj and jwt_obj.header and jwt_obj.header.alg) or ''
845846
local is_unsupported_signature_error = jwt_obj and not jwt_obj.verified and not is_algorithm_supported(jwt_obj.header)
846847
if is_unsupported_signature_error then
847-
ngx.log(ngx.WARN, "ignored id_token signature as algorithm '" .. jwt_obj.header.alg .. "' is not supported")
848+
if opts.accept_unsupported_alg == nil or opts.accept_unsupported_alg then
849+
ngx.log(ngx.WARN, "ignored id_token signature as algorithm '" .. alg .. "' is not supported")
850+
else
851+
err = "token is signed using algorithm \"" .. alg .. "\" which is not supported by lua-resty-jwt"
852+
ngx.log(ngx.ERR, err)
853+
return nil, err
854+
end
848855
else
849-
local alg = (jwt_obj and jwt_obj.header and jwt_obj.header.alg) or ''
850856
ngx.log(ngx.ERR, "id_token '" .. alg .. "' signature verification failed")
851857
return nil, err
852858
end

0 commit comments

Comments
 (0)