Skip to content

fix: login vulnerability #863

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion web/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,12 @@ func Auth(r *gin.Engine, timeout int) *jwt.GinJWTMiddleware {
}
})
r.POST("/auth/login", authMiddleware.LoginHandler)
r.POST("/auth/register", updateUser)
// 只有在系统未初始化时才注册公开的 /auth/register 路由
adminPass, _ := core.GetValue("admin_pass")
if adminPass == "" {
r.POST("/auth/register", updateUser)
}

authO := r.Group("/auth")
authO.Use(authMiddleware.MiddlewareFunc())
{
Expand All @@ -173,6 +178,8 @@ func Auth(r *gin.Engine, timeout int) *jwt.GinJWTMiddleware {
authO.POST("/reset_pass", updateUser)
authO.POST("/logout", authMiddleware.LogoutHandler)
authO.POST("/refresh_token", authMiddleware.RefreshHandler)
// 系统初始化后,注册功能只能在授权后使用
authO.POST("/register", updateUser)
}
return authMiddleware
}