Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support for Single Logout #115

Merged
merged 1 commit into from
Oct 18, 2016
Merged

feat: Support for Single Logout #115

merged 1 commit into from
Oct 18, 2016

Conversation

suprnova32
Copy link
Member

Replaces #99, as the author there has not responded and we would really like to have this feature for version 1.7.0.

Fixes #81

@md5 can you help me with a review here? I tried solving the conflicts to the best of my abilities, and the tests are green, but I really need more eyes here to make sure the code is sound.

cc @bufferoverflow

@coveralls
Copy link

coveralls commented Sep 18, 2016

Coverage Status

Coverage increased (+0.5%) to 95.105% when pulling aa8ea8d on single-logout-support into 64c874e on master.

7 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.5%) to 95.105% when pulling aa8ea8d on single-logout-support into 64c874e on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.5%) to 95.105% when pulling aa8ea8d on single-logout-support into 64c874e on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.5%) to 95.105% when pulling aa8ea8d on single-logout-support into 64c874e on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.5%) to 95.105% when pulling aa8ea8d on single-logout-support into 64c874e on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.5%) to 95.105% when pulling aa8ea8d on single-logout-support into 64c874e on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.5%) to 95.105% when pulling aa8ea8d on single-logout-support into 64c874e on master.

@coveralls
Copy link

coveralls commented Sep 18, 2016

Coverage Status

Coverage increased (+0.5%) to 95.105% when pulling aa8ea8d on single-logout-support into 64c874e on master.

Copy link
Contributor

@md5 md5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a couple comments on the README, but I'll need to review the actual code later since I'm out of time this morning.

* `:idp_slo_target_url` - The URL to which the single logout request and response should
be sent. This would be on the identity provider. Optional.

* `:default_relay_state` - The URL to use as default RelayState on single logouts. The
Copy link
Contributor

@md5 md5 Sep 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure it's accurate to say that the RelayState is a URL in all cases.

Also, can we code-format "RelayState" with backticks?

## Single Logout

Single Logout can be Service Provider initiated or Identity Provider initiated.
The SP initiated flow can be integrated in the `SessionsController#destroy`.
Copy link
Contributor

@md5 md5 Sep 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sentence seems to start off assuming that Devise will be used with OmniAuth, which is not always the case. I think it should say something like "When using Devise, the SP-initiated flow can be integrated with the SessionsController#destroy action."

Single Logout can be Service Provider initiated or Identity Provider initiated.
The SP initiated flow can be integrated in the `SessionsController#destroy`.
For this to work its important to preserve the `saml_uid` value before Devise
clears the session and redirect to the spslo subpath to initiate the single logout.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should say "the /spslo subpath" I think.

Copy link
Contributor

@md5 md5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@supernova32 This looks good to merge 👍

It's a bummer that this is going to conflict with #101, but I don't see a better way to structure this code to avoid that.

@md5
Copy link
Contributor

md5 commented Sep 20, 2016

@supernova32 I should have been more clear. I think the README still needs to be updated, but I think the code is fine.

@suprnova32
Copy link
Member Author

@md5 don't worry. I did get that 😄 I'll update the README tomorrow.

@suprnova32
Copy link
Member Author

@md5 I updated the README. Let me know what you think.

@coveralls
Copy link

coveralls commented Sep 22, 2016

Coverage Status

Coverage increased (+0.5%) to 95.105% when pulling c6e688a on single-logout-support into 76aa16c on master.

* `:idp_slo_target_url` - The URL to which the single logout request and response should
be sent. This would be on the identity provider. Optional.

* `:default_relay_state` - The value to use as default `RelayState` on single log outs. The
Copy link
Contributor

@md5 md5 Sep 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that I read this again, I think it's weird that :default_relay_state setting is only used for SLO, despite the fact that the RelayState mechanism applies to SSO as well as SLO (depending on the binding). It seems like it should be named :slo_default_relay_state or else it should be used in other places as well.

Also, I think this documentation should cover the fact that the :default_relay_state (or whatever it is called) can be a Proc (or other object responding to call) and that the request instance will be passed to this callable if it has an arity of 1.


