We are in the process of migrating 187 Drupal websites from the simplesamlphp_auth module to the samlauth module. The default behavior of simplesamlphp_auth is to perform both a Drupal logout and a SAML logout when using the '/user/logout' URL. We'd like to submit a patch for the samlauth module that will add an option to implement this behavior. This will allow us to maintain the current logout experience for website users without requiring site modifications to replace '/user/logout' with '/saml/logout'.
Would this be an acceptable patch? If so, one of my colleagues will develop it and I can attach it to this issue.
Issue fork samlauth-3583791
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
roderikYes, that sounds like a fine addition (though I'd like it to stay off by default), and probably clear enough where the configuration UI option should go.
I assume you'll just be calling SamlController::logout() (which first logs out from Drupal and then redirects to the IdP, to log out from there + possibly do a logout-redirect-sequence through all logged-in sites/SPs).
Detail note for completeness:
From official SAML docs, I understand the 'official' specification for SP initiated logout is to first logout from the IDP + all other SPs, and then logout from our SP (Drupal) once we are redirected back.. (Drawing in #3043704-9: Make user logout more robust.) I've found this to be a risk of never logging out from Drupal at all, because we have no control over what errors can occur during the logout-redirect-sequence). So the Drupal logout happens first.
As far as I can tell quickly, simplesamlphp_auth also does Drupal logout first, in simplesamlphp_auth_logout() -- though it doesn't seem to do it 'properly' there. So hook_user_logout() implementations which maybe aren't currently executed by simplesamlphp_auth, will start being executed by the samlauth module.
Comment #3
kfolsom commentedThanks for the feedback.
I agree that the default for this should be off, such that default behavior remains the same as it is now.
My colleague is beginning work on the patch and agrees with your suggestion of using the SamlController::logout(). And the configuration UI option location is clear from examining the current configuration options layout...probably at the bottom of the Login / Logout section of the /admin/config/people/saml page.
My colleague is @timlouie, who has submitted another patch in issue #3070321.
Comment #6
timlouie commented@kfolsom, @roderik I submitted a merge request with what I think will workout. It looks like it's not recommended to use the samlController::logout() inside the hook_user_logout(). So I added a route subcriber to update the user.logout path to the saml/logout. There is a checkbox option on the login/user page. So it should be off by default, but allows someone to use /saml/logout inplace of user/logout.
Comment #7
roderikGreat. Route subscriber feels like the best option.
This change is of the type: code is stable / does not add any real complexity to existing code, so if it works for you, I'll merge it.
(I looked at the route subscriber, looks good to me. I'll check the rest in detail later. I'm absent, but I hope to do some proper reviews and merging, maybe do some other issues too before I release a new version... next week.)
Comment #8
timlouie commented@roderik that is great, thank you for your attention and guidance. Let me know if any concerns come up and I can rework any code.
Comment #9
roderikPostponing on #3555406: User logout csrf because there may be an extra route to alter (and this feels like the right 'order of dependencies' in terms of keeping functionality separate).
I'm hoping for some activity there that I just need to review, but if not, I'll reassess next weekend.
Comment #10
timlouie commentedComment #11
kfolsom commentedHi, @roderik. Thanks for pushing through issue 3070321. Could you also consider pushing this one through to Dev before the next release? It will help our web developers with the migration from simplesamlphp_auth to samlauth, since the option added preserves the logout behavior of the previous package. Thanks much.
Comment #12
roderikOK, so I'll assume you're using the -dev version (and can work with just that one updated, for the next ~week).
Doing the dependency #3555406 (resulting in a 'cleaner' split) did not work out, due to lameness + an unexpected snag that still needs to be solved there. But it doesn't matter anymore.
I'll also add PHPUnit tests for the new functionality, in there.
I pushed some PHPCS issues + some dependency injection. (I hope to do more proper communication / set back to Needs Work when I'm more available / next time...) Plus some tweaking of UI labels. Nothing major.
Comment #14
roderikComment #16
kfolsom commentedThanks, @roderik, for merging this into Dev. We can definitely hang out on that for a week or so.