{"id":22782193,"url":"https://github.com/randomstate/laravel-auth","last_synced_at":"2026-05-19T03:35:35.033Z","repository":{"id":62533178,"uuid":"132795260","full_name":"randomstate/laravel-auth","owner":"randomstate","description":"A strategy-based auth component for Laravel","archived":false,"fork":false,"pushed_at":"2022-04-23T10:47:43.000Z","size":38,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-05T16:22:41.525Z","etag":null,"topics":["auth","authentication","laravel","strategy"],"latest_commit_sha":null,"homepage":null,"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/randomstate.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":"2018-05-09T18:06:19.000Z","updated_at":"2022-04-23T10:46:36.000Z","dependencies_parsed_at":"2022-11-02T14:46:31.616Z","dependency_job_id":null,"html_url":"https://github.com/randomstate/laravel-auth","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/randomstate%2Flaravel-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/randomstate%2Flaravel-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/randomstate%2Flaravel-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/randomstate%2Flaravel-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/randomstate","download_url":"https://codeload.github.com/randomstate/laravel-auth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246333931,"owners_count":20760638,"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":["auth","authentication","laravel","strategy"],"created_at":"2024-12-11T21:09:45.675Z","updated_at":"2026-05-19T03:35:29.996Z","avatar_url":"https://github.com/randomstate.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# laravel-auth\n\nA strategy-based auth component for Laravel.\n\n# Setup with Laravel\n\nAdd `RandomState\\LaravelAuth\\LaravelAuthServiceProvider::class` to your app.php 'providers' config.\n\n# Strategies\n\nIn a service provider:\n\n```php\npublic function register() {\n    $this-\u003eapp-\u003eresolving(AuthManager::class, function($manager) {\n        $manager-\u003eregister('jwt', $this-\u003eapp-\u003emake(JwtStrategy::class));\n    });\n    \n    $this-\u003eapp-\u003eresolving(JwtStrategy::class, function($strategy) {\n        $strategy-\u003econvertUsing(function(JwtUser $jwtUser) {\n            return new MyUser($jwtUser);\n        });\n    });\n}\n```\n\n## Writing a Custom Strategy\n\nStrategies are relatively easy to implement, though you need a firm grasp of how your authentication mechanism works before\nyou should write a strategy for it. This library doesn't protect you from any security holes you implement by accident.\n\nYour strategy should implement the interface `RandomState\\LaravelAuth\\AuthStrategy`. A convenient `RandomState\\LaravelAuth\\AbstractAuthStrategy` class is provided to help with this.\nThere are two methods in this interface that must be implemented and are explained below.\n\n```php\n\n/*\n * This method is responsible for authenticating a given Laravel HTTP Request.\n * You have access to the entire request and can choose to manipulate the request's response property to your liking.\n * For more complex flows such as OAuth2, you can still implement these in a single strategy by\n * checking for access tokens in the URL and performing different redirect logic. Only when everything is in the URL for a final\n * step should you then authenticate and allow a user through. See some of the Random State strategies for examples on how to do this.\n */\npublic function attempt(Request $request);\n\n/*\n * If you use the AbstractAuthStrategy class to help you, you can ignore this method.\n *\n * The strategy system works well when it is isolated to its own domain. You should usually expose strategy specific objects\n * to represent the client or user that is authenticating/authenticated. This might be a FirebaseUser, a StripeUser,\n * a GitHub user etc.\n * \n * This function should take the (possibly-null) authenticated object returned by your attempt method and convert it into a\n * user object you can use in your application.\n */\npublic function convert($user);\n\n/*\n * This method is only present in the AbstractAuthStrategy class, if you are extending that class.\n * \n * Strategies made for open source or third party use will benefit greatly from this API.\n * It allows a consumer to pass a function to convert the domain-specific user (e.g. FirebaseUser) to their own domain.\n * \n * This is especially useful for third-party consumers simply because you don't need to know the structure of their application\n * ahead of creating the strategy implementation.\n */\npublic function convertUsing(Closure $converter);\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frandomstate%2Flaravel-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frandomstate%2Flaravel-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frandomstate%2Flaravel-auth/lists"}