We are creating a Drupal 8 website where some sub-pages are only accessible to authenticated users. These sub-pages are accessible from links on other pages. However, we would like to avoid that users, which are not logged in, get the “access denied” page when they click on the link, but they should rather be redirected to the SSO page. Is this possible?
You can create a basic page with the thellowing message:
“In order to access the content of this page you need to login first.”
Then hyperlink the login with this URL /user/login
Then go to Configuration->Basic site settings and put the page that you have created as the new Access denied page under Default 403 (access denied) page.
Is there any way we can include the target page in the login link?
For example, I don’t want my users to land again on the Access Denied page after logging in.
Ideally it should even be dynamic, so I would like to keep somewhere the original URL that triggered the 403 page, and use that for redirection.
In Drupal 7 we could do /Shibboleth.sso/?target=https%3A%2F%2Fmy-site.web.cern.ch%2Fmy-redirection to statically define the redirection but with /user/login that trick doesn’t seem to work
Are you sure that /user/login doesn’t work? I have seen it on other sites people set a custom access denied page and add a link to user/login and works fine.
Also there are the following two modules that you can check:
Hi, I do not understand this answer.
I created a Basic Page . But what do you call"hyperlink the login with this URL" ?
When i when to configure “Configuration->Basic site settings” I don’t know what to put ? should I put /node/xxx or something else?
Just create a basic page and in the body of the node ass some text like:
“Click here to login”
Make “here” a hyperlink and add /user/login
Then go to Configuration->Basic site settings and at the bottom of the page you will see the access denied URL. Put there the link of your basic page either like /node/nodeid or /content/titleofnode
You have enabled the Content Access module and you set it up per content type. The basic page content type was accessible only to authenticated users that’s why the custom access denied page could not be displayed.
I enabled the content access in basic page content type per node and I allowed anonymous users to see this specific node.
Now it works fine. Be careful when you work with access and permission modules.