good-system/laravel-o365auth
Composer 安装命令:
composer require good-system/laravel-o365auth
包简介
README 文档
README
This package allows a Laravel application to authenticate users using their Office 365 accounts.
The package is largely based on program logic from microsoftgraph/php-connect-sample, but aims to easier integration with Laravel 5, and utilized more Laravel specific things.
Prerequisite
Microsoft Application and .env
Create an application at https://apps.dev.microsoft.com. And add the following to .env file with the application's parameters.
# If any of the following is missing, authentication will fail.
O365_DOMAIN=ALLOWED-EMAIL-DOMAIN-NAMES,SEPARATED-BY-COMMA
O365_CLIENT_ID=YOUR-APPLICATION-ID-OR-CLIENT-ID-IN-CREATED-MICROSOFT-APPLICATION
O365_CLIENT_SECRET=YOUR-CLIENT-SECRETE-OR-CLIENT-PASSWORD-IN-CREATED-MICROSOFT-APPLICATION
# This needs to be the full URL (https).
O365_REDIRECT_URL=YOUR-REDIRECT-URL-IN-CREATED-MICROSOFT-APPLICATION
User Model
This package will be looking for a Laravel model \O365User. This could be an alias of App\User or other user class such as GoodSystem\User, explicitly set in the application.
Installation
Run composer require good-system/o365auth under Laraval application root directory.
Laravel (5.6 and newer) should "discover" the package, without having to add service provider to config/app.php.
Required Laravel Version
This package might work with Laravel framework before 5.7, it's not been tested.
Error Page Templates
Error templates in package will be looked up and used if exist. Otherwise, fall back to default Laravel error display.
Expected Behaviors
Default Routes
Two default routes are provided:
/o365auth/init/o365auth/redirect
Users should always start at /o365auth/init, and then expect to be redirected to Office 365 authentication page at https://login.microsoftonline.com/common/oauth2/v2.0/authorize, with parameters.
1. Happy Scenario
Upon successful authentication with an Office 365 account on any of the domains specified by "O365_DOMAIN" in .env,
- if not exists in the system, and user model is configured properly, user record is added to the system (retrieved if already exists)
- system access is granted (Laravel manual authentication)
- user is finally redirected to the previous page or web root
/(it doesn't have anything to do with "O365_REDIRECT_URL" in.env) - Both new user and existing user will be able to bypass email verification, if not yet verified (verification flag will be set manually)
2. Laravel Authentication Error
If above #2 fails, which is unlikely, expect the system to throw a 500 error -- something really unexpected.
3. User Model Error
If above #1 fails due to bad configuration for user model, which is possible (but not expected), or some unknown error while adding user to system, also expect system to throw a 500 error.
4. Bad Data Coming from Microsoft
Could be one of the several scenarios.
5. Email Not on The Allowed Domains List
Expect the system to throw a 403 error.
good-system/laravel-o365auth 适用场景与选型建议
good-system/laravel-o365auth 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 22 次下载、GitHub Stars 达 1, 最近一次更新时间为 2019 年 01 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 good-system/laravel-o365auth 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 good-system/laravel-o365auth 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 22
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2019-01-30