Skip to content

Commit 8c63805

Browse files
committed
Fix #157 : Set compatibility with session_contents opts.
1 parent 3dc960f commit 8c63805

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

Diff for: lib/resty/openidc.lua

+14-6
Original file line numberDiff line numberDiff line change
@@ -1117,13 +1117,21 @@ local function openidc_access_token(opts, session, try_to_renew)
11171117
session.data.refresh_token = json.refresh_token
11181118
end
11191119

1120-
if json.id_token ~= nil then
1121-
local id_token, err = openidc_load_and_validate_jwt_id_token(opts, json.id_token, session)
1122-
if err then
1123-
session:save()
1124-
return nil, err
1120+
if store_in_session(opts, 'enc_id_token') then
1121+
if json.id_token ~= nil then
1122+
session.data.enc_id_token = json.id_token
1123+
end
1124+
end
1125+
1126+
if store_in_session(opts, 'id_token') then
1127+
if json.id_token ~= nil then
1128+
local id_token, err = openidc_load_and_validate_jwt_id_token(opts, json.id_token, session)
1129+
if err then
1130+
session:save()
1131+
return nil, err
1132+
end
1133+
session.data.id_token = id_token
11251134
end
1126-
session.data.id_token = id_token
11271135
end
11281136

11291137
-- save the session with the new access_token and optionally the new refresh_token

0 commit comments

Comments
 (0)