If a user is logged in, going to /saml/login should not display a "access denied" page.
I wasn't sure until now whether this was covered by any other issue, but it's not.
I (still relative D8 beginner) just traced what happens in the similar /user/login case: actually the HTTP kernel throws an AccessDeniedHttpException, which then dispatches a 'kernel.exception' event. \Drupal\user\EventSubscriber\AccessDeniedSubscriber reacts on that event by setting a redirect response, to /user.
OK, great. We can do the same thing. (An event subscriber has the added advantage that we can just implement the exact same behavior... but if people don't like this, they can alter that behavior by e.g.
* always displaying a "you are already logged in" message
* forcing logout and redirecting to the IDP
* ...
)
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | samlauth-saml-login-should-not-yield-access-denied-2901757-5.patch | 2.9 KB | cruno |
Comments
Comment #3
roderikDone. Same also done for /saml/login.
Comment #5
cruno commentedSince this issue still exists in alpha1 and alpha2 release has not yet been set, I'm uploading a patch that includes the Event Subscriber and service entry from the commit posted in #2.
This patch does not include the code standard change also in that commit.
This is being uploaded here so that others facing this issue may apply the patch with Composer if needed before alpha2 is released.
Comment #6
akalam commentedThere are some issues on redirection, for example on Acquia Cloud Site Factory when more than one domain is configured, you get the following error message:
"Redirects to external URLs are not allowed by default, use \Drupal\Core\Routing\TrustedRedirectResponse for it."
I'm not 100% sure if it is the best way to fix it, but attaching a new patch (against 8.x-2.x branch) trying to solve it.
Comment #7
akalam commentedCan we reopen this issue?
Comment #8
akalam commentedPlease IGNORE my previous patch. If you expect issues in multi-lingual sites, check this issue:
https://www.drupal.org/project/samlauth/issues/2848809
There are patches for 2.x and 3.x branches.