From bd51b15824fc9bb3383aaa3ede018997bd989111 Mon Sep 17 00:00:00 2001 From: Abhishek Shroff Date: Mon, 21 Jul 2025 01:37:22 +0530 Subject: [PATCH] [server][api] Accept scopes as a comma-separated string --- server/internal/api/v1/user/keys.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/internal/api/v1/user/keys.go b/server/internal/api/v1/user/keys.go index 536c29af..0d6424b5 100644 --- a/server/internal/api/v1/user/keys.go +++ b/server/internal/api/v1/user/keys.go @@ -3,6 +3,7 @@ package user import ( "fmt" "net/http" + "strings" "time" "codeberg.org/shroff/phylum/server/internal/api/authenticator" @@ -57,7 +58,7 @@ func handleKeysList(c *gin.Context) { func handleKeysGenerate(c *gin.Context) { var params struct { - Scopes []string `json:"scopes" form:"scopes" binding:"required"` + Scopes string `json:"scopes" form:"scopes" binding:"required"` Description string `json:"description" form:"description"` Expires time.Time `json:"expires" form:"expires"` } @@ -82,7 +83,7 @@ func handleKeysGenerate(c *gin.Context) { expires.Time = params.Expires expires.Valid = true } - if a, err := auth.NewAuth(a, expires, params.Scopes); err != nil { + if a, err := auth.NewAuth(a, expires, strings.Split(params.Scopes, ",")); err != nil { panic(err) } else if id, key, token, err := auth.GenerateAPIKey(db.Get(c.Request.Context()), a, params.Description); err != nil { panic(err)