# IdP initiated SSO

**URL:** <https://community.auth0.com/t/idp-initiated-sso/6646>\
**Category:** Get Help\
**Tags:** rails, oauth, sso, saml\
**Created:** [May 17, 2017, 9:07pm UTC](https://community.auth0.com/t/idp-initiated-sso/6646 "2017-05-17T21:07:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Irfan\_Wadia](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/irfan_wadia/32/10047_2.png) [@Irfan\_Wadia](https://community.auth0.com/u/Irfan_Wadia)\
**Post date:** [May 17, 2017, 9:07pm UTC](https://community.auth0.com/t/idp-initiated-sso/6646/1 "2017-05-17T21:07:02Z")

</div>

Trying to setup Auth0 to implement IdP initiated SSO with Rails.

I have created two different accounts. One created as IdP and another as SP. I have created a SAML connection on SP with IdP SSO settings:

1. Response protocol as OpenID Connect
2. Query string has below string  
redirect\_uri=[http://localhost:3000/users/auth/auth0/callback&scope=openid](http://localhost:3000/users/auth/auth0/callback&scope=openid) email&response\_type=code

Above redirect\_uri is similar to my SP initiated callback url. And it is not authenticating my user. It works like a charm for SP initiated SSO.

Logs while authenticating on my rails server  
INFO – omniauth: (auth0) Callback phase initiated.  
ERROR – omniauth: (auth0) Authentication failure! csrf\_detected: OmniAuth::Strategies::OAuth2::CallbackError, csrf\_detected | CSRF detected

Also need to understand what should be an ideal workflow for multiple users login from common connection to avoid CSRF

Below are the gems version for integrating Auth0

gem ‘omniauth-auth0’, ‘2.0.0’  
gem ‘omniauth’, ‘~\> 1.2’  
gem ‘oauth2’, ‘~\> 1.0’

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [May 23, 2017, 7:14pm UTC](https://community.auth0.com/t/idp-initiated-sso/6646/2 "2017-05-23T19:14:32Z")

</div>

There’s some level of conflict with what you want to achieve. Protection against CSRF aims to prevent a certain action from being performed if it’s triggered through a third-party. However, IdP-initiated SSO basically boils down to a third-party wanting to initiate an action unilaterally.

To my knowledge, the SAML specification does not address this directly and although something could be done by probably leveraging the `RelayState` parameter that would imply a very intimate knowledge between the IdP and the SP so it would always be on a case by case basis.

Given that the SAML assertion is signed the receiving source already has some way to at least ensure that even though the action is coming from a third-party, it’s coming from a trusted third-party. With this in mind you can either have a specific endpoint for IdP-initiated and disable CSRF on that endpoint or always use SP-initiated instead.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 2, 2018, 5:53am UTC](https://community.auth0.com/t/idp-initiated-sso/6646/3 "2018-03-02T05:53:57Z")

</div>


