# Confusing/unpolished error message when using Discourse as SSO provider

**URL:** <https://meta.discourse.org/t/confusing-unpolished-error-message-when-using-discourse-as-sso-provider/123762>\
**Category:** Feature\
**Created:** [July 23, 2019, 6:15pm UTC](https://meta.discourse.org/t/confusing-unpolished-error-message-when-using-discourse-as-sso-provider/123762 "2019-07-23T18:15:37Z")\
**Posts on this page:** 6\
**Page:** 1

## AI-generated summary

A user [nylen](/t/-/123762/1) reported a confusing error message when using Discourse as a Single Sign-On (SSO) provider. The error occurs when the `sso provider secrets` setting is left blank, resulting in a generic Error 500 message in the browser and a cryptic error message in the logs. The user suggested improving the error message to indicate a misconfigured SSO provider or unauthorized attempt, and to display a more appropriate error message in the browser (e.g., HTTP 400 Bad Request or 403 Forbidden). [codinghorror](/t/-/123762/2) and [codinghorror](/t/-/123762/4) discussed the issue, and [eviltrout](/t/-/123762/7) confirmed that the fix has been implemented by [Osama](https://github.com/discourse/discourse/commit/525920a9794a4582d6588250daa302c36029fce8).

<div class="post-metadata">

**Author:** ![nylen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nylen/32/125684_2.png) [@nylen](https://meta.discourse.org/u/nylen)\
**Post date:** [July 23, 2019, 6:15pm UTC](https://meta.discourse.org/t/confusing-unpolished-error-message-when-using-discourse-as-sso-provider/123762/1 "2019-07-23T18:15:37Z")

</div>

If you don’t configure the `sso provider secrets` setting correctly when using Discourse as an SSO provider, you get a generic Error 500 message in the browser and a confusing error message in the logs:

> TypeError (no implicit conversion of nil into String) /var/www/discourse/lib/single\_sign\_on.rb:114:in `hexdigest’

Based on the code path being followed, this looks to be accidental, and I think this error message should be improved:

- In the logs, indicate that the SSO provider is misconfigured or an unauthorized attempt has been made
- In the browser, show a more appropriate error message (probably `HTTP 400 Bad Request` or `403 Forbidden`)

More details here (maybe an admin/moderator can move that post into this new thread for me):

> [@SSO client link giving error 500](https://meta.discourse.org/t/sso-client-link-giving-error-500/86854/6):
>
> For anyone else experiencing this error, I fixed it by filling in the sso provider secrets setting for the client domain name: In the Discourse code, when this secret is not set, the call to OpenSSL::HMAC.hexdigest fails with the following error in the logs: TypeError (no implicit conversion of nil into String) /var/www/discourse/lib/single\_sign\_on.rb:114:in `hexdigest’ Here is the relevant code path: [discourse/lib/single\_sign\_on\_provider.rb at f364317625ee273d1e8983faa271831db9129…](https://github.com/discourse/discourse/blob/f3643176/lib/single_sign_on_provider.rb#L21-L34)

Note this is in the context of the `wp-discourse` plugin for WordPress but the issue has nothing to do with this plugin specifically.

---

<div class="post-metadata">

**Author:** ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)\
**Post date:** [July 24, 2019, 4:12am UTC](https://meta.discourse.org/t/confusing-unpolished-error-message-when-using-discourse-as-sso-provider/123762/2 "2019-07-24T04:12:01Z")

</div>

> [@nylen](#):
>
> don’t configure the `sso provider secrets` setting correctly

Do you mean leave it blank or put garbage data in it?

---

<div class="post-metadata">

**Author:** ![nylen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nylen/32/125684_2.png) [@nylen](https://meta.discourse.org/u/nylen)\
**Post date:** [July 24, 2019, 6:40am UTC](https://meta.discourse.org/t/confusing-unpolished-error-message-when-using-discourse-as-sso-provider/123762/3 "2019-07-24T06:40:21Z")

</div>

This happens if the setting is left blank (more specifically, I think whenever there is no secret for the domain associated with an incoming SSO request).

---

<div class="post-metadata">

**Author:** ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)\
**Post date:** [July 24, 2019, 5:27pm UTC](https://meta.discourse.org/t/confusing-unpolished-error-message-when-using-discourse-as-sso-provider/123762/4 "2019-07-24T17:27:49Z")

</div>

Aha if the setting is blank I support a better error here @eviltrout can you do this or assign it?

---

<div class="post-metadata">

**Author:** ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)\
**Post date:** [July 26, 2019, 8:40pm UTC](https://meta.discourse.org/t/confusing-unpolished-error-message-when-using-discourse-as-sso-provider/123762/7 "2019-07-26T20:40:49Z")

</div>

@Osama did this and it’s been merged:

[https://github.com/discourse/discourse/commit/525920a9794a4582d6588250daa302c36029fce8](https://github.com/discourse/discourse/commit/525920a9794a4582d6588250daa302c36029fce8)

---

<div class="post-metadata">

**Author:** ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)\
**Post date:** [July 27, 2019, 12:35am UTC](https://meta.discourse.org/t/confusing-unpolished-error-message-when-using-discourse-as-sso-provider/123762/8 "2019-07-27T00:35:10Z")

</div>

Closed on July 27, 2019, 12:35am UTC


