php-sso php-sso

Install with Composer

Run php-sso on your own PHP and web server.

composer create-project --no-dev php-sso/php-sso my-sso

That downloads the application into my-sso/ and installs its libraries from Packagist. The files are yours. You need PHP 8.3 or later with the openssl and pdo_sqlite extensions (or pdo_mysql or pdo_pgsql for another database), and Composer 2.

The web server #

Point the document root at my-sso/public and send every request that is not a file to index.php. The server must pass the Authorization header to PHP, because clients authenticate to /token with it.

Apache:

<VirtualHost *:443>
    DocumentRoot /var/www/my-sso/public
    FallbackResource /index.php
    SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
    <Directory /var/www/my-sso/public>
        Options -Indexes
        AllowOverride None
        Require all granted
    </Directory>
</VirtualHost>

nginx with PHP-FPM:

server {
    listen 443 ssl;
    root /var/www/my-sso/public;
    location / { try_files $uri /index.php$is_args$args; }
    location = /index.php {
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root/index.php;
        fastcgi_pass unix:/run/php/php-fpm.sock;
    }
    location ~ \.php$ { return 404; }
}

Settings #

The settings are environment variables, the same as for the Docker image (see Production and configuration). Give them to the web server or to PHP-FPM; PHP-FPM clears the environment unless the pool has clear_env = no (or lists each variable with env[NAME] = ...).

my-sso/var/ must be writable by the web server user. It holds the SQLite database, the keys and a cache. Keep it out of backups you do not trust, and in the ones you do.

The first time it runs with an empty database, it creates the administrator admin with the password in ADMIN_PASSWORD.

Run bin/maintenance from cron, for example hourly, to remove expired sessions and tokens:

0 * * * * cd /var/www/my-sso && php bin/maintenance

Your own look #

Set SSO_THEME_DIR to a folder of yours, outside the project, so that an upgrade does not touch it: see Theming.

Upgrading #

The project is an application you own, so composer update only updates the libraries it uses, not the application. To move to a new version, create a new project of that version next to the old one, move var/ across (it holds your data and keys) and use the same environment variables and theme folder. Keep your own changes out of the application’s files and this stays a copy and a restart. For a setup you would rather not maintain this way, use the Docker image.

Edit this page on GitHub