Download the PHP package phantomwatson/cakephp-simple-saml without Composer
On this page you can find all versions of the php package phantomwatson/cakephp-simple-saml. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download phantomwatson/cakephp-simple-saml
More information about phantomwatson/cakephp-simple-saml
Files in phantomwatson/cakephp-simple-saml
Package cakephp-simple-saml
Short Description SimpleSaml plugin for CakePHP
License MIT
Informations about the package cakephp-simple-saml
SimpleSaml plugin for CakePHP
Installation
Until this issue is resolved, SimpleSAML is incompatible with CakePHP's Bake package, so cakephp/bake must be removed before installing.
Then:
Add an authorization policy
- Add an authorization policy class under
/src/Policy
. (example policy)
Update Application.php
- Have the
Application
class implementAuthorizationServiceProviderInterface
-
Add these lines to
Application::bootstrap()
: -
Add
getAuthorizationService()
andgetAuthenticationService()
methods, using the name of your policy class:- Set the value of
tokenField
to the name of the database field to identify users with (e.g.'sso-uuid'
) - Set the value of
dataField
to the name of the field in the data received from the authenticator (e.g.'id'
)
- Set the value of
Update AppController.php
In AppController::initialize()
, load the SimpleSamlComponent
from the plugin:
Uncomment and change the value of authSource
if needed.
Update User model
Have User
entity class
implement IdentityInterface
and add the getIdentifier()
and getOriginalData()
methods to it. (example)
Get SimpleSAML's /www directory ready for being accessed
- Set up a VirtualHost alias (or its equivalent in non-Apache servers) or a symlink for
/vendor/simplesamlphp/simplesamlphp/www
, named something like/simplesaml
- Navigate to
/vendor/simplesamlphp/simplesamlphp
in the command line and run these two commands to download front-end dependencies and set up CSS and JS (this assumes that NodeJS is installed on the server).
Configuration
- Copy the SimpleSAML
/config-templates
directory to/config/simplesaml
at the root of the project - Set the
SIMPLESAMLPHP_CONFIG_DIR
environment variable to the path to this new directory so SimpleSAML can access these config files.- If you're doing this via PHP, you would use
putenv('SIMPLESAMLPHP_CONFIG_DIR=' . CONFIG . 'simplesaml');
- Do not include a trailing slash in the path string
- This can be placed in
/config/bootstrap.php
- If you're doing this via PHP, you would use
- Set
baseurlpath
value to the full URL path to access SimpleSAML's www directory, e.g.'baseurlpath' => 'https://example.com/simplesaml-alias-name/'
- If SimpleSAML's metadata files need to be edited
- Copy the library's
/metadata-templates
directory to/config/simplesaml/metadata
from the project's root - Update the metadatadir value in
/config/simplesaml/config.php
- Copy the library's
Run checks
Open the SimpleSAML web-accessible directory in a browser to confirm that it’s installed and configured correctly.
Using the component
All controllers should now have access to the SimpleSaml
component, which provides these methods:
$this->SimpleSaml->isAuthenticated();
- Returns true if the user is logged in via SimpleSaml$this->SimpleSaml->login($params);
- Starts the authentication process ($params
is documented at\SimpleSAML\Auth\Simple::login()
)$this->SimpleSaml->logout();
- Logs the user out$this->SimpleSaml->getUserAttributes();
- Returns the authenticated user's attributes from the SimpleSaml session, or an empty array if no user is authenticated
All versions of cakephp-simple-saml with dependencies
cakephp/authentication Version ^2.0
cakephp/authorization Version ^2.1
cakephp/cakephp Version ~4.2.0
simplesamlphp/simplesamlphp Version 1.19