DEV: improves error message when sso param is not passed (#8549)

SingleSignOnProvider is expecting a sso param later in the chain. If sso param is not found it will cause a 500 with the following exception: `NoMethodError (undefined method `unpack1' for nil:NilClass)` as `set_return_sso_url` is attempting to decode it: https://github.com/discourse/discourse/blob/master/lib/single_sign_on_provider.rb#L19
This commit is contained in:
Joffrey JAFFEUX 2019-12-16 12:33:24 +01:00 committed by GitHub
parent 1002bf62e5
commit aa73df768a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -41,10 +41,12 @@ class SessionController < ApplicationController
end end
def sso_provider(payload = nil) def sso_provider(payload = nil)
payload ||= request.query_string
if SiteSetting.enable_sso_provider if SiteSetting.enable_sso_provider
begin begin
if !payload
params.require(:sso)
payload = request.query_string
end
sso = SingleSignOnProvider.parse(payload) sso = SingleSignOnProvider.parse(payload)
rescue SingleSignOnProvider::BlankSecret rescue SingleSignOnProvider::BlankSecret
render plain: I18n.t("sso.missing_secret"), status: 400 render plain: I18n.t("sso.missing_secret"), status: 400