feat(企微签到):逻辑:员工使用企微扫码后直接跳出签到页面,在签到页面对该课程进行点击签到!
deploy-hxtesting / build-and-deploy (push) Successful in 1m14s
deploy-hxtesting / build-and-deploy (push) Successful in 1m14s
规则:1.签到要校验是否为培训当天签到,如果不是当天扫码签到则进行友好提示;2. 签到需提供员工工号及随机时间戳(超过签到二维码有效期后需重新扫码签到);3.签到二维码每5分钟自动更新一次(更新后之前扫码签到自动作废需重新扫码); 补充说明:1.签到页面需展示该签到课程相关信息;2.展示签到倒计时还有多久过期,过期后需重新扫码进行优化提示;3.签到后提示签到成功!自动登录进入平台系统并进入该课程详情页面
This commit is contained in:
1 parent
9950a28346
commit
f43fbef5db
24 files changed
+1336
-67
No files matched your search
@@ -64,6 +64,11 @@ var noAuthAPI = map[string][]string{
|
||||
// template key + 20-day expiry), never by caller-supplied ids. HEAD is
|
||||
// allowed for the same preview-validation reason as /files/presigned.
|
||||
"/api/v1/training/templates/signed-file": {"GET", "HEAD"},
|
||||
// 企微扫码签到免登(2026-11 需求):学员在企微内置浏览器打开落地页时没有
|
||||
// 平台会话,免登链路凭「未过期签到码 token(state)+ 一次性 OAuth code」
|
||||
// 鉴权,路由级 IP 限流承担防滥用;checkin-page(登录态)不在此列。
|
||||
"/api/v1/training/wecom/checkin-auth": {"GET"},
|
||||
"/api/v1/training/wecom/checkin-session": {"POST"},
|
||||
// IM platforms (Feishu, Slack, etc.) commonly issue a HEAD request
|
||||
// before GET to validate Content-Type / Content-Length when rendering
|
||||
// image previews — both verbs must be allowed for image links to work.
|
||||
|
||||
@@ -119,9 +119,30 @@ var publicAuthLimiter = newIPRateLimiter(
|
||||
// through the project's AppError type so it flows through the same
|
||||
// error middleware as the rest of the auth surface.
|
||||
func PublicAuthRateLimit() gin.HandlerFunc {
|
||||
return rateLimitWith(publicAuthLimiter)
|
||||
}
|
||||
|
||||
// wecomCheckinRateLimitMax 培训扫码免登专用预算:教室场景几十名学员共享同一
|
||||
// 办公网出口 IP,若复用 30/min 的共享 auth 限流,集中扫码会整批 429。签到
|
||||
// 链路独立限流器放宽到 600/min/IP(百人级课堂在 5 分钟轮换窗口内仍宽裕),
|
||||
// 同时保留对脚本刷 code/token 的约束。
|
||||
const wecomCheckinRateLimitMax = 600
|
||||
|
||||
// wecomCheckinLimiter 独立桶,不与 share-link/auth 端点共享预算。
|
||||
var wecomCheckinLimiter = newIPRateLimiter(publicAuthRateLimitWindow, wecomCheckinRateLimitMax)
|
||||
|
||||
// WecomCheckinRateLimit rate-limits the anonymous WeCom scan-checkin endpoints
|
||||
// (checkin-auth / checkin-session) by client IP.
|
||||
func WecomCheckinRateLimit() gin.HandlerFunc {
|
||||
return rateLimitWith(wecomCheckinLimiter)
|
||||
}
|
||||
|
||||
// rateLimitWith adapts an ipRateLimiter into Gin middleware; 429 flows through
|
||||
// the project's AppError middleware like the rest of the auth surface.
|
||||
func rateLimitWith(l *ipRateLimiter) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
ip := c.ClientIP()
|
||||
if !publicAuthLimiter.allow(ip) {
|
||||
if !l.allow(ip) {
|
||||
c.Error(&apperrors.AppError{
|
||||
Code: apperrors.ErrTooManyRequests,
|
||||
Message: "too many requests; please retry shortly",
|
||||
|
||||
Reference in new issue
Block a user