mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 21:12:45 +08:00
FIX: support sso_url that has query params
This commit is contained in:
parent
faaada6e8a
commit
342d09bc34
|
@ -48,7 +48,8 @@ class SingleSignOn
|
|||
|
||||
|
||||
def to_url(base_url=nil)
|
||||
"#{base_url || sso_url}?#{payload}"
|
||||
base = "#{base_url || sso_url}"
|
||||
"#{base}#{base.include?('?') ? '&' : '?'}#{payload}"
|
||||
end
|
||||
|
||||
def payload
|
||||
|
|
|
@ -10,7 +10,7 @@ describe DiscourseSingleSignOn do
|
|||
SiteSetting.stubs("sso_secret").returns(@sso_secret)
|
||||
end
|
||||
|
||||
it "can fill in data on way back" do
|
||||
def make_sso
|
||||
sso = SingleSignOn.new
|
||||
sso.sso_url = "http://meta.discorse.org/topics/111"
|
||||
sso.sso_secret = "supersecret"
|
||||
|
@ -19,17 +19,38 @@ describe DiscourseSingleSignOn do
|
|||
sso.username = "sam"
|
||||
sso.name = "sam saffron"
|
||||
sso.external_id = "100"
|
||||
sso
|
||||
end
|
||||
|
||||
url, payload = sso.to_url.split("?")
|
||||
url.should == sso.sso_url
|
||||
parsed = SingleSignOn.parse(payload, "supersecret")
|
||||
|
||||
def test_parsed(parsed, sso)
|
||||
parsed.nonce.should == sso.nonce
|
||||
parsed.email.should == sso.email
|
||||
parsed.username.should == sso.username
|
||||
parsed.name.should == sso.name
|
||||
parsed.external_id.should == sso.external_id
|
||||
end
|
||||
|
||||
it "can fill in data on way back" do
|
||||
sso = make_sso
|
||||
|
||||
url, payload = sso.to_url.split("?")
|
||||
url.should == sso.sso_url
|
||||
parsed = SingleSignOn.parse(payload, "supersecret")
|
||||
|
||||
test_parsed(parsed, sso)
|
||||
end
|
||||
|
||||
it "handles sso_url with query params" do
|
||||
sso = make_sso
|
||||
sso.sso_url = "http://tcdev7.wpengine.com/?action=showlogin"
|
||||
|
||||
sso.to_url.split('?').size.should == 2
|
||||
|
||||
url, payload = sso.to_url.split("?")
|
||||
url.should == "http://tcdev7.wpengine.com/"
|
||||
parsed = SingleSignOn.parse(payload, "supersecret")
|
||||
|
||||
test_parsed(parsed, sso)
|
||||
end
|
||||
|
||||
it "validates nonce" do
|
||||
|
|
Loading…
Reference in New Issue
Block a user