Skip to content

leave opts alone when silently re-authenticating #120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 14, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions lib/resty/openidc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ local function openidc_combine_uri(uri, params)
end

-- send the browser of to the OP's authorization endpoint
local function openidc_authorize(opts, session, target_url)
local function openidc_authorize(opts, session, target_url, prompt)
local resty_random = require "resty.random"
local resty_string = require "resty.string"

Expand All @@ -214,8 +214,8 @@ local function openidc_authorize(opts, session, target_url)
nonce=nonce,
}

if opts.prompt then
params.prompt = opts.prompt
if prompt then
params.prompt = prompt
end

if opts.display then
Expand Down Expand Up @@ -962,15 +962,14 @@ function openidc.authenticate(opts, target_url, unauth_action, session_opts)
target_url,
session
end
openidc_authorize(opts, session, target_url)
openidc_authorize(opts, session, target_url, opts.prompt)
return nil, nil, target_url, session
end

-- silently reauthenticate if necessary (mainly used for session refresh/getting updated id_token data)
if opts.refresh_session_interval ~= nil then
if session.data.last_authenticated == nil or (session.data.last_authenticated+opts.refresh_session_interval) < ngx.time() then
opts.prompt = "none"
openidc_authorize(opts, session, target_url)
openidc_authorize(opts, session, target_url, "none")
return nil, nil, target_url, session
end
end
Expand Down