# Generate a response to the IdP.
logout_request_id = logout_request.id
logout_response = OneLogin::RubySaml::SloLogoutresponse.new.create(settings, logout_request_id, nil, RelayState: relay_state)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if it makes sense to add the RelayState parameter when relay_state returns a blank string or nil. This applies below to generate_logout_request as well.

## Single Logout

Single Logout can be Service Provider initiated or Identity Provider initiated.
When using Devise as authentication solution, the SP initiated flow can be integrated
Copy link
Contributor

@md5 md5 Sep 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"as an authentication solution"

When using Devise as authentication solution, the SP initiated flow can be integrated
in the `SessionsController#destroy` action.

For this to work its important to preserve the `saml_uid` value before Devise
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"it's important" or "it is important"

@md5
Copy link
Contributor

md5 commented Oct 6, 2016

bump @supernova32

@suprnova32
Copy link
Member Author

@md5 sorry. I'm a bit swamped at work. I'll take a look at your comments tomorrow.

@suprnova32
Copy link
Member Author

@md5 i addressed your comments. it's a shame that I cannot resolve a discussion that is no longer valid, or that GitHub does not tell you that that discussion was started on an outdated diff. ¯**(ツ)**/¯

@coveralls
Copy link

coveralls commented Oct 11, 2016

Coverage Status

Coverage increased (+0.5%) to 95.035% when pulling 65ec2ef on single-logout-support into 76aa16c on master.

@coveralls
Copy link

coveralls commented Oct 11, 2016

Coverage Status

Coverage increased (+0.5%) to 95.105% when pulling b306ab1 on single-logout-support into 76aa16c on master.

@suprnova32
Copy link
Member Author

@md5 any chance you can sign off on this today? I'd like to cut the new gem over the weekend so we can release the new version with GitLab 8.13. Thanks!

@@ -44,10 +45,6 @@ def request_phase
end

def callback_phase
unless request.params['SAMLResponse']
raise OmniAuth::Strategies::SAML::ValidationError.new("SAML response missing")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check still needs to happen here. In a couple of lines, there's a call to response_fingerprint, which will blow up (because of a nil argument to Base64.decode64) if there's no SAMLResponse param.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(or possibly the check should be in response_fingerprint itself)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Er, that only applies if someone has supplied the idp_cert_fingerprint_validator option.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ErinCall: Nice catch!

Since that's the only call to response_fingerprint, it's probably safe to check for request.params['SAMLResponse'] in that method and return false or nil if is is not present. This will cause the code to raise OmniAuth::Strategies::SAML::ValidationError as it would have previous to this PR.

In general, I think this idp_cert_fingerprint_validator code needs to be deprecated and eventually removed, but it's possible I don't understand the use case. I think it's a bad idea to have ominiauth-saml directly decoding the SAMLResponse instead of relying on ruby-saml to do so in a consistent way.

md5
md5 previously requested changes Oct 14, 2016
Copy link
Contributor

@md5 md5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to merge other than the issue pointed out by @EricCall regarding response_fingerprint 👍

@md5
Copy link
Contributor

md5 commented Oct 15, 2016

@supernova32 I'll should be able to spare some time this weekend to review this again if you get the response_fingerprint stuff sorted out 👍

@suprnova32 suprnova32 dismissed md5’s stale review October 16, 2016 16:51

Changes needed have been implemented.

@suprnova32
Copy link
Member Author

@ErinCall thanks for the review. You are absolutely right. I added a guard clause to the callback_phase method to raise OmniAuth::Strategies::SAML::ValidationError if there is no SAMLResponse present.

@md5 I also cleaned the code up a bit and added some line breaks to make the code easier to read. If you have time today or tomorrow, I'd love to get this merged 😄

@coveralls
Copy link

coveralls commented Oct 16, 2016

Coverage Status

Coverage decreased (-0.3%) to 94.286% when pulling cd3fc43 on single-logout-support into 76aa16c on master.

1 similar comment
@coveralls
Copy link

coveralls commented Oct 16, 2016

Coverage Status

Coverage decreased (-0.3%) to 94.286% when pulling cd3fc43 on single-logout-support into 76aa16c on master.

Copy link
Contributor

@md5 md5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to merge 👍

@suprnova32 suprnova32 merged commit 5559d6b into master Oct 18, 2016
@suprnova32 suprnova32 deleted the single-logout-support branch October 18, 2016 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants