dreitier/streamline-authentication

多租户Laravel应用的常见认证方法

dev-main 2023-09-03 09:09 UTC

This package is auto-updated.

Last update: 2024-10-03 11:21:25 UTC


README

多租户Laravel应用的常见认证方法。

特性

  • 提供常见认证方法
    • 基于表单的登录,带有主体(例如,用户名,电子邮件)和密码
    • 通过发送包含魔法登录链接的电子邮件进行无密码登录
    • 通过选择预定义用户进行演示/端到端环境登录
    • 社交登录集成以实现OAuth
  • 针对多租户Laravel SaaS/本地应用的开发者
    • 仅针对特定客户群体激活不同的认证方法
    • 每个租户可配置的认证方法
    • 用户可以通过同一租户中的不同Socialite驱动器进行登录

何时使用Streamline Authentication而不是Laravel Fortify?

对于大多数Laravel应用,Fortify以更简单、更Laravel的方式实现了所有必要的认证工作流程。如果您需要基于密码的认证,可选启用双因素认证,以及注册和密码恢复工作流程,您可能应该选择Fortify。如果您需要一个更可配置和动态的方法来在不同租户中启用和配置不同的认证方法,Streamline Authentication可能是一个选择。

安装

安装composer包并发布所需的配置

composer require dreitier/streamline-authentication

php artisan vendor:publish --provider=Dreitier\\Streamline\\Authentication\\StreamlineAuthenticationServiceProvider --tag=config

自定义视图

如果您想自定义视图和邮件,使用以下命令发布资产:

php artisan vendor:publish --provider=Dreitier\\Streamline\\Authentication\\StreamlineAuthenticationServiceProvider --tag=assets

您可以在以下位置找到自定义的资产:resources/views/vendor/streamline-authentication

自定义路由

默认情况下,Streamline Authentication/sign-in端点注册认证方法流程。仅注册启用的认证方法。

如果您想自己发布路由,使用以下命令,并在config/streamline-authentication.php中设置:

php artisan vendor:publish --provider=Dreitier\\Streamline\\Authentication\\StreamlineAuthenticationServiceProvider --tag=routes

并在config/streamline-authentication.php中设置

return [
    // ...
    'routes' => false
    // ...
];

配置

config/streamline-authentication.php包含注释的配置选项。

术语

常见问题解答