Laravel Api和Web身份验证同时进行

时间:2020-06-24 13:55:40

标签: php mysql laravel api laravel-7

我正在构建跨平台应用程序,因此我拥有网站和移动应用程序。我也有网站和应用程序的身份验证部分。

,我正在使用Laravel作为后端。对于身份验证,我发现了一个称为“身份验证防护”的东西,Laravel中有两个默认的身份验证防护,一个用于Web,另一个用于API。

但是我有点困惑,因为我发现您不能同时使用两个Auth Guard。

因此,有什么方法可以基于用于移动网站的数据库表构建身份验证系统。

注意,我需要除Firebase Auth之外的任何解决方案

Auth.php

/*
    |--------------------------------------------------------------------------
    | Authentication Defaults
    |--------------------------------------------------------------------------
    |
    | This option controls the default authentication "guard" and password
    | reset options for your application. You may change these defaults
    | as required, but they're a perfect start for most applications.
    |
    */

    'defaults' => [
        'guard' => 'web',
        'passwords' => 'users',
    ],

1 个答案:

答案 0 :(得分:0)

一个好的解决方案可能是laravel官方软件包laravel / passport,它可以为您提供oauth2,因此您可以轻松地在android / os上实现它。

相关问题