Authentication, SSO and SSL: Difference between revisions

Jump to navigation Jump to search
m
Tag: 2017 source edit
Tag: 2017 source edit
Line 59: Line 59:


=== Connect to dolibarr using Openid and the HTTP Basic of Apache ===
=== Connect to dolibarr using Openid and the HTTP Basic of Apache ===
L'idée est d'utiliser deux éléments :  
The idea is to use two elements:
* Le plugin auth_openidc pour Apache  
* The auth_openidc plugin for Apache
* L'authentification HTTP Dolibarr.  
* Dolibarr HTTP authentication.


La procédure va donc nécessiter d'avoir Dolibarr installé avec Apache et le module apache https://github.com/zmartzone/mod_auth_openidc. Ce dernier est souvent directement disponible sur Linux via une commande du gestionnaire de package.
The procedure will therefore require Dolibarr installed with Apache and the apache module https://github.com/zmartzone/mod_auth_openidc. The latter is often directly available on Linux via a package manager command.


La seconde partie va donc être de configurer ce module apache afin d'authentifier les utilisateurs avec le protocole OpenID Connect. Dans le cas général, il vous faudra seulement l'URL des métadata.
The second part will therefore be to configure this apache module in order to authenticate users with the OpenID Connect protocol. In the general case, you will only need the metadata URL.
Voici un exemple de configuration apache pour de l'OpenID avec AzuereAD:
Here is an example apache configuration for OpenID with AzureAD:


<syntaxhighlight lang="ini">
<syntaxhighlight lang="ini">
OIDCProviderMetadataURL https://login.microsoftonline.com/your-tenant-id/v2.0/.well-known/openid-configuration
OIDCProviderMetadataURL https://login.microsoftonline.com/your-tenant-id/v2.0/.well-known/openid-configuration
OIDCClientID youropenidclient  
OIDCClientID youropenidclient
OIDCClientSecret yoursecret  
OIDCClientSecret yoursecret
OIDCCryptoPassphrase randomstring  
OIDCCryptoPassphrase randomstring
OIDCRedirectURI https://mydolibarr.exemple.com/sso_redirect  
OIDCRedirectURI https://mydolibarr.example.com/sso_redirect
OIDCScope "openid email profile"  
OIDCScope "openid email profile"
OIDCRemoteUserClaim email ^(.*)@  
OIDCRemoteUserClaim email ^(.*)@


<Directory /var/ht>  
<Directory /home/.../htdocs>


# Docroot  
# Docroot
AuthType openid-connect  
AuthType openid-connect
Require valid-user  
Require valid-user
Require env no-auth  
Require env no-auth


</Directory>  
</Directory>


</syntaxhighlight>
</syntaxhighlight>




Dans l'exemple ci-dessus, les informations à rentrer dans OIDCProviderMetadataURL, OIDCClientID et OIDCClientSecret sont communiquées par votre fournisseur OpenID Connect.  
In the example above, the information to enter in OIDCProviderMetadataURL, OIDCClientID and OIDCClientSecret is provided by your OpenID Connect provider.


La variable '''OIDCRemoteUserClaim''' définie quel "claim" sera utilisé pour le nom d'utilisateur. Dans notre exemple de configuration, nous considérons que le nom d'utilisateur qui sera utilisé dans Dolibarr est ce qui précède l'arobase dans l'adresse email.
The '''OIDCRemoteUserClaim''' variable defines which "claim" will be used for the username. In our configuration example, we consider that the username that will be used in Dolibarr is what precedes the at sign in the email address.


Après cette manipulation, vous devriez être invité à vous connecter à votre compte OpenID Connect pour accéder à votre installation Dolibarr. Cependant, il reste à indiquer à Dolibarr qu'il doit utiliser le nom d'utilisateur défini par Apache. C'est dans le fichier '''conf/conf.php''' que nous allons réaliser cette manipulation. Ajoutez à la fin du fichier la ligne suivante :  
After this manipulation, you should be prompted to log in to your OpenID Connect account to access your Dolibarr installation. However, it remains to indicate to Dolibarr that it must use the username defined by Apache. It is in the '''conf/conf.php''' file that we will perform this manipulation. Add the following line at the end of the file:


<syntaxhighlight lang="ini">
<syntaxhighlight lang="ini">
$dolibarr_main_authentication='http';  
$dolibarr_main_authentication='http';
</syntaxhighlight>
</syntaxhighlight>


Votre authentification OpenID Connect est maintenant pleinement fonctionnelle ! Attention toutefois, il peut y avoir des ajustements à faire pour que cette configuration fonctionne avec certains modules.  
Your OpenID Connect authentication is now fully functional! Be careful however, there may be adjustments to make for this configuration to work with certain modules.


Par exemple, l'usage de WebDav dans Dolibarr (pages /dav/*) n'est pas compatible avec cette configuration, ou encore l'accès aux pages publiques (pages /public/*) ou encore l'accès aux API (pages /api/*), se retrouveront bloquer par la demande d'authentification mise en place. Pour éviter cela, il vous faut aussi exclure les chemins qui ne doivent pas être protégé par l'authentification Apache pour OpenID qui défini le Directory protégé. Voici un exemple de fichier de configuration de votre virtual host apache pour pouvoir utiliser l'authentification "http" sans bloquer l'accès aux pages publiques (décommenter la section sous "# To restrict access by a HTTP basic auth" dans cet exemple):
For example, the use of WebDav in Dolibarr (pages /dav/*) is not compatible with this configuration, or access to public pages (pages /public/*) or access to APIs (pages /api/*), will be blocked by the authentication request put in place. To avoid this, you must also exclude the paths which should not be protected by the Apache authentication for OpenID which defines the protected Directory. Here is an example configuration file of your apache virtual host to be able to use "http" authentication without blocking access to public pages (retrieve the exclusion under the line "# Leaving /public and /api, /dav, .well_known..." in this example):


https://github.com/Dolibarr/dolibarr/blob/develop/dev/setup/apache/virtualhost
https://github.com/Dolibarr/dolibarr/blob/develop/dev/setup/apache/virtualhost


En adaptant plus loin cette configuration, est est aussi possible d'utiliser l'authentification ActiveDirectory et d'autres services d'authentification.
By further adapting this configuration, it is also possible to use Active Directory authentication and other authentication services.
<br />
<br />

Navigation menu