In the index.php page of the project, create the few lines :
require ("domframework/authentication.php");
$route = new Domframework\Route;
$authentication = new Domframework\Authentication ($route);
$authentication->appName = "Application !";
$authentication->authMethods = array ("ldap");
$authentication->authServers = array ("authldap"=>array (
),
);
$authentication->routes ();
In the REST part, add :
$route->output = "rest";
$route->viewClass ='\views\rest';
try
{
$authREST = $authentication->verifAuthREST ();
}
catch (\Exception $e)
{
$route->error ($e);
}
In the HTML part, add :
$route->output = "html";
$route->viewClass = '\views\general';
try
{
$authHTML = $authentication->verifAuthHTML ();
}
catch (\Exception $e)
{
$route->error ($e);
}
Namespace Domframework
/** All the authentication protocol
/** The application Name displayed on authentication page
/** The authentication methods. Can be ldap, sympa...
/** The authentication servers configuration array ("authXXXX" => array ( array ("ldapserver" => "ldaps://server.domain.fr", "ldapport" => 636, "ldaptimeout" => 5, "ldapauth" => "uid=XXX,dc=domain,dc=fr", "ldappwd" => "XXX", "ldapbase" => "", "ldapfilter" => "(mail=%s)", "ldapfield" => "mail", "ldapfiltersearch" => "(objectClass=inetOrgPerson)" ), ), );
/** The debug of the authentication methods
/** The html authentication methods. Can be : post, session, http, shibboleth, jwt The "post" is already used when using verifAuthLoginPage method (usually only in authentication page)
/** The class and method to use to log the errors
/** Number of authentication maximum by minute
/** Directory to store the ratelimit files
/** The rest authentication methods. Can be post, session, http, shibboleth, jwt Attention : session case = CSRF !
/**
The constructor
@param object $route
The route object
/**
Return the JSON Web Token
@param string|array $auth
The user data to store in JSON Web Token cache.
The $this->authServers["authjwt"]["algorithm"],
$this->authServers["authjwt"]["cipherKey"] and
$this->authServers["authjwt"]["serverKey"] can be set
/** Setter/Getter for debug@param integer|null $debug
The debug value to get/set@return
integer|self the actual value or this
/**
Disconnect the user
@param string|null $url
The url to be redirected after a valid
logout
/**
Display the login page
@param string|null $url
The url to be redirected after a valid
authentication
/** Add the authentication routes to the routing model for HTML authentication. Not needed if using shibboleth, HTTP auth...
/**
Check all the others pages of the site
@return
array The details provided by the authentication mecanism
/**
Check the authentication page
@param string|null $url
The url to be redirected after a valid
authentication
/** Check all the REST API@param boolean|null $savePassword
return the user password if the authentication is valid@return
array The details provided by the authentication mecanism