{"id":19250261,"url":"https://github.com/charcoalphp/user","last_synced_at":"2025-07-15T09:04:53.615Z","repository":{"id":37491314,"uuid":"505906830","full_name":"charcoalphp/user","owner":"charcoalphp","description":"[READ-ONLY] User definition, authentication and authorization","archived":false,"fork":false,"pushed_at":"2024-03-13T15:05:17.000Z","size":203,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-02T17:28:37.601Z","etag":null,"topics":["authentication","authorization","charcoal","php","read-only-repository","user"],"latest_commit_sha":null,"homepage":"https://github.com/charcoalphp/charcoal","language":"PHP","has_issues":false,"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/charcoalphp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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":"2022-06-21T15:45:47.000Z","updated_at":"2022-06-21T16:19:54.000Z","dependencies_parsed_at":"2024-01-13T04:49:46.280Z","dependency_job_id":"91cc280c-8730-4111-aaa8-6c78f10cff11","html_url":"https://github.com/charcoalphp/user","commit_stats":{"total_commits":125,"total_committers":9,"mean_commits":13.88888888888889,"dds":0.5840000000000001,"last_synced_commit":"cc91cc299f7de0946caadbb56ddb0b1b3b04f2dd"},"previous_names":[],"tags_count":58,"template":false,"template_full_name":null,"purl":"pkg:github/charcoalphp/user","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charcoalphp%2Fuser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charcoalphp%2Fuser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charcoalphp%2Fuser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charcoalphp%2Fuser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/charcoalphp","download_url":"https://codeload.github.com/charcoalphp/user/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charcoalphp%2Fuser/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265424333,"owners_count":23762880,"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","authorization","charcoal","php","read-only-repository","user"],"created_at":"2024-11-09T18:16:39.318Z","updated_at":"2025-07-15T09:04:53.567Z","avatar_url":"https://github.com/charcoalphp.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Charcoal User\n=============\n\nThe User package provides abstract tools for defining user models, authenticating and authorizating users from an integration with [Laminas Permissions ACL](https://github.com/laminas/laminas-permissions-acl).\n\n## Installation\n\n```shell\ncomposer require charcoal/user\n```\n\n## Overview\n\n### The User object\n\nAt the core of this module is the definition of a \"User\" object. The contract can be found as `\\Charcoal\\User\\UserInterface`. This interfaces extends `\\Charcoal\\Object\\ContentInterface` (from `charcoal/object`), which extends `\\Charcoal\\Model\\ModelInterface` (from `charcoal/core`).\n\nThe preferred way of using this module is by defining your own User class in your project and extending the provided `\\Charcoal\\User\\AbstractUser` class.\n\nFor quick prototypes or small projects, a full concrete class is provided as `\\Charcoal\\User\\GenericUser`.\n\n#### User properties\n\n| Property                  | Type        | Default     | Description |\n| ------------------------- | ----------- | ----------- | ----------- |\n| **username**              | `string`    | `true`      | …           |\n| **password**              | `string`    | `null`      | …           |\n| **email**                 | `string`    | `null`      | …           |\n| **roles**                 | `string[]`  | `[]`        | ACL roles, which define user permissions. |\n| **last\\_login\\_date**     | `date-time` | `null`      | …           |\n| **last\\_login\\_ip**       | `string`    | `''`        | …           |\n| **last\\_password\\_date**  | `date-time` | `null`      | …           |\n| **last\\_password\\_ip**    | `string`    | `''`        | …           |\n| **login\\_token**          | `string`    | `null`      | …           |\n\n\u003e Note that the `key` of the User is the `username`. Therefore, `id()` returns the username. It must be unique.\n\n**Properties inherited from `Content-Interface`:**\n\n| Property                  | Type        | Default     | Description |\n| ------------------------- | ----------- | ----------- | ----------- |\n| **active**                | `boolean`   | `true`      | …           |\n| **position**              | `number`    | `null`      | …           |\n| **created**               | `date-time` | `null`      | …           |\n| **created\\_by**           | `string`    | `''`        | …           |\n| **last\\_modified**        | `date-time` | `null`      | …           |\n| **last\\_modified\\_by**    | `string`    | `''`        | …           |\n\n### Authentication\n\nTODO\n\n### Authorization\n\nUser authorization is managed with a role-based _Access Control List_ (ACL). Internally, it uses [`laminas/laminas-permissions-acl`](https://github.com/laminas/laminas-permissions-acl) for the ACL logic. It is recommended to read the  [Laminas ACL documentation](https://docs.laminas.dev/laminas-permissions-acl/) to learn more about how it all works.\n\nThere are 2 main concepts that must be managed, either from JSON config files or in the database (which works well with `charcoal/admin`), **roles** and **permissions**.\n\n#### ACL Configuration\n\nTo set up ACL, it is highly recommended to use the `\\Charcoal\\User\\Acl\\Manager`.\n\n#### ACL Example\n\n```json\n{\n    \"acl\": {\n        \"permissions\": {\n            \"superuser\": {\n                \"superuser\": true\n            },\n            \"author\": {\n                \"allowed\": {},\n                \"denied\": {}\n            }\n        }\n    }\n}\n```\n\n```php\nuse Charcoal\\User\\Acl\\Manager as AclManager;\nuse Laminas\\Permissions\\Acl\\Acl;\nuse Laminas\\Permissions\\Acl\\Resource\\GenericResource as AclResource;\n\n$acl = new Acl();\n\n // Add resource for ACL\n$acl-\u003eaddResource(new AclResource($resourceName));\n\n$aclManager = new AclManager([\n    'logger' =\u003e $logger,\n]);\n$aclManager-\u003eloadPermissions($acl, $config['acl.permissions'], $resourceName);\n\n$authorizer = new Authorizer([\n    'logger'   =\u003e $logger,\n    'acl'      =\u003e $acl,\n    'resource' =\u003e $resourceName,\n]);\n\n$isAllowed = $authorizer-\u003euserAllowed($user, [ 'permssion' ]);\n```\n\n## Resources\n\n* [Contributing](https://github.com/charcoalphp/.github/blob/main/CONTRIBUTING.md)\n* [Report issues](https://github.com/charcoalphp/charcoal/issues) and\n  [send pull requests](https://github.com/charcoalphp/charcoal/pulls)\n  in the [main Charcoal repository](https://github.com/charcoalphp/charcoal)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharcoalphp%2Fuser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcharcoalphp%2Fuser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharcoalphp%2Fuser/lists"}