Skip to content

Commit ba3685f

Browse files
committed
DEV: Test token_params
1 parent 17f12b0 commit ba3685f

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

lib/omniauth_open_id_connect.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,15 @@ def authorize_params
6969
end
7070
end
7171

72+
def token_params
73+
params = {}
74+
options[:passthrough_token_options].each do |k|
75+
val = session.delete("omniauth.param.#{k}")
76+
params[k] = val unless [nil, ''].include?(val)
77+
end
78+
super.merge(params)
79+
end
80+
7281
uid { id_token_info['sub'] }
7382

7483
info do
@@ -140,15 +149,6 @@ def callback_url
140149
full_host + script_name + callback_path
141150
end
142151

143-
def token_params
144-
params = {}
145-
options[:passthrough_token_options].each do |k|
146-
val = session.delete("omniauth.param.#{k}")
147-
params[k] = val unless [nil, ''].include?(val)
148-
end
149-
super.merge(params)
150-
end
151-
152152
def get_token_options
153153
{ redirect_uri: callback_url,
154154
grant_type: 'authorization_code',

spec/lib/omniauth_open_id_connect_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,15 @@
101101
end
102102
end
103103

104+
describe "token parameters" do
105+
it "passes through parameters from authorize phase" do
106+
expect(subject.authorize_params[:p]).to eq("someallowedvalue")
107+
allow(subject).to receive(:request) { double("Request", params: {}) }
108+
expect(subject.token_params[:p]).to eq("someallowedvalue")
109+
end
110+
111+
end
112+
104113
end
105114

106115
end

0 commit comments

Comments
 (0)