kregel/laravel-flight 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

kregel/laravel-flight

Composer 安装命令:

composer require kregel/laravel-flight

包简介

Secure your apps easily with Laravel Socialite and OAuth. Install this package, configure a few env values, a config/services.php entry, and then login.

README 文档

README

Secure your apps easily with Laravel Socialite and OAuth. Install this package, configure a few env values, a config/services.php entry, and then login. Never leave your apps unprotected.

Latest Version on Packagist Total Downloads

Streamline your Authentication even further. Integrate with your own internal Laravel Passport instance and enable your users to login however they need to.

Stop dealing with setting up a /login redirect and /callback. Not all apps need their own auth system. Sometimes we just want to login with an existing platform like Github, Auth0, or even a custom Laravel Passport instance. While this still does have it's own user's table, it's largely used for tracking social users.

Ok but why?

Because there are Laravel tools out there that don't come with authentication, but require it to be able to secure them for production access.

This package let's you grab your favorite Github, Google, or other supported OAuth provider's credentials, set them in your env, visit http://yoururl/flight/login and login. You should be redirected to the auth provider you chose as your FLIGHT_DRIVER, and you will then be redirected to FLIGHT_LOGIN_REDIRECT.

Users that don't exist at the time of the request will be created unless you explicitly disable registration with an env var (so turn it off after you registery) FLIGHT_ALLOW_REGISTRATION

Installation

You can install the package via composer:

composer require kregel/laravel-flight

Publish the config

php artisan vendor:publish --provider=Kregel\\Flight\\FlightServiceProvider

Find a socialite provider you wish to use

Add their ExtendSocialite event to our config file under the community_drivers section, and if you wish to make it your primary driver, set your FLIGHT_DRIVER

Post setup

You'll want to verify that you have your web middleware configured. And you'll want the auth middleware too, so Laravel will redirect you to your auth provider.

If you're reading a headless type of system and have removed those middlewares here's basically the same stuff.

In your app/Http/Kernel.php the web middleware would basically be

    protected $middlewareGroups = [
        'web' => [
            \Illuminate\Cookie\Middleware\EncryptCookies::class,
            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
            \Illuminate\Session\Middleware\StartSession::class,
            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
            \Illuminate\Foundation\Http\Middleware\VerifyCsrfToke::class,
            \Illuminate\Routing\Middleware\SubstituteBindings::class,
        ],
    ];

And under the $middlewareAliases portion you can add the following replacement for App\Http\Middleware\Authenticate

'auth' => \Kregel\Flight\Middleware\Authenticate::class,
'guest' => \Kregel\Flight\Middleware\RedirectIfAuthenticated::class,

Both of the above middleware are almost directly taken from the base Laravel app, with minor adjustments for configuration.

Integrating new socialite providers

To add a new authentication provider to your app, you'll need to composer require their package into your app, then add their ExtendSocialite listener to the community_drivers page. Once the driver has been added, you'll need to open your config/services.php file and add the following equivalent for your driver . Replacing driver_name and DRIVER_NAME with your actual driver.

'driver_name' => [
    'client_id' => env('DRIVER_NAME_CLIENT_ID'),
    'client_secret' => env('DRIVER_NAME_CLIENT_SECRET'),
    'redirect' => env('DRIVER_NAME_REDIRECT_URI'),
],

If your preferred driver is github, then it'll look like this:

'github' => [
    'client_id' => env('GITHUB_CLIENT_ID'),
    'client_secret' => env('GITHUB_CLIENT_SECRET'),
    'redirect' => env('GITHUB_REDIRECT'),
],

Lastly, change your FLIGHT_DRIVER env var to your preferred driver.

And visit http://yourwebsite/flight/login

If you haven't already set up the redirect url or callback url http://yourwebsite/flight/callback

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email 5355937+austinkregel@users.noreply.github.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.

kregel/laravel-flight 适用场景与选型建议

kregel/laravel-flight 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 340 次下载、GitHub Stars 达 3, 最近一次更新时间为 2023 年 03 月 20 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「Authentication」 「oauth」 「laravel」 「socialite」 「horizon」 「kregel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 kregel/laravel-flight 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 kregel/laravel-flight 我们能提供哪些服务?
定制开发 / 二次开发

基于 kregel/laravel-flight 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 340
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 11
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-03-20