Hello,

currently I'm using the PHP filter module (https://www.drupal.org/project/php) for Drupal 8, because it does what I want to achieve, but I'm looking for a better way to avoid that module. May I kindly ask for your help in sorting out the options?

The primary intent is to provide a mean to do a single sign-on for a user logged in into our drupalsite to another system sitting on the same server. The other system can check the parameters provided in the URL by accessing drupal's database.

in Detail:

PHP-Filter approach

I use some lines of PHP code to construct and display an URL on a simple page that is formed like
http://target.example.com/logon.php?user=current_userid&hsid=hashed_sess...
so that the system at target.myside.com can check against my primary drupal database, whether the user current_userid is currently logged on (=has the corresponding hashed drupal session id) inside our drupal-site "example.com".

This works, but uses the PHP filter module, which should be avoided for security reasons.

a custom module

Probably the preferred approach, but I've no idea how to start this. Are there easy to use code templates?
How would that be used? Would I just put a link to example.com/some_special_path into a simple page node? And the code pointed to by example.com/some_special_path would construct the special URL and open it?

Other options

Could we use "views" to construct such an URL? Or anything else?

Thanks a lot for your suggestions and/or advice.

Richard.

Comments

John_B’s picture

You could take a look at the D8 port of Bakery module https://www.drupal.org/node/2699683. I have no idea how good it is or whether it works with current version of D8. it is at least a start.

Digit Professionals specialising in Drupal, WordPress & CiviCRM support for publishers in non-profit and related sectors

richardmetzger’s picture

Hi - I found (and understood) https://www.drupal.org/docs/8/creating-custom-modules/a-hello-world-cust...
By using this as an example it was pretty easy to write an own custom page module that just does, what was intended.
Thanks a lot for the comprehensive documentation.
Richard.

John_B’s picture

Excellent.

I posted my irrelevant answer above in the wrong thread. Sorry about that!

Digit Professionals specialising in Drupal, WordPress & CiviCRM support for publishers in non-profit and related sectors