# Discourse-saml + Okta endless redirect

**URL:** https://meta.discourse.org/t/discourse-saml-okta-endless-redirect/55525
**Category:** SSO
**Created:** [2017年一月10日 20:51 UTC](https://meta.discourse.org/t/discourse-saml-okta-endless-redirect/55525 "2017-01-10T20:51:29Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![runofthemill](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/runofthemill/32/56919_2.png) [@runofthemill](https://meta.discourse.org/u/runofthemill)
#### Post date: [2017年一月10日 20:51 UTC](https://meta.discourse.org/t/discourse-saml-okta-endless-redirect/55525/1 "2017-01-10T20:51:29Z")

</div>

Hi there - I’m trying to get the discourse-saml plugin working with Okta; I’ve scoured the existing threads, and can’t seem to figure out what’s going on.

When I go to the login page, it prompts me to log in with my Okta credentials. Upon logging in, the page gets stuck in a loop between [forums.trusa.io](http://forums.trusa.io) (the Discourse URL) and [teamrubiconusa.okta.com](http://teamrubiconusa.okta.com) (the Okta login).

Here’s how Okta is configured:

 ![](https://global.discourse-cdn.com/meta/original/3X/f/4/f489b95fb944c04c822bd87636283f924a76f5c7.png)

Here’s the Login settings in Discourse:

 ![](https://global.discourse-cdn.com/meta/original/3X/b/9/b9b8b38ef26050ccb5c558dfe4cf7f43bd36ac6c.png)

Here’s the app.yml settings:

 ![](https://global.discourse-cdn.com/meta/original/3X/8/f/8f2cdb1a31eb77e79f1e9029bc7c11d280b1fac2.png)

The logs don’t show anything informative:

 ![](https://global.discourse-cdn.com/meta/original/3X/c/0/c0cd5b54d90dd434ba8a1aec2ec4b0bec134d44d.png)

Halp! 😕

@skoota - I saw you had some issues with the plugin, perhaps you might be able to lend a hand?

Thanks!

---

<div class="post-metadata">

### Author: ![skoota](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/skoota/32/65472_2.png) [@skoota](https://meta.discourse.org/u/skoota)
#### Post date: [2017年一月10日 23:51 UTC](https://meta.discourse.org/t/discourse-saml-okta-endless-redirect/55525/2 "2017-01-10T23:51:45Z")

</div>

Happy to help, as it took me a while getting this working too 🙂

I think the issue could be the SSO configuration in the Discourse settings - remove all the custom configuration for SSO that you have made, as SSO is being handled by the plugin instead. This is what mine looks like:

 ![](https://global.discourse-cdn.com/meta/original/3X/d/a/dacf6e43e8a2d89d9419c5f020924cefb99f79cd.png)

…as you can see, nothing is enabled or configured.

Let me know how it goes!

---

<div class="post-metadata">

### Author: ![runofthemill](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/runofthemill/32/56919_2.png) [@runofthemill](https://meta.discourse.org/u/runofthemill)
#### Post date: [2017年一月11日 00:27 UTC](https://meta.discourse.org/t/discourse-saml-okta-endless-redirect/55525/3 "2017-01-11T00:27:59Z")

</div>

Thanks! That seems to fix the problem, although now it’s pulling in the wrong data for user email when a new user registers, and it won’t let the registration complete since there’s an invalid value in the email field, which isn’t editable :\

I appreciate the help! Trying to debug the email issue now, will post back with any updates.

---

<div class="post-metadata">

### Author: ![skoota](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/skoota/32/65472_2.png) [@skoota](https://meta.discourse.org/u/skoota)
#### Post date: [2017年一月11日 01:03 UTC](https://meta.discourse.org/t/discourse-saml-okta-endless-redirect/55525/4 "2017-01-11T01:03:28Z")

</div>

No worries. That sounds like a problem on the SAML provider end of things. Let me know how you get on.

---

<div class="post-metadata">

### Author: ![runofthemill](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/runofthemill/32/56919_2.png) [@runofthemill](https://meta.discourse.org/u/runofthemill)
#### Post date: [2017年一月11日 01:25 UTC](https://meta.discourse.org/t/discourse-saml-okta-endless-redirect/55525/5 "2017-01-11T01:25:49Z")

</div>

I made a workaround by forking the plugin and changing the email value in `plugin.rb` to an attribute that Okta sends:

```
result.email = auth[:info].email || uid
if auth.extra.present? && auth.extra[:raw_info].present?
  result.email = auth.extra[:raw_info].attributes['screenName']
end
result.email_valid = true

```

Not the best solution, but works for now 😛

---

<div class="post-metadata">

### Author: ![runofthemill](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/runofthemill/32/56919_2.png) [@runofthemill](https://meta.discourse.org/u/runofthemill)
#### Post date: [2017年一月11日 18:53 UTC](https://meta.discourse.org/t/discourse-saml-okta-endless-redirect/55525/6 "2017-01-11T18:53:34Z")

</div>

So it’s now pulling in the correct data for the email field, but gives “Something went wrong” when the user proceeds to create a new account.

The logs show an error with `"Undefined method 'strip' in /app/controllers/users_controller"` at line 311, and I think it’s because strip expects a string, and it’s getting an object. But if I add `.to_s` to `result.email = auth.extra[:raw_info].attributes['screenName']`, the new user’s email shows up as `["jeremy.miller+test@teamrubiconusa.org"]` so that’s not quite the right solution…

I’m not a Ruby or Rails developer, so I’m not sure the correct way to handle this; any thoughts?

Edit: turns out this is all I needed to do:

```
result.email = auth.extra[:raw_info].attributes['screenName'].try(:first)

```

---

<div class="post-metadata">

### Author: ![neil](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neil/32/102150_2.png) [@neil](https://meta.discourse.org/u/neil)
#### Post date: [2017年七月13日 18:33 UTC](https://meta.discourse.org/t/discourse-saml-okta-endless-redirect/55525/7 "2017-07-13T18:33:14Z")

</div>

Sorry for reviving an old topic… @runofthemill Isn’t this something that could have been fixed in the SAML application settings in Okta? Seems like Screen Name has email as the value.

 ![](https://global.discourse-cdn.com/meta/original/3X/8/6/86fab085fbbdec5625f8b231c45359da086a6c4c.png)

---

<div class="post-metadata">

### Author: ![runofthemill](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/runofthemill/32/56919_2.png) [@runofthemill](https://meta.discourse.org/u/runofthemill)
#### Post date: [2017年七月20日 19:36 UTC](https://meta.discourse.org/t/discourse-saml-okta-endless-redirect/55525/8 "2017-07-20T19:36:08Z")

</div>

Thanks for the response @neil - we’ve shut down the forum this was in reference to, but if we revive it I will certainly check this out. =D
