31,003
edits
m (→http) 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 === | ||
The idea is to use two elements: | |||
* | * The auth_openidc plugin for Apache | ||
* | * Dolibarr HTTP authentication. | ||
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. | |||
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. | |||
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. | OIDCRedirectURI https://mydolibarr.example.com/sso_redirect | ||
OIDCScope "openid email profile" | OIDCScope "openid email profile" | ||
OIDCRemoteUserClaim email ^(.*)@ | OIDCRemoteUserClaim email ^(.*)@ | ||
<Directory / | <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> | ||
In the example above, the information to enter in OIDCProviderMetadataURL, OIDCClientID and OIDCClientSecret is provided by your OpenID Connect provider. | |||
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. | |||
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> | ||
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. | |||
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 | ||
By further adapting this configuration, it is also possible to use Active Directory authentication and other authentication services. | |||
<br /> | <br /> | ||