feat: switch to global auth and tenant route prefix
This commit is contained in:
@@ -164,17 +164,10 @@ func isPublicRoute(ctx fiber.Ctx) bool {
|
||||
}
|
||||
}
|
||||
|
||||
if method == fiber.MethodPost && path == "/v1/webhook/payment/notify" {
|
||||
if method == fiber.MethodPost && (path == "/v1/webhook/payment/notify" || path == "/v1/auth/otp" || path == "/v1/auth/login") {
|
||||
return true
|
||||
}
|
||||
|
||||
if method == fiber.MethodPost {
|
||||
switch path {
|
||||
case "/v1/auth/otp", "/v1/auth/login":
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
if method == fiber.MethodPut && strings.HasPrefix(path, "/v1/storage/") {
|
||||
return true
|
||||
}
|
||||
@@ -186,25 +179,41 @@ func isSuperPublicRoute(ctx fiber.Ctx) bool {
|
||||
path := ctx.Path()
|
||||
method := ctx.Method()
|
||||
|
||||
if method == fiber.MethodPost && path == "/super/v1/auth/login" {
|
||||
return true
|
||||
if method == fiber.MethodPost {
|
||||
if path == "/super/v1/auth/login" || path == "/auth/login" || path == "/login" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
if method == fiber.MethodGet {
|
||||
if path == "/super/v1/auth/token" || path == "/auth/token" || path == "/token" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func normalizeTenantPath(path string) string {
|
||||
if !strings.HasPrefix(path, "/t/") {
|
||||
if strings.HasPrefix(path, "/t/") {
|
||||
rest := strings.TrimPrefix(path, "/t/")
|
||||
slash := strings.Index(rest, "/")
|
||||
if slash == -1 {
|
||||
return path
|
||||
}
|
||||
rest = rest[slash:]
|
||||
if strings.HasPrefix(rest, "/v1") {
|
||||
return rest
|
||||
}
|
||||
return path
|
||||
}
|
||||
rest := strings.TrimPrefix(path, "/t/")
|
||||
slash := strings.Index(rest, "/")
|
||||
if slash == -1 {
|
||||
return path
|
||||
}
|
||||
rest = rest[slash:]
|
||||
if strings.HasPrefix(rest, "/v1") {
|
||||
return rest
|
||||
if strings.HasPrefix(path, "/v1/t/") {
|
||||
rest := strings.TrimPrefix(path, "/v1/t/")
|
||||
slash := strings.Index(rest, "/")
|
||||
if slash == -1 {
|
||||
return path
|
||||
}
|
||||
return "/v1" + rest[slash:]
|
||||
}
|
||||
return path
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user