mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 23:58:26 +08:00
FIX: Return 422 instead of 500 for invalid SSO signature (#6738)
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
class SingleSignOn
|
||||
|
||||
class ParseError < RuntimeError; end
|
||||
|
||||
ACCESSORS = %i{
|
||||
add_groups
|
||||
admin moderator
|
||||
@ -61,9 +63,9 @@ class SingleSignOn
|
||||
if sso.sign(parsed["sso"]) != parsed["sig"]
|
||||
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}"
|
||||
raise ParseError, "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}"
|
||||
raise ParseError, "Bad signature for payload #{diags}"
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user