mirror of
https://github.com/discourse/discourse.git
synced 2025-04-10 08:41:27 +08:00
improve error handling massage for bad sso requests
This commit is contained in:
parent
7bcecb54fd
commit
2754b45fff
@ -22,7 +22,12 @@ class SingleSignOn
|
|||||||
|
|
||||||
parsed = Rack::Utils.parse_query(payload)
|
parsed = Rack::Utils.parse_query(payload)
|
||||||
if sso.sign(parsed["sso"]) != parsed["sig"]
|
if sso.sign(parsed["sso"]) != parsed["sig"]
|
||||||
raise RuntimeError, "Bad signature for payload"
|
diags = "\n\nsso: #{parsed["sso"]}\n\nsig: #{parsed["sig"]}\n\nexpected sig: #{sso.sign(parsed["sso"])}"
|
||||||
|
if parsed["sso"] =~ /[^a-zA-Z0-9=\r\n]/m
|
||||||
|
raise RuntimeError, "The SSO field should be Base64 encoded, using only A-Z, a-z, 0-9 and = characters. Your input contains characters we don't understand as Base64, see http://en.wikipedia.org/wiki/Base64 #{diags}"
|
||||||
|
else
|
||||||
|
raise RuntimeError, "Bad signature for payload #{diags}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
decoded = Base64.decode64(parsed["sso"])
|
decoded = Base64.decode64(parsed["sso"])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user