cyrildewit/laravel-silent-authentication

Laravel 的静默认证方法

v0.1.2 2020-04-17 11:09 UTC

This package is auto-updated.

Last update: 2024-09-07 18:18:30 UTC


README

此 Laravel >= 5.5 包允许您静默地认证用户。

概述

我创建这个包是为了个人使用。它基于其他开源包和在线博客文章的见解。

文档

在这份文档中,您将找到有关使用此 Laravel 包的一些有用信息。

目录

  1. 入门
  2. 使用

入门

要求

此包需要 PHP 7.1+Laravel 5.5+

不支持 Lumen!

版本信息

安装

首先,您需要通过 Composer 安装此包

composer require cyrildewit/laravel-silent-authentication

您可以选择使用以下命令发布配置文件

php artisan vendor:publish --provider="CyrildeWit\LaravelSilentAuthentication\SilentAuthenticationServiceProvider" --tag="config"

手动注册服务提供者

如果您喜欢手动注册包,可以将以下提供者添加到应用程序的提供者列表中。

// config/app.php

'providers' => [
    // ...
    CyrildeWit\LaravelSilentAuthentication\SilentAuthenticationServiceProvider::class,
];

使用

默认设置

默认情况下,此包将覆盖默认的 SessionGuard。自定义会话保护器使用 SilentAuthentication 特性,这将允许您静默地认证用户。

如果您对此默认设置不感兴趣,或者它破坏了您的应用程序,您可以在配置文件中禁用它。

SilentAuthentication 特性

如果您已经在应用程序中覆盖了默认的 SessionGuard,您只需实现 SilentAuthentication 特性即可。

use Illuminate\Auth\SessionGuard as BaseSessionGuard;
use CyrildeWit\LaravelSilentAuthentication\Guards\Traits\SilentAuthentication;

class SessionGuard extends BaseSessionGuard
{
    use SilentAuthentication;
}

变更日志

请参阅 CHANGELOG 了解最近更改的更多信息。

许可证

本项目采用 MIT 许可证 - 有关详细信息,请参阅 LICENSE.md 文件。