Jump to content

Sharing authorization between ProcessWire installations


Ivan Gretsky
 Share

Recommended Posts

Good day everyone! Hope you all safe and healthy!

I am thinking about a rather ambitious project (for me). It should consist of a number of ProcessWire based sites which will serve the same group of registered users. I need to make the user registration a one time process. And I need to share the user data across the sites. Single sign-in is also in plans. I am thinking about placing the user info and all the user data in one installation and somehow sharing it between all the other. But I am open to any suggestions.

Please share your thoughts and experience on the topic. I am only in the very beginning and trying to estimate is it even doable.

Link to comment
Share on other sites

Here is the customized module. You will need to run:

composer require predis/predis

 to use it.

Add the following settings to your `config.php`

    $config->redis_session_server_ip     = '127.0.0.1';
    $config->redis_session_server_port   = 6379;
    $config->redis_session_server_db     = 0;
    $config->redis_session_server_prefix = "PHPSESSID:";
    $config->redis_session_server_ttl    = 1800;

Change the session prefix to whatever you want.

Once installed, you can then share the same session (using the prefix) across multiple sites as long as those sites are reading/writing to the same redis server.

SessionHandlerRedis.zip

  • Like 2
Link to comment
Share on other sites

Cool stuff, @Rudy!

May I ask a few additional questions?

  1. Do you limit the ability to login/register to only one installation? How?
  2. You do not re-create users on all installations, do you?
  3. Are you using user info from one installation in all the others? I mean something like $user->hasRole() and things like finding users? How? Are you using API call to other instances?
Link to comment
Share on other sites

@Ivan Gretsky my usage is slightly different than yours. It's more for running a website on a multiple servers through a load-balancer. I have my database running on AWS RDS and a separate Redis server.

I think you should:
- limit the login/register to only one installation
- use either database or redis to store your sessions
- use AppAPI module to make REST calls from the primary site

  • Like 2
Link to comment
Share on other sites

Thanks for the great suggestions! Will make my mind around it and try.

If anyone has other ideas or experience on the topic, please share. I did not consider REST API for using $user data from the main registration site on the other installations (and do not have expertise in this). Are there other (simpler? more PW-ish?) ways to do it?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...