Files
be.ems/src/modules/auth/auth.go
TsMask 56991a0b49 feat: Implement Oauth2 login log service and repository
- Added Oauth2LogLoginService for managing user authorization logs.
- Implemented methods for inserting logs, cleaning logs, and exporting log data.
- Created a new file for Oauth2 login log service.

refactor: Remove unused open_api module

- Deleted the open_api.go file as it was not utilized in the project.

fix: Update error codes in SysProfileController

- Changed error codes for binding errors and user authentication errors to more descriptive values.

fix: Update cache handling in SysConfig and SysDictType services

- Modified Redis set operations to include expiration time for cached values.

refactor: Update middleware authorization checks

- Replaced PreAuthorize middleware with AuthorizeUser across multiple routes in system and tool modules for consistency.

chore: Clean up trace and ws modules

- Updated middleware authorization in trace and ws modules to use AuthorizeUser.
2025-04-27 11:07:34 +08:00

86 lines
1.9 KiB
Go

package auth
import (
"be.ems/src/framework/logger"
"be.ems/src/framework/middleware"
"be.ems/src/modules/auth/controller"
"github.com/gin-gonic/gin"
)
// 模块路由注册
func Setup(router *gin.Engine) {
logger.Infof("开始加载 ====> auth 模块路由")
// 系统可暴露的配置信息
router.GET("/sys-conf", controller.NewSysConf.Handler)
// 系统引导初始化
guideGroup := router.Group("/bootloader")
{
guideGroup.POST("", controller.NewBootloader.Start)
guideGroup.PUT("", middleware.AuthorizeUser(nil), controller.NewBootloader.Done)
guideGroup.DELETE("", middleware.AuthorizeUser(nil), controller.NewBootloader.Reset)
guideGroup.PUT("/account", middleware.AuthorizeUser(nil), controller.NewBootloader.Account)
}
// 验证码操作
router.GET("/captcha-image",
middleware.RateLimit(middleware.LimitOption{
Time: 300,
Count: 60,
Type: middleware.LIMIT_IP,
}),
controller.NewCaptcha.Image,
)
// 账号身份操作
{
router.POST("/auth/login",
middleware.RateLimit(middleware.LimitOption{
Time: 180,
Count: 15,
Type: middleware.LIMIT_IP,
}),
controller.NewAccount.Login,
)
router.POST("/auth/logout",
middleware.RateLimit(middleware.LimitOption{
Time: 120,
Count: 15,
Type: middleware.LIMIT_IP,
}),
controller.NewAccount.Logout,
)
router.POST("/auth/refresh-token",
middleware.RateLimit(middleware.LimitOption{
Time: 60,
Count: 5,
Type: middleware.LIMIT_IP,
}),
controller.NewAccount.RefreshToken,
)
router.GET("/me",
middleware.AuthorizeUser(nil),
controller.NewAccount.Me,
)
router.GET("/router",
middleware.AuthorizeUser(nil),
controller.NewAccount.Router,
)
}
// 账号注册操作
{
router.POST("/auth/register",
middleware.RateLimit(middleware.LimitOption{
Time: 300,
Count: 10,
Type: middleware.LIMIT_IP,
}),
controller.NewRegister.Register,
)
}
}