kundu/orgsignin
Composer 安装命令:
composer require kundu/orgsignin
包简介
Google Sign-In for Laravel with domain restrictions
README 文档
README
Laravel Organization Google Sign-In Package Guide
Overview
This package provides a straightforward way to integrate Google Sign-In with domain restrictions into your Laravel application. It allows only users from a specific domain to authenticate using their Google accounts.
Prerequisites
Ensure your environment meets the following requirements:
- PHP Version: ^7.2 or ^8.2
- Laravel Version: ^8.0 or ^11.0
- Google API Client Credentials: Set up through Google Cloud Console
Installation
1. Install the Package
To install the package, run the following command in your terminal:
composer require kundu/orgsignin
2. Publish Configuration and Views
After installation, publish the configuration file:
php artisan vendor:publish --tag="orgsignin-config"
Optionally, you can also publish the views:
php artisan vendor:publish --tag="orgsignin-views"
Configuration
1. Environment Variables
Add the following variables to your .env file to configure Google Sign-In:
GOOGLE_CLIENT_ID=your-google-client-id GOOGLE_CLIENT_SECRET=your-google-client-secret ORG_SIGNIN_ALLOWED_DOMAIN=your-allowed-domain.com,another-allowed-domain.com ORG_SIGNIN_USER_TABLE=users ORG_SIGNIN_EMAIL_COLUMN=email ORG_SIGNIN_CHECK_VERIFIED=true ORG_SIGNIN_REDIRECT_ROUTE=/home SIGNIN_BUTTON_TEXT="Sign in with Google"
2. Google OAuth Credentials
Configure your Google OAuth credentials in the Google Cloud Console, making sure to set the correct redirect URI for your Laravel app.
Integration
1. Include the Sign-In Button
To display the Google Sign-In button on your login view, add this line:
@include('orgsignin::components.signin-button')
2. Route Protection
Apply the ValidateDomain middleware to protect routes and allow access only to users with the specified email domain. For example:
Route::middleware(['auth', ValidateDomain::class])->group(function () { Route::get('/dashboard', function () { return view('dashboard'); }); // Additional protected routes... });
Authentication Flow
This package handles the authentication flow as follows:
- Domain Validation: Ensures the user’s email belongs to the allowed domain.
- User Verification: Checks if the user exists in the database.
- Optional Email Verification: Verifies the user’s email if required.
Upon successful authentication, users are redirected to the specified route (ORG_SIGNIN_REDIRECT_ROUTE); otherwise, an error message is displayed.
Customization
You can customize the views and configuration to fit your application. The text on the sign-in button can be changed using the SIGNIN_BUTTON_TEXT environment variable.
kundu/orgsignin 适用场景与选型建议
kundu/orgsignin 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.11k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2024 年 11 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 kundu/orgsignin 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 kundu/orgsignin 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1.11k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-11-06