{"id":22656857,"url":"https://github.com/libreworks/caridea-auth","last_synced_at":"2025-03-29T08:11:13.074Z","repository":{"id":33172672,"uuid":"36813784","full_name":"libreworks/caridea-auth","owner":"libreworks","description":":fried_shrimp: Caridea is a miniscule PHP application library. This is a shrimpy authentication library.","archived":false,"fork":false,"pushed_at":"2018-01-06T20:52:36.000Z","size":78,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-03T21:47:33.747Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/libreworks.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}},"created_at":"2015-06-03T15:45:48.000Z","updated_at":"2016-11-17T19:49:56.000Z","dependencies_parsed_at":"2022-08-17T21:15:28.901Z","dependency_job_id":null,"html_url":"https://github.com/libreworks/caridea-auth","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libreworks%2Fcaridea-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libreworks%2Fcaridea-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libreworks%2Fcaridea-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libreworks%2Fcaridea-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/libreworks","download_url":"https://codeload.github.com/libreworks/caridea-auth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246156419,"owners_count":20732397,"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":[],"created_at":"2024-12-09T10:16:42.523Z","updated_at":"2025-03-29T08:11:13.055Z","avatar_url":"https://github.com/libreworks.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# caridea-auth\nCaridea is a miniscule PHP application library. This shrimpy fellow is what you'd use when you just want some helping hands and not a full-blown framework.\n\n![](http://libreworks.com/caridea-100.png)\n\nThis is its authentication component. It provides a way to authenticate principals and store their identity. It will broadcast authentication events for any listeners. It works with any implementation of [PSR-7](http://www.php-fig.org/psr/psr-7/).\n\nIncluded are three adapters for authentication through MongoDB, PDO, and X.509 client SSL certificates. You can easily write your own adapter for other authentication sources like IMAP, LDAP, or OAuth2.\n\n[![Packagist](https://img.shields.io/packagist/v/caridea/auth.svg)](https://packagist.org/packages/caridea/auth)\n[![Build Status](https://travis-ci.org/libreworks/caridea-auth.svg)](https://travis-ci.org/libreworks/caridea-auth)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/libreworks/caridea-auth/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/libreworks/caridea-auth/?branch=master)\n[![Code Coverage](https://scrutinizer-ci.com/g/libreworks/caridea-auth/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/libreworks/caridea-auth/?branch=master)\n\n## Installation\n\nYou can install this library using Composer:\n\n```console\n$ composer require caridea/auth\n```\n\n* The master branch (version 3.x) of this project requires PHP 7.1 and depends on `caridea/event`, `caridea/session`, `psr/log`, and `psr/http-message`.\n* Version 2.x of this project requires PHP 7.0 and depends on `caridea/event`, `caridea/session`, `psr/log`, and `psr/http-message`.\n* Version 1.x of this project requires PHP 5.5 and depends on `caridea/event`, `caridea/session`, `psr/log`, and `psr/http-message`.\n\n## Compliance\n\nReleases of this library will conform to [Semantic Versioning](http://semver.org).\n\nOur code is intended to comply with [PSR-1](http://www.php-fig.org/psr/psr-1/), [PSR-2](http://www.php-fig.org/psr/psr-2/), and [PSR-4](http://www.php-fig.org/psr/psr-4/). If you find any issues related to standards compliance, please send a pull request!\n\n## Documentation\n\n* Head over to [Read the Docs](http://caridea-auth.readthedocs.io/en/latest/)\n\n## Examples\n\nJust a few quick examples.\n\n### Login\n\n```php\n// Let's say $session is a \\Caridea\\Session\\Session, such as \\Caridea\\Session\\NativeSession\n// Let's say $publisher is a \\Caridea\\Event\\Publisher, such as \\Caridea\\Container\\Objects\n$service = new \\Caridea\\Auth\\Service($session, $publisher);\n\n// Let's say $collection is a \\MongoCollection\n$adapter = new \\Caridea\\Auth\\Adapter\\Mongo($collection, 'username', 'password');\n\n// Let's say $request is a \\Psr\\Http\\Message\\RequestInterface\nif ($service-\u003elogin($request, $adapter)) {\n    $principal = $service-\u003egetPrincipal();\n    $username = $principal-\u003egetUsername();\n    $details = $principal-\u003egetDetails());\n\n    // $details = [\n    //    'id' =\u003e '1234567890',\n    //    'ua' =\u003e 'Mozilla/5.0',\n    //    'ip' =\u003e '192.168.1.1'\n    // ];\n}\n```\n\nUpon login, `Service` will broadcast a `Caridea\\Auth\\Event\\Login` if `$publisher` has been set.\n\n### Resume\n\n```php\n// Let's say $session is a \\Caridea\\Session\\Session, such as \\Caridea\\Session\\NativeSession\n// Let's say $publisher is a \\Caridea\\Event\\Publisher, such as \\Caridea\\Container\\Objects\n$service = new \\Caridea\\Auth\\Service($session, $publisher);\n\nif ($service-\u003eresume()) {\n    $principal = $service-\u003egetPrincipal();\n}\n```\n\nUpon resume, `Service` will broadcast a `Caridea\\Auth\\Event\\Resume` if `$publisher` has been set.\n\n### Logout\n\n```php\n// Let's say $session is a \\Caridea\\Session\\Session, such as \\Caridea\\Session\\NativeSession\n// Let's say $publisher is a \\Caridea\\Event\\Publisher, such as \\Caridea\\Container\\Objects\n$service = new \\Caridea\\Auth\\Service($session, $publisher);\n\n// Let's say $collection is a \\MongoCollection\n$adapter = new \\Caridea\\Auth\\Adapter\\Mongo($collection, 'username', 'password');\n\nif ($service-\u003elogout()) {\n    // anonymous!\n}\n```\n\nUpon login, `Service` will broadcast a `Caridea\\Auth\\Event\\Logout` if `$publisher` has been set.\n\n### Login Timeout\n\nA component has been included, the `TimeoutListener` which can be registered in a `Caridea\\Event\\Publisher`.\n\nIt listens for `Caridea\\Auth\\Event\\Resume` and will log out a user if an authenticated session has either gone on too long or has been idle for too long.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibreworks%2Fcaridea-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flibreworks%2Fcaridea-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibreworks%2Fcaridea-auth/lists"}