提问者:小点点

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


我正在构建跨平台的应用程序,所以我有网站和移动应用程序。 此外,我有认证部分的网站和应用程序。

我用Laravel做后台。 对于auth,我发现了一个名为“auth Guards”的东西,在Laravel中有两个默认的auth Guards,一个用于web,另一个用于API。

但是我有点困惑,因为我发现你不能同时使用两个身份验证卫士。

那么,有没有一种方法来建立基于一个数据库表的移动网站认证系统。

注我需要任何解决方案,除了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个答案

匿名用户

一个很好的解决方案是laravel oficial pakage laravel/Passport,它提供了oauth2,因此您可以很容易地在Android/OS上实现它。