Skip to content

Commit

Permalink
#2486 菜单绑定API权限
Browse files Browse the repository at this point in the history
  • Loading branch information
tangjiawei committed Jan 13, 2025
1 parent e4c24fa commit 0a87116
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions platform-core/api/middleware/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ func ReadFormFile(c *gin.Context, fileKey string) (fileName string, fileBytes []
}

func validateMenuApi(roles []string, path, method string) (legal bool) {
// 防止ip 之类数据配置不上
path = strings.ReplaceAll(path, ".", "")
for _, menuApi := range models.MenuApiGlobalList {
for _, role := range roles {
Expand All @@ -106,6 +107,6 @@ func validateMenuApi(roles []string, path, method string) (legal bool) {
}

func buildRegexPattern(template string) string {
// 将 ${variable} 替换为 (\w+)
return regexp.MustCompile(`\$\{[\w.-]+\}`).ReplaceAllString(template, `(\w+)`)
// 将 ${variable} 替换为 (\w+) ,并且严格匹配
return "^" + regexp.MustCompile(`\$\{[\w.-]+\}`).ReplaceAllString(template, `(\w+)`) + "$"
}

0 comments on commit 0a87116

Please sign in to comment.