{"id":22702501,"url":"https://github.com/vielhuber/simpleauth","last_synced_at":"2026-03-15T02:03:26.360Z","repository":{"id":57077895,"uuid":"67736477","full_name":"vielhuber/simpleauth","owner":"vielhuber","description":"🔒 Simple php authentication library. 🔒","archived":false,"fork":false,"pushed_at":"2024-04-27T23:25:08.000Z","size":44,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-15T20:25:15.756Z","etag":null,"topics":["authentication","bcrypt","jwt","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vielhuber.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-08T20:06:48.000Z","updated_at":"2023-07-27T11:38:46.000Z","dependencies_parsed_at":"2023-02-08T16:16:33.028Z","dependency_job_id":null,"html_url":"https://github.com/vielhuber/simpleauth","commit_stats":null,"previous_names":[],"tags_count":36,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vielhuber%2Fsimpleauth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vielhuber%2Fsimpleauth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vielhuber%2Fsimpleauth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vielhuber%2Fsimpleauth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vielhuber","download_url":"https://codeload.github.com/vielhuber/simpleauth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229019413,"owners_count":18007169,"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","bcrypt","jwt","php"],"created_at":"2024-12-10T07:13:44.079Z","updated_at":"2026-03-15T02:03:26.292Z","avatar_url":"https://github.com/vielhuber.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🔒 simpleauth 🔒\n\nsimpleauth is a simple php based authentication library.\n\nit leverages:\n\n-   json web tokens\n-   bcrypted passwords\n-   full api\n\n## installation\n\ninstall once with composer:\n\n```\ncomposer require vielhuber/simpleauth\n```\n\nnow simply create the following files in a new folder called `auth` in your public directory:\n\n#### /auth/index.php\n\n```php\n\u003c?php\nrequire_once __DIR__ . '/../vendor/autoload.php';\nuse vielhuber\\simpleauth\\simpleauth;\n$auth = new simpleauth(__DIR__ . '/../.env');\nif (php_sapi_name() !== 'cli') {\n    $auth-\u003eapi();\n} elseif (@$argv[1] === 'migrate') {\n    $auth-\u003emigrate();\n} elseif (@$argv[1] === 'seed') {\n    $auth-\u003eseed();\n}\n```\n\n#### /auth/.htaccess\n\n```.htaccess\nRewriteEngine on\nRewriteCond %{HTTP:Authorization} ^(.*)\nRewriteRule .* - [e=HTTP_AUTHORIZATION:%1]\nRewriteCond %{REQUEST_FILENAME} !-f\nRewriteCond %{REQUEST_FILENAME} !-d\nRewriteRule ^.*$ /auth/index.php [L,QSA]\n```\n\n#### /.env\n\n```.env\nDB_CONNECTION=mysql\nDB_HOST=127.0.0.1\nDB_PORT=3306\nDB_DATABASE=simpleauth\nDB_USERNAME=root\nDB_PASSWORD=root\nJWT_TABLE=users\nJWT_LOGIN=email\nJWT_TTL=30\nJWT_SECRET=I2hkRtw6t8Yg9Wvlg99Nij23Bvdm0n0L4UPkVC33a7rMo5EQGlnIv79LAOIMIxE\nBASE_URL=http://simpleauth.local.vielhuber.de\n```\n\nif you want to migrate and seed data, simply run\n\n```sh\nphp auth/index.php migrate\nphp auth/index.php seed\n```\n\nand you should be done (a test user `david@vielhuber.de` with the password `secret` is created).\\\nyou can now fully authenticate with the routes below.\\\nif you want to authenticate via username instead of email, simply change JWT_LOGIN to `username`.\n\n## routes\n\nthe following routes are provided automatically:\n\n| route         | method | arguments      | header                      | response                                                                                                                                                                |\n| ------------- | ------ | -------------- | --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| /auth/login   | POST   | email password | --                          | `([ 'success' =\u003e true, 'message' =\u003e 'auth successful', 'public_message' =\u003e '...', 'data' =\u003e [ 'access_token' =\u003e '...', 'expires_in' =\u003e 3600, 'user_id' =\u003e 42 ] ], 200)` |\n| /auth/refresh | POST   | --             | Authorization: Bearer token | `([ 'success' =\u003e true, 'message' =\u003e 'auth successful', 'public_message' =\u003e '...', 'data' =\u003e [ 'access_token' =\u003e '...', 'expires_in' =\u003e 3600, 'user_id' =\u003e 42 ] ], 200)` |\n| /auth/logout  | POST   | --             | Authorization: Bearer token | `([ 'success' =\u003e true, 'message' =\u003e 'logout successful', 'public_message' =\u003e '...' ], 200)`                                                                             |\n| /auth/check   | POST   | access_token   | --                          | `([ 'success' =\u003e true, 'message' =\u003e 'valid token', 'public_message' =\u003e '...', 'data' =\u003e [ 'expires_in' =\u003e 3600, 'user_id' =\u003e 42, 'client_id' =\u003e 7000000 ] ], 200)`      |\n\n## further usage\n\nyou can use the following functions inside your own application (they do not need any database lookups):\n\n```php\nrequire __DIR__ . '/vendor/autoload.php';\nuse vielhuber\\simpleauth\\simpleauth;\n$auth = new simpleauth(__DIR__ . '/.env');\n\n$auth-\u003eisLoggedIn();\n$auth-\u003egetCurrentUserId();\n```\n\n## frontend\n\nif you need a neat frontend library that works together with simpleauth seemlessly, try out [jwtbutler](https://github.com/vielhuber/jwtbutler).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvielhuber%2Fsimpleauth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvielhuber%2Fsimpleauth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvielhuber%2Fsimpleauth/lists"}