omniauth-mpassid 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/omniauth/strategies/mpassid.rb +61 -0
- data/lib/omniauth-mpassid/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d20db7b39bbaa982cf5e05417c903cc08f3b543d7eac10ba621e8c5868aa1c45
|
4
|
+
data.tar.gz: 2c54ae01ece53cccc2d3f323c46e0d876a87443b38d306ce6ee9656fda8c1a3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: acd40c82d1dd81d7e4a9184c014dd0797930a2743327e61ab54319b9bebf2dc0726990386670ff94c4f216a27f910635daed878513dcd87fcbfc3a74180e5369
|
7
|
+
data.tar.gz: c1b6d98478a1c39c1aabb7cafd2d1631f92613897936ac497661271da0b848fa3a2740a9910d091dcae4e6c470490bc5571d9f3310b81743bc88e347a9d7b5fb
|
@@ -10,6 +10,27 @@ module OmniAuth
|
|
10
10
|
# :test - MPASSid test environment
|
11
11
|
option :mode, :production
|
12
12
|
|
13
|
+
# Defines the lang parameters to check from the request phase request
|
14
|
+
# parameters. A valid language will be added to the IdP sign in redirect
|
15
|
+
# URL as the last parameter (with the name `lang` as expected by
|
16
|
+
# MPASSid).
|
17
|
+
#
|
18
|
+
# MPASSid generally accepts `fi` or `sv` in this parameter but it can
|
19
|
+
# depend on the underlying service. The language can be parsed from the
|
20
|
+
# following kind of strings:
|
21
|
+
# - fi
|
22
|
+
# - sv-SE
|
23
|
+
# - fi_FI
|
24
|
+
#
|
25
|
+
# In case a valid language cannot be parsed from the parameter, the lang
|
26
|
+
# parameter will default to `:idp_sso_target_url_default_lang`.
|
27
|
+
option :idp_sso_target_url_lang_params, %w[locale language lang]
|
28
|
+
|
29
|
+
# This is the default language to be passed to IdP sign in redirect URL as
|
30
|
+
# defined above. In case a valid language is not found from the request
|
31
|
+
# parameters, this will be used instead.
|
32
|
+
option :idp_sso_target_url_default_lang, 'fi'
|
33
|
+
|
13
34
|
# The request attributes for MPASSid
|
14
35
|
option :request_attributes, [
|
15
36
|
# The unique identifier of the authenticated user. Currently recommended
|
@@ -236,6 +257,20 @@ module OmniAuth
|
|
236
257
|
)
|
237
258
|
end
|
238
259
|
|
260
|
+
# Override the request phase to be able to pass the lang parameter to
|
261
|
+
# the redirect URL. Note that this needs to be the last parameter to
|
262
|
+
# be passed to the redirect URL.
|
263
|
+
def request_phase
|
264
|
+
authn_request = OneLogin::RubySaml::Authrequest.new
|
265
|
+
lang = lang_for_authn_request
|
266
|
+
|
267
|
+
with_settings do |settings|
|
268
|
+
url = authn_request.create(settings, additional_params_for_authn_request)
|
269
|
+
url += "&lang=#{CGI.escape(lang)}" unless lang.nil?
|
270
|
+
redirect(url)
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
239
274
|
# This method can be used externally to fetch information about the
|
240
275
|
# response, e.g. in case of failures.
|
241
276
|
def response_object
|
@@ -251,6 +286,13 @@ module OmniAuth
|
|
251
286
|
end
|
252
287
|
end
|
253
288
|
|
289
|
+
# Override the callback URL so that it always matches the one expected by
|
290
|
+
# MPASSid. No additional query string parameters can be included in the
|
291
|
+
# string.
|
292
|
+
def callback_url
|
293
|
+
full_host + script_name + callback_path
|
294
|
+
end
|
295
|
+
|
254
296
|
private
|
255
297
|
|
256
298
|
def idp_metadata_url
|
@@ -302,6 +344,25 @@ module OmniAuth
|
|
302
344
|
end
|
303
345
|
end
|
304
346
|
end
|
347
|
+
|
348
|
+
def lang_for_authn_request
|
349
|
+
if options.idp_sso_target_url_lang_params.is_a?(Array)
|
350
|
+
options.idp_sso_target_url_lang_params.each do |param|
|
351
|
+
next unless request.params.key?(param.to_s)
|
352
|
+
|
353
|
+
lang = parse_language_value(request.params[param.to_s])
|
354
|
+
return lang unless lang.nil?
|
355
|
+
end
|
356
|
+
end
|
357
|
+
|
358
|
+
options.idp_sso_target_url_default_lang
|
359
|
+
end
|
360
|
+
|
361
|
+
def parse_language_value(string)
|
362
|
+
language = string.sub('_', '-').split('-').first
|
363
|
+
|
364
|
+
language if language =~ /^(fi|sv)$/
|
365
|
+
end
|
305
366
|
end
|
306
367
|
end
|
307
368
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-mpassid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Antti Hukkanen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: omniauth-saml
|