{"id":15480070,"url":"https://github.com/tyler36/ldap","last_synced_at":"2025-03-28T14:28:27.242Z","repository":{"id":57074155,"uuid":"244540173","full_name":"tyler36/ldap","owner":"tyler36","description":null,"archived":false,"fork":false,"pushed_at":"2022-12-13T05:54:54.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-19T04:30:27.048Z","etag":null,"topics":["laravel"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tyler36.png","metadata":{"files":{"readme":"readme.md","changelog":"changelog.md","contributing":"contributing.md","funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-03T04:19:19.000Z","updated_at":"2022-10-20T00:40:00.000Z","dependencies_parsed_at":"2023-01-28T07:40:23.645Z","dependency_job_id":null,"html_url":"https://github.com/tyler36/ldap","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tyler36%2Fldap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tyler36%2Fldap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tyler36%2Fldap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tyler36%2Fldap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tyler36","download_url":"https://codeload.github.com/tyler36/ldap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246045272,"owners_count":20714747,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["laravel"],"created_at":"2024-10-02T04:40:28.778Z","updated_at":"2025-03-28T14:28:27.215Z","avatar_url":"https://github.com/tyler36.png","language":"PHP","readme":"# Ldap\n\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Total Downloads][ico-downloads]][link-downloads]\n[![Build Status][ico-travis]][link-travis]\n[![StyleCI][ico-styleci]][link-styleci]\n\nThis package is designed to offer a quick authentication process via LDAP.\nThe example below describes a setup that authenticates using a ```username``` and ```password`` combination.\n\n## Installation\n\nVia Composer\n\n``` bash\n$ composer require tyler36/ldap\n```\n\n## Usage\n1. Publish the config file\n\n```php\n$ php artisan vendor:publish --provider=\"Tyler36\\Ldap\\LdapServiceProvider\"\n```\n\n\n2. Update ```.ENV``` with server settings\n\n```\nLDAP_HOST=\nLDAP_USERNAME=\nLDAP_USERNAME_PREFIX=\nLDAP_FILTER=\nLDAP_DOMAIN_COMP=\nLDAP_COMMON_NAME=\nLDAP_BASE_DN=\n```\n\n3. Add a username column to your user migration.\n\n```\n$table-\u003estring('username')-\u003eunique();\n```\n\n4. Update login view by replacing ```email``` with ```username```. Remember to remove the ```type=\"email\"```\n\n```\n\u003cinput id=\"username\"\n    class=\"shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline{{ $errors-\u003ehas('username') ? ' border-red-500' : '' }}\"\n    name=\"username\" value=\"{{ old('username') }}\" required autofocus\u003e\n```\n\n\n###  Laravel 7\n5. Update your ```LoginController``` file. Remember to import ```Tyler36\\Ldap\\LdapAuthenticator;```\n\n```php\n/**\n  * Get the login username to be used by the controller. ['email']\n  *\n  * @return string\n  */\npublic function username()\n{\n    return config('ldap.username');\n}\n\n/**\n * Attempt to log the user into the application.\n *\n * @param \\Illuminate\\Http\\Request $request\n *\n * @return mixed\n */\nprotected function attemptLogin(Request $request)\n{\n    // This is where authentication happens. It SHOULD return an array containing the user\n    $ldap     = new LdapAuthenticator($request);\n    $ldapUser = $ldap-\u003eauthenticate();\n    if (!$ldapUser || 'array' !== gettype($ldapUser)) {\n        return $ldapUser;\n    }\n\n    // Un-comment the following to see details of the user array\n    // dd($ldapUser)\n\n    // Update or create a new user based on the username. The second array determines how to populate new users.\n    $user   = User::updateOrCreate(\n        [$this-\u003eusername() =\u003e $request-\u003eget('username')],\n        [\n            $this-\u003eusername() =\u003e $request-\u003eget('username'),\n            'name'            =\u003e optional($ldapUser)['displayname'][0],\n            'email'           =\u003e optional($ldapUser)['mail'][0],\n        ]\n    );\n\n    auth()-\u003elogin($user);\n}\n```\n\n### laravel/breeze\n- Replace the rules section in `app/Http/Requests/Auth/LoginRequest.php`.\n```php\n    public function rules()\n    {\n        return config('ldap.rules');\n    }\n```\n\n\n## Change log\n\nPlease see the [changelog](changelog.md) for more information on what has changed recently.\n\n## Testing\n\n``` bash\n$ composer test\n```\n\n## Contributing\n\nPlease see [contributing.md](contributing.md) for details and a todolist.\n\n## Security\n\nIf you discover any security related issues, please email author email instead of using the issue tracker.\n\n## Credits\n\n- [author name][link-author]\n- [All Contributors][link-contributors]\n\n## License\n\nlicense. Please see the [license file](license.md) for more information.\n\n[ico-version]: https://img.shields.io/packagist/v/tyler36/ldap.svg?style=flat-square\n[ico-downloads]: https://img.shields.io/packagist/dt/tyler36/ldap.svg?style=flat-square\n[ico-travis]: https://img.shields.io/travis/tyler36/ldap/master.svg?style=flat-square\n[ico-styleci]: https://styleci.io/repos/12345678/shield\n\n[link-packagist]: https://packagist.org/packages/tyler36/ldap\n[link-downloads]: https://packagist.org/packages/tyler36/ldap\n[link-travis]: https://travis-ci.org/tyler36/ldap\n[link-styleci]: https://styleci.io/repos/12345678\n[link-author]: https://github.com/tyler36\n[link-contributors]: ../../contributors\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftyler36%2Fldap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftyler36%2Fldap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftyler36%2Fldap/lists"}