{"id":23003717,"url":"https://github.com/stechstudio/laravel-socialite-auth","last_synced_at":"2025-08-14T01:32:11.741Z","repository":{"id":57059346,"uuid":"170163327","full_name":"stechstudio/laravel-socialite-auth","owner":"stechstudio","description":null,"archived":false,"fork":false,"pushed_at":"2022-02-10T03:32:44.000Z","size":33,"stargazers_count":6,"open_issues_count":0,"forks_count":3,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-06-28T10:26:01.300Z","etag":null,"topics":[],"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/stechstudio.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-11T16:36:24.000Z","updated_at":"2023-02-04T11:42:45.000Z","dependencies_parsed_at":"2022-08-24T14:53:27.507Z","dependency_job_id":null,"html_url":"https://github.com/stechstudio/laravel-socialite-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/stechstudio%2Flaravel-socialite-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stechstudio%2Flaravel-socialite-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stechstudio%2Flaravel-socialite-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stechstudio%2Flaravel-socialite-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stechstudio","download_url":"https://codeload.github.com/stechstudio/laravel-socialite-auth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229790943,"owners_count":18124608,"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-15T07:15:08.332Z","updated_at":"2024-12-15T07:15:09.057Z","avatar_url":"https://github.com/stechstudio.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Quickly integrate Laravel Socialite into a Laravel app \n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/stechstudio/laravel-socialite-auth.svg?style=flat-square)](https://packagist.org/packages/stechstudio/laravel-socialite-auth)\n[![Build Status](https://img.shields.io/travis/stechstudio/laravel-socialite-auth/master.svg?style=flat-square)](https://travis-ci.org/stechstudio/laravel-socialite-auth)\n[![Quality Score](https://img.shields.io/scrutinizer/g/stechstudio/laravel-socialite-auth.svg?style=flat-square)](https://scrutinizer-ci.com/g/stechstudio/laravel-socialite-auth)\n\u003c!--- [![Total Downloads](https://img.shields.io/packagist/dt/stechstudio/laravel-socialite-auth.svg?style=flat-square)](https://packagist.org/packages/stechstudio/laravel-socialite-auth) --\u003e\n\nThis package provides quick wiring and simple configuration for the most common ways in which you may wish to integrate [Laravel Socialite](https://github.com/laravel/socialite) into your application. \nIn addition it extends that authentication flow, enabling further logic to verify that a user meets your unique requirements before logging in.\n\n### Currently supports:\n- Use as the primary and only authentication for your application.\n- Route-specific authentication alongside Laravel's own Auth scaffolding or other authentication drivers.\n- Use for authentication into Laravel Nova in addition to or separate from front-end app authentication.\n\n### Not yet provided\n- OAuth-only authentication with Socialite, not requiring users to be present in a Laravel user provider.\n- Use with multiple Socialite providers (eg. Google and Facebook).\n- Use of different providers for different routes (eg. Facebook for frontend, Google for Nova).\n\n## Getting started\n\n1. Install the composer package\n    ```bash\n    composer require stechstudio/laravel-socialite-auth\n    ```\n2. [Configure the Socialite provider](https://laravel.com/docs/5.7/socialite#configuration) you wish to use in\n   `config/services.php`, specifying the redirect path as either the named route of `socialite-auth.callback` or\n   the relative path `/socialite-auth/callback`. For example:\n    ```php\n    'google' =\u003e [\n        'client_id' =\u003e env('GOOGLE_CLIENT_ID'),\n        'client_secret' =\u003e env('GOOGLE_CLIENT_SECRET'),\n        'redirect' =\u003e route('socialite-auth.callback')\n    ],\n    ```\n3. Implement this package's `SocialiteAuthenticatable` Interface on each user class in\n   your application that corresponds to a Socialite user. These two methods return the \n   field and value which will be compared to the user returned by Socialite.\n   \n   ```php\n   public function getSocialiteIdentifierName()\n   {\n       return 'email';\n   }\n    \n   public function getSocialiteIdentifier()\n   {\n       return $this-\u003eemail;\n   }\n   ```\n   \n   By default these values will be compared to the `email` attribute returned from socialite.\n   Below you may configure this and other options.\n4. Beyond matching a Socialite user to one in your database, you may optionally provide a closure to \n   ensure any additional requirements are met. Provide whatever logic you require by using this package's\n   facade within your AppServiceProvider's `boot()` method as follows:\n   ```php\n   SocialiteAuth::beforeLogin(function($user) {\n       return str_contains($user-\u003eemail, ['example.com']);\n   });\n   ```  \n   \n## Configuration\n\nAfter publishing this package's configration, the following options will be available to you in `config/socialite-auth.php`.\n\n| Field      | Description |\n| ---------- | ----------- |\n| driver     | The OAuth service to be used by Socialite. The corresponding credentials must be provided in your services config. The default is `google`.  |\n| provider   | The user provider which contains the users you are authenticating with Socialite. Default is `users` |\n| middleware | Additional middleware to apply to the OAuth routes. Default is `web`. |\n| field      | The socialite field which will be compared to the value returned by the `SocialiteAuthenticatable` interface. Default is `email`. |\n\n\n## Usage\n\n### Use as primary authentication\n \nRemove any existing authentication routes, such as those added by Auth::routes(). Then in `config/auth.php`, set the default guard to `socialite`\n```php\n'defaults' =\u003e [\n    'guard' =\u003e 'socialite',\n    ...\n],\n```\n\n### Mixed authentication\n\n1. This package includes its own Authenticate middleware which can be applied to perform\n   the correct redirect in a mixed authentication environment. First add it to your route\n   middleware in `app/Http/Kernel.php`.\n   ```php\n   protected $routeMiddleware = [\n       ...\n       'socialite' =\u003e \\STS\\SocialiteAuth\\Authenticate::class,\n       ...\n   ];\n   ``` \n\n2. Further down, add it above the default Authenticate middleware in the\n   priority array to ensure it takes priority over the default when applied.\n   ```php\n   protected $middlewarePriority = [\n       ...\n       \\STS\\SocialiteAuth\\Authenticate::class,\n       \\App\\Http\\Middleware\\Authenticate::class,\n       ...\n   ];\n   ```\n\nNow you may freely specify Socialite authentication on some routes...\n```php\nRoute::get(...)-\u003emiddleware(['auth:socialite', 'socialite']);\n```\n...and in-app authentication on others.\n```php\nRoute::get(...)-\u003emiddleware('auth');\n```\n \n### Laravel Nova authentication\n\nFinally, it's quick to set up socialite authentication with Laravel Nova.\n\n1. In the NovaServiceProvider added within your Providers directory, disable the\n   authentication related routes which are generated by default.\n   ```php\n   protected function routes()\n   {\n       Nova::routes();\n           // -\u003ewithAuthenticationRoutes()\n           // -\u003ewithPasswordResetRoutes()\n           // -\u003eregister();\n   }\n   ```\n2. If Socialite is configured as your default guard as above, you're all set.\n   Otherwise add a `NOVA_GUARD` value to your .env file indicating that `socialite` \n   is your desired guard.\n   ```\n   NOVA_GUARD=socialite\n   ```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstechstudio%2Flaravel-socialite-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstechstudio%2Flaravel-socialite-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstechstudio%2Flaravel-socialite-auth/lists"}