21 Star 207 Fork 49

yiyun / SimCaptcha

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

SimCaptcha

SimCaptcha

:cake: 一个简单易用的点触验证码, 包含了前端与后端实现

repo size LICENSE QQ Group

介绍

一个简单易用的点触验证码促进你的开发

  • 简单 - 约定优于配置, 以最少的配置帮助你专注于业务
  • 易扩展 - 通过实现各个验证组件接口,再借助于 ASP.NET Core 依赖注入,轻松扩展自己的验证策略
  • 开箱即用 - 使用现有 Web SDK 接入后端验证
  • 安全 - 验证图片,效验信息均服务端生成并保存
  • 分布式 - 支持通过实现 ICache 接口替换默认本地缓存方案
  • 轻松定制 - 简单配置即可自定义过期时间,失效次数,背景图片,字体等

在线演示

前后端调用时序图

依赖

只需要满足下方其中一条.

  • .NET Framework (>= 4.0) 被安装.
  • .NET Standard (>= 2.0) 被安装.

安装

推荐使用 NuGet, 在你项目的根目录 执行下方的命令, 如果你使用 Visual Studio, 这时依次点击 Tools -> NuGet Package Manager -> Package Manager Console , 确保 "Default project" 是你想要安装的项目, 输入下方的命令进行安装.

PM> Install-Package SimCaptcha

在 ASP.NET Core 下使用

PM> Install-Package SimCaptcha.AspNetCore

快速开始

在 ASP.NET Core 下 三步搭建验证服务端

// Startup.cs 
// 注意: 省略了部分代码, 只保留主要部分, 详见示例(/examples/EasyAspNetCoreService)
// 仅适用于 SimCaptcha.AspNetCore v0.3.0+
public void ConfigureServices(IServiceCollection services)
{
    // 1.重要: 注册验证码配置
    services.Configure<SimCaptchaOptions>(Configuration.GetSection(SimCaptchaOptions.SimCaptcha));

    // 2.添加 SimCaptcha
    services.AddSimCaptcha();
}

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
    // 3.启用 SimCaptcha 中间件
    app.UseSimCaptcha();

    // 现在
    // "https://yourdomain.com/api/SimCaptcha/Img", "https://yourdomain.com/api/SimCaptcha/Check", "https://yourdomain.com/api/SimCaptcha/TicketVerify"
    // 将开始工作
}

Docker 快速部署

下方为部署验证码服务端:

docker run -d -p 5004:80 -e ASPNETCORE_URLS="http://*:80" --name simcaptcha-container yiyungent/simcaptcha

注意:若使用 Docker 同时部署验证码服务端,业务(客户)端,
需注意Docker容器隔离,默认容器之间无法网络通信,
需使其在一个网络下,用于客户端访问服务端验证票据,可参考仓库根目录 docker-compose.yml
同时,若客户端与服务端非同源域名,
需注意跨域问题,Docker下验证码服务端配置文件:/app/appsettings.Docker.json
事实上,若使用 Docker快速部署验证服务端,
则一定要修改 /app/appsettings.Docker.json 其中的 SimCaptcha.AppList.CorsWhiteList,添加上你的客户端域名。

使用

版本依赖

SimCaptcha 0.0.1 0.1.0 0.2.0
SimCaptcha.AspNetCore 0.0.1 0.1.0-0.2.0 0.3.0
sim-captcha-js 0.0.1-0.0.4 0.0.1-0.1.0 0.0.1-0.1.0
vue-sim-captcha 0.0.1-0.0.3 0.0.1-0.1.1 0.0.1-0.1.1
SimCaptcha nuget downloads
SimCaptcha.AspNetCore nuget downloads

Q&A

Q: 为什么选择 SimCaptcha ? A: 流行开源验证码及商业验证码 对照表如下:
TODO: 流行开源验证码及商业验证码 对照表

环境

  • 运行环境: .NET Framework (>= 4.0) or .NET Standard (>= 2.0)
  • 开发环境: Visual Studio Community 2019

相关项目

鸣谢

Donate

SimCaptcha is an MIT licensed open source project and completely free to use. However, the amount of effort needed to maintain and develop new features for the project is not sustainable without proper financial backing.

We accept donations through these channels:

Author

SimCaptcha © yiyun, Released under the MIT License.
Authored and maintained by yiyun with help from contributors (list).

GitHub @yiyungent

MIT License Copyright (c) 2019 yiyun 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.

简介

✅ 一个简单易用的点触验证码 (前端+后端) 展开 收起
C# 等 2 种语言
MIT
取消

贡献者

全部

近期动态

加载更多
不能加载更多了
C#
1
https://gitee.com/yiyungent/SimCaptcha.git
git@gitee.com:yiyungent/SimCaptcha.git
yiyungent
SimCaptcha
SimCaptcha
master

搜索帮助

14c37bed 8189591 565d56ea 8189591