statikbe/laravel-google-authenticate
Composer 安装命令:
composer require statikbe/laravel-google-authenticate
包简介
Google Authentication in Laravel
README 文档
README
Google Authenticator
This module gives you the option to let you (and your users) log in with their Google account on your Laravel application.
This is initially used to let only people log in from certain workspaces. But can be enabled to let everyone log in.
Installation
Using Composer
composer require statikbe/laravel-google-authenticate
Usage
The package will automatically register itself.
You can publish the migration with the following command:
php artisan vendor:publish --provider="Statikbe\GoogleAuthenticate\GoogleAuthenticateServiceProvider" --tag="google-migrations"
To add the needed columns to your database run:
php artisan migrate
Add the use HasGoogleAuth trait in your User.php class.
This will provide the necessary fillable options to your User.
In your .env file you should include the following keys:
GOOGLE_CLIENT_ID="YOUR_GOOGLE_CLIENT_ID" GOOGLE_CLIENT_SECRET="YOUR_GOOGLE_CLIENT_SECRET" CALLBACK_URL_GOOGLE="https://www.domain.com/login/google/callback"
The next step is to add the following lines in your services.php config file
'google' => [ 'client_id' => env('GOOGLE_CLIENT_ID'), 'client_secret' => env('GOOGLE_CLIENT_SECRET'), 'redirect' => env('CALLBACK_URL_GOOGLE'), ],
Info on how to create a Google Auth Client id and secret can be found on their documentation page.
Finally, you can add google login route to your login and register views: {{ route('google.auth.login') }}.
Config
Publish the config file
php artisan vendor:publish --provider="Statikbe\\GoogleAuthenticate\\GoogleAuthenticateServiceProvider" --tag="google-config"
Email domains
You can change the email domains that can login using Google. The three available options are:
allowed-array: only the domains in this array can login using Googledisabled-array: domains in this array can not login using Google- Empty / null: all domains can use the Google login
'domains' => [ //'allowed' => ['statik.be'], //'disabled' => ['google.com'], ],
You can add an extra middleware on the auth logins by adding them in the google-authenticate.php config file.
Custom middlewares
'middleware' => [ 'web', CustomMiddleware::class ],
User table
You can customize how a user is saved. The config array user_columns will create the fillable data for your user.
The array keys are your user column names, the array values are what should be stored. (Make sure the value is an array).
You can add multiple values per key, these will be glued together.
The following values would be filled by google's returned data, before being glued.
const GOOGLE_VALUES = [ 'name', 'email_verified', 'email', 'given_name', 'family_name', 'picture', 'nickname', 'locale', ];
For example in your config:
'user_columns' => [ 'name' => ['name', ' (', 'locale', ')'] // John Doe (en) 'email_verified_at' => ['email_verified'], // 2019-10-23 14:31:50 'email' => ['email'], // john@doe.com 'other data' => ['blablabla'], // blablabla ]
Publishing
You can publish the views and translations files using:
php artisan vendor:publish --provider="Statikbe\\GoogleAuthenticate\\GoogleAuthenticateServiceProvider" --tag="google-views"
and
php artisan vendor:publish --provider="Statikbe\\GoogleAuthenticate\\GoogleAuthenticateServiceProvider" --tag="google-lang"
Security
If you discover any security related issues, please email info@statik.be instead of using the issue tracker.
License
The MIT License (MIT). Please see License file for more information.
statikbe/laravel-google-authenticate 适用场景与选型建议
statikbe/laravel-google-authenticate 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12.87k 次下载、GitHub Stars 达 7, 最近一次更新时间为 2018 年 12 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「google」 「laravel」 「authenticate」 「socialite」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 statikbe/laravel-google-authenticate 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 statikbe/laravel-google-authenticate 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 statikbe/laravel-google-authenticate 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A simple Cake3 plugin to authenticate users with Cookies.
CakePHP plugin that performs Remember-me authentication with the new cookie algorithm of version 3.5 or later
MvcCore - Extension - Auth - authentication module with automatic authentication module type detection by loaded classes.
Magento 2 Social Login extension is designed for quick login to your Magento 2 store without procesing complex register steps
MvcCore - Extension - Auth - Basic - simple authentication extension, only to signin/signout user. Extension can use credentials defined in system `config.ini` or in database. Possibility to extend user, signin/signout forms, submit controller and extension class itself.
Client for Google Directions API to add interpolated points to a route consisting of given coordinates.
统计信息
- 总下载量: 12.87k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-12-09
