Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a way to override LdapUser. fix #1062 #1064

Merged
merged 2 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion INSTALL.fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ ajouter cette ligne dans le crontab
Si vous souhaitez connecter Mercator avec un Active Diretory ou un serveur LDAP,
dans le fichier .env, mettez les paramètres de connexion en décommentant les lignes :

# Plusieurs types possibles : AD, OpenLDAP, FreeIPA, DirectoryServer
# Plusieurs types possibles : AD, OpenLDAP, FreeIPA, DirectoryServer, Custom
LDAP_TYPE="AD"
# If true, LDAP actions will be written to the application's default log file
LDAP_LOGGING=true
Expand All @@ -198,6 +198,24 @@ dans le fichier .env, mettez les paramètres de connexion en décommentant les l

Retrouvez une documentation plus complète sur la configuration de [LdapRecord](https://ldaprecord.com/docs/laravel/v2/configuration/#using-an-environment-file-env).

Si vous choisissez le type Custom, vous devez fournir une classe LdapUserCustom dans le fichier `app/Ldap/LdapUserCustom.php`, par exemple :

```php
<?php

namespace App\Ldap;

use LdapRecord\Models\OpenLDAP\User as OpenLdapUser;
use LdapRecord\Models as Models;

class LdapUserCustom extends OpenLdapUser
{
public function groups(): Models\Relations\HasMany {
return $this->hasMany(Models\OpenLDAP\Group::class, 'memberUid', 'uid');
}
}
```

## Configuration de Keycloak (optionel)

Pour configurer Keycloak, suivez ces étapes :
Expand Down
21 changes: 20 additions & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ add this line in the crontab

Modify .env file, and uncomment LDAP configuration :

# Several possible types: AD, OpenLDAP, FreeIPA, DirectoryServer
# Several possible types: AD, OpenLDAP, FreeIPA, DirectoryServer, Custom
LDAP_TYPE="AD"
# If true, LDAP's actions will be log into
LDAP_LOGGING=true
Expand All @@ -198,6 +198,25 @@ Modify .env file, and uncomment LDAP configuration :

Find more complete documentation on LDAP configuration [here](https://ldaprecord.com/docs/laravel/v2/configuration/#using-an-environment-file-env).

If you choose Custom, you have to provide a LdapUserCustom class in `app/Ldap/LdapUserCustom.php` file, ie :

```php
<?php

namespace App\Ldap;

use LdapRecord\Models\OpenLDAP\User as OpenLdapUser;
use LdapRecord\Models as Models;

class LdapUserCustom extends OpenLdapUser
{
public function groups(): Models\Relations\HasMany {
return $this->hasMany(Models\OpenLDAP\Group::class, 'memberUid', 'uid');
}
}
```


## KeyCloak Configuration (optional)

To configure Keycloak, follow these steps:
Expand Down
6 changes: 6 additions & 0 deletions app/Ldap/LdapUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
use LdapRecord\Models\OpenLDAP\User as OpenLdapUser;

switch (strtolower(config('app.ldap_type', 'AD'))) {
case 'custom':
class LdapUser extends LdapUserCustom
{
}
break;
// no break
case 'openldap':
class LdapUser extends OpenLdapUser
{
Expand Down