Skip to content

Commit 3a1e760

Browse files
committed
metadata_path? implementation
See salsify#3
1 parent a751d33 commit 3a1e760

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/omniauth/saml/multi_provider/handler.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,22 @@ def initialize(path_prefix: OmniAuth.config.path_prefix,
2020
@saml_path_regex = /^#{@provider_path_prefix}\/(?<identity_provider_id>#{@identity_provider_id_regex})/
2121
@request_path_regex = /#{saml_path_regex}\/?$/
2222
@callback_path_regex = /#{saml_path_regex}\/callback\/?$/
23+
@metadata_path_regex = /#{saml_path_regex}\/metadata\/?$/
2324
end
2425

2526
def provider_options
2627
{
2728
request_path: method(:request_path?),
2829
callback_path: method(:callback_path?),
30+
metadata_path: method(:metadata_path?),
2931
setup: method(:setup)
3032
}
3133
end
3234

3335
private
3436

3537
attr_reader :provider_path_prefix, :saml_path_regex, :request_path_regex, :callback_path_regex,
36-
:identity_provider_options_generator
38+
:metadata_path_regex, :identity_provider_options_generator
3739

3840
def setup(env)
3941
identity_provider_id = extract_identity_provider_id(env)
@@ -69,6 +71,11 @@ def callback_path?(env)
6971
!!callback_path_regex.match(path)
7072
end
7173

74+
def metadata_path?(env)
75+
path = current_path(env)
76+
!!metadata_path_regex.match(path)
77+
end
78+
7279
def current_path(env)
7380
env['PATH_INFO']
7481
end

0 commit comments

Comments
 (0)