Commit a6bed5dc authored by James Edwards-Jones's avatar James Edwards-Jones

SamlProvider uses URL helpers for issuer and callback

parent c10d067f
...@@ -28,6 +28,8 @@ class SamlProvider < ActiveRecord::Base ...@@ -28,6 +28,8 @@ class SamlProvider < ActiveRecord::Base
end end
class DefaultOptions class DefaultOptions
include Gitlab::Routing
NAME_IDENTIFIER_FORMAT = 'urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified'.freeze NAME_IDENTIFIER_FORMAT = 'urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified'.freeze
def initialize(group_path) def initialize(group_path)
...@@ -38,16 +40,12 @@ class SamlProvider < ActiveRecord::Base ...@@ -38,16 +40,12 @@ class SamlProvider < ActiveRecord::Base
NAME_IDENTIFIER_FORMAT NAME_IDENTIFIER_FORMAT
end end
def full_group_path
"#{host}/groups/#{@group_path}"
end
def issuer def issuer
full_group_path group_canonical_url(@group_path)
end end
def assertion_consumer_service_url def assertion_consumer_service_url
"#{full_group_path}/-/saml/callback" callback_group_saml_providers_url(@group_path)
end end
def to_h def to_h
...@@ -58,12 +56,6 @@ class SamlProvider < ActiveRecord::Base ...@@ -58,12 +56,6 @@ class SamlProvider < ActiveRecord::Base
idp_sso_target_url_runtime_params: { redirect_to: :RelayState } idp_sso_target_url_runtime_params: { redirect_to: :RelayState }
} }
end end
private
def host
@host ||= Gitlab.config.gitlab.url
end
end end
private private
......
...@@ -8,7 +8,7 @@ describe 'SAML provider settings' do ...@@ -8,7 +8,7 @@ describe 'SAML provider settings' do
let(:callback_path) { "/groups/#{group.path}/-/saml/callback" } let(:callback_path) { "/groups/#{group.path}/-/saml/callback" }
before do before do
stub_config_setting(url: 'https://localhost') stub_default_url_options(protocol: "https")
stub_saml_config stub_saml_config
group.add_owner(user) group.add_owner(user)
end end
......
...@@ -58,7 +58,7 @@ describe SamlProvider do ...@@ -58,7 +58,7 @@ describe SamlProvider do
subject(:saml_provider) { create(:saml_provider, group: group) } subject(:saml_provider) { create(:saml_provider, group: group) }
before do before do
stub_config_setting(url: 'https://localhost') stub_default_url_options(protocol: "https")
end end
it 'generates callback URL' do it 'generates callback URL' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment