1 Star 0 Fork 0

LaravelAdmin / geetest

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

极验验证码 v3.0 Laravel

采用了Germeyd的package,在此基础上添加后台获取Geetest ID 和 KEY 方法,可不从env获取。

安装

  1. 安装包文件

    $ composer require zbrettonye/geetest

配置

Laravel5.5+ 可跳过此步骤

  1. config/app.php 注册 ServiceProvider:

    ZBrettonYe\Geetest\GeetestServiceProvider::class,
  2. config/app.php 添加 Alias

    'Geetest' => ZBrettonYe\Geetest\Facades\Geetest::class,
  3. 创建配置文件、视图级资源文件:

    php artisan vendor:publish --provider='ZBrettonYe\Geetest\GeetestServiceProvider'
  4. .env 文件增加配置项 GEETEST_IDGEETEST_KEY 或 通过添加 Component CaptchaVerify 来获取 ID 和 KEY

配置项

配置项 说明 选项 默认值
width 按钮宽度 单位可以是 px, %, em, rem, pt 300px
lang 语言,极验验证码免费版不支持多国语言 zh-cn, en, zh-tw, ja, ko, th zh-cn
server-get-config 从服务器获取GeetestKEY True False
product 验证码展示方式 popup, float popup
geetest_id 极验验证码ID
geetest_key 极验验证码KEY
client_fail_alert 客户端失败提示语 请完成验证码
server_fail_alert 服务端失败提示语 验证码校验失败

使用

  1. 前端使用

安装扩展后,在页面需要使用极验验证码的地方增加如下代码

{!! Geetest::render() !!}
  1. 服务端校验

在服务端使用 geetest 验证规则进行二次验证,示例代码:

$this->validate($request, [
    'geetest_challenge' => 'required|geetest'
], [
    'geetest' => config('geetest.server_fail_alert')
]);
  1. 配置项:server-get-config - 服务器获取GeetestKey

通过调用 Components CaptchaVerify 的 geetestCaptchaGetConfig 方法来获取 Geetest 配置,方便实现由后台配置的KEY 和 ID

<?php

namespace App\Components;

/**
 * Class CaptchaVerify
 *
 * @package App\Components
 */

Class CaptchaVerify 
{
    public static function geetestCaptchaGetConfig() 
    {
        return [
            "geetest_id" => Helpers::systemConfig()["geetest_id"], // 后台获取 id
            "geetest_key" => Helpers::systemConfig()["geetest_key"] // 后台获取 key
        ];
    }
}

?>

参考项目

  1. Germey/LaravelGeetest

  2. GeeTeam/gt3-php-sdk

License

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

The MIT License (MIT) Copyright (c) 2020 ZBrettonYe Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

geetest 展开 收起
PHP 等 2 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
PHP
1
https://gitee.com/laravel-admin/geetest.git
git@gitee.com:laravel-admin/geetest.git
laravel-admin
geetest
geetest
master

搜索帮助