{"id":19374716,"url":"https://github.com/gyselroth/micro-auth","last_synced_at":"2025-04-23T18:32:06.222Z","repository":{"id":44678020,"uuid":"111523058","full_name":"gyselroth/micro-auth","owner":"gyselroth","description":"Lightweight authentication library","archived":false,"fork":false,"pushed_at":"2024-10-30T15:57:54.000Z","size":112,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-30T16:37:03.705Z","etag":null,"topics":["authentication","ldap","openid-connect","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gyselroth.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-11-21T08:49:55.000Z","updated_at":"2019-04-12T14:13:41.000Z","dependencies_parsed_at":"2024-10-19T12:00:14.742Z","dependency_job_id":null,"html_url":"https://github.com/gyselroth/micro-auth","commit_stats":{"total_commits":21,"total_committers":1,"mean_commits":21.0,"dds":0.0,"last_synced_commit":"9c08a6afc94f76635fb7d29f56fb8409e383677f"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gyselroth%2Fmicro-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gyselroth%2Fmicro-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gyselroth%2Fmicro-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gyselroth%2Fmicro-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gyselroth","download_url":"https://codeload.github.com/gyselroth/micro-auth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223932207,"owners_count":17227272,"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":["authentication","ldap","openid-connect","php"],"created_at":"2024-11-10T08:35:56.824Z","updated_at":"2024-11-10T08:35:56.878Z","avatar_url":"https://github.com/gyselroth.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lightweight authentication library\n\n[![Build Status](https://travis-ci.org/gyselroth/micro-auth.svg?branch=master)](https://travis-ci.org/gyselroth/micro-auth)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/gyselroth/micro-auth/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/gyselroth/micro-auth/?branch=master)\n[![Latest Stable Version](https://img.shields.io/packagist/v/gyselroth/micro-auth.svg)](https://packagist.org/packages/gyselroth/micro-auth)\n[![GitHub release](https://img.shields.io/github/release/gyselroth/micro-auth.svg)](https://github.com/gyselroth/micro-auth/releases)\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/gyselroth/micro-auth/master/LICENSE)\n\n## Description\nThis is a lightweight authentication library. It is adapter based and comes with support for LDAP and OpenID-connect. \nIt can handle multiple adapter of the same or different types. \nThis library contains no storage mechanism. If you wish to store the authentication you need to store the identity object in your sessesion storage.\n\n## Requirements\nThe library is only \u003e= PHP7.1 compatible.\n\n## Download\nThe package is available at packagist: https://packagist.org/packages/gyselroth/micro-auth\n\nTo install the package via composer execute:\n```\ncomposer require gyselroth/micro-auth\n```\n\n## Documentation\n\n### Simple example usage\n\nCreate authentication instance and inject an LDAP and OpenID-connect adapter:\n\n```php\nuse Micro\\Auth;\n\n$logger = new \\My\\Psr\\Logger()\n$auth = new Auth\\Auth(\\Psr\\Log\\LoggerInterface $logger);\n$auth-\u003einjectAdapter(new Auth\\Adapter\\Basic\\Ldap(new Auth\\Ldap([\n    'uri' =\u003e 'ldap://myldap.local:398',\n    'binddn' =\u003e 'cn=admin,dc=test,dc=com',\n    'bindpw' =\u003e '1234',\n    'basedn' =\u003e 'dc=test,dc=com',\n    'tls' =\u003e true\n]), $logger, [\n    'account_filter' =\u003e '(\u0026(objectClass=posixAccount)(uid=%s))'\n]), 'my_ldap_server');\n\n$auth-\u003einjectAdapter(new Auth\\Adapter\\Oidc([\n    'provider_url' =\u003e 'https://accounts.google.com',\n    'identity_attribute' =\u003e 'email'\n], $logger), 'google_oidc_server');\n\nif($auth-\u003erequireOne()) {\n    $identity = $auth-\u003egetIdentity();\n    printf('Hello %s', $identity-\u003egetIdentifier());\n} else {\n    //Authentication failed\n}\n```\n\n### Define attribute map\n\nSo far so good but usually just authenticate is not enaugh, mostly you like to request user attributes of a given identity.\nLet us create an attribute map for our ldap server `my_ldap_server`.\n\n```php\nuse Micro\\Auth;\n\n$auth-\u003einjectAdapter(new Auth\\Adapter\\Basic\\Ldap(new Auth\\Ldap([\n    'uri' =\u003e 'ldap://myldap.local:398',\n    'binddn' =\u003e 'cn=admin,dc=test,dc=com',\n    'bindpw' =\u003e '1234',\n    'basedn' =\u003e 'dc=test,dc=com',\n    'tls' =\u003e true\n]), $logger, [\n    'account_filter' =\u003e '(\u0026(objectClass=posixAccount)(uid=%s))',\n    'attribute_map' =\u003e [\n        'firstname' =\u003e [\n            'attr' =\u003e 'firstname',\n            'type' =\u003e 'string',\n        ],\n        'lastname' =\u003e [\n            'attr' =\u003e 'surname',\n            'type' =\u003e 'string',\n        ],\n        'mail' =\u003e [\n            'attr' =\u003e 'mail',\n            'type' =\u003e 'string'\n        ]\n    ]\n]), 'my_ldap_server');\n\nif($auth-\u003erequireOne()) {\n    $attributes = $auth-\u003egetIdentity()-\u003egetAttributes();\n    var_dump($attributes);\n} else {\n    //Authentication failed\n}\n```\n\nGiven that, you can define an attribute map for each authentication adapter and map all attributes to the same attribute names you would like to use.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgyselroth%2Fmicro-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgyselroth%2Fmicro-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgyselroth%2Fmicro-auth/lists"}