feat: update client middleware
This commit is contained in:
parent
d31abdd4d1
commit
fde36e45b1
|
|
@ -21,14 +21,19 @@ var excludedPaths = []string{
|
|||
"/health/*",
|
||||
"/clients",
|
||||
"/clients/*",
|
||||
"/metrics",
|
||||
"/metrics/*",
|
||||
"*/viewer/*",
|
||||
}
|
||||
|
||||
// isPathExcluded checks if the given path should be excluded from client key validation
|
||||
func isPathExcluded(path string) bool {
|
||||
for _, excludedPath := range excludedPaths {
|
||||
if strings.HasPrefix(excludedPath, "*") {
|
||||
if strings.HasPrefix(excludedPath, "*") && strings.HasSuffix(excludedPath, "*") {
|
||||
// Handle wildcard at both beginning and end (e.g., "*/viewer/*")
|
||||
pattern := excludedPath[1 : len(excludedPath)-1] // Remove * from both ends
|
||||
if strings.Contains(path, pattern) {
|
||||
return true
|
||||
}
|
||||
} else if strings.HasPrefix(excludedPath, "*") {
|
||||
// Handle wildcard at the beginning
|
||||
if strings.HasSuffix(path, excludedPath[1:]) {
|
||||
return true
|
||||
|
|
|
|||
Loading…
Reference in New Issue