Skip to content

Commit

Permalink
Fix Lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
tsubery committed May 11, 2024
1 parent ca8a932 commit 27dad0c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/discourse_api/single_sign_on.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def self.parse(payload, sso_secret = nil)
parsed = Rack::Utils.parse_query(payload)
if parsed["sso"].nil? || sso.sign(parsed["sso"]) != parsed["sig"]
diags =
"\n\nsso: #{parsed["sso"].inspect}\n\nsig: #{parsed["sig"].inspect}\n\nexpected sig: #{sso.sign(parsed.fetch("sso", ''))}"
"\n\nsso: #{parsed["sso"].inspect}\n\nsig: #{parsed["sig"].inspect}\n\nexpected sig: #{sso.sign(parsed.fetch("sso", ""))}"
if parsed["sso"].nil? || parsed["sso"] =~ %r{[^a-zA-Z0-9=\r\n/+]}m
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}"
Expand Down
6 changes: 4 additions & 2 deletions spec/discourse_api/single_sign_on_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@
it "raises ParseError when there's a signature mismatch" do
sso = described_class.new
sso.sso_secret = "abcd"
missing_sso = Rack::Utils.parse_query(sso.payload).except("sso")
missing_sso = Rack::Utils.parse_query(sso.payload)
missing_sso.delete("sso")
malformed_query = Rack::Utils.build_query(missing_sso)

expect { described_class.parse(malformed_query, "dcba") }.to raise_error(
DiscourseApi::SingleSignOn::ParseError, /The SSO field should/i
DiscourseApi::SingleSignOn::ParseError,
/The SSO field should/i,
)
end
end
Expand Down

0 comments on commit 27dad0c

Please sign in to comment.