PHP code example of padosoft / laravel-iam-directory
1. Go to this page and download the library: Download padosoft/laravel-iam-directory library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
padosoft / laravel-iam-directory example snippets
return [
// Target organization for provisioning (null = global users without a membership).
'organization_id' => env('IAM_DIRECTORY_ORG'),
'jit' => [
'm:tenant_member'], // bootstrap roles (full_key)
'group_mapping' => true,
// Roles that can NEVER be granted via group mapping (manual-only):
'protected_roles' => ['iam:super_admin'],
],
// Directory group → IAM role(s). Key = full DN or short CN (case-insensitive).
'group_map' => [
'cn=warehouse-admins,ou=groups,dc=acme,dc=com' => 'warehouse:admin',
'developers' => ['app:developer', 'app:deployer'],
],
];
use Padosoft\Iam\Directory\DirectoryAuthenticator;
$outcome = app(DirectoryAuthenticator::class)->login($username, $password);
match ($outcome->status) {
'provisioned', 'linked' => Auth::loginUsingId($outcome->userId), // roles already synced
'pending' => back()->withErrors(__("Access pending: {$outcome->reason}")),
'conflict' => back()->withErrors(__('That email belongs to an existing account — manual link
use Padosoft\Iam\Directory\Contracts\DirectoryConnector;
use Padosoft\Iam\Directory\DirectoryUser;
final class CsvDirectoryConnector implements DirectoryConnector
{
public function authenticate(string $username, string $password): ?DirectoryUser
{
// verify credentials; return null (= denied) on failure — never throw an opaque error
return new DirectoryUser(
username: $username,
email: '[email protected]',
emailVerified: true,
groups: ['developers'],
);
}
public function find(string $username): ?DirectoryUser { /* lookup without credentials */ }
}