feat: support dummy sk- prefix for token (#82)

This commit is contained in:
JustSong
2023-05-17 17:03:36 +08:00
parent efc744ca35
commit 73d5e0f283
2 changed files with 2 additions and 2 deletions

View File

@@ -85,6 +85,8 @@ func RootAuth() func(c *gin.Context) {
func TokenAuth() func(c *gin.Context) {
return func(c *gin.Context) {
key := c.Request.Header.Get("Authorization")
key = strings.TrimPrefix(key, "Bearer ")
key = strings.TrimPrefix(key, "sk-")
parts := strings.Split(key, "-")
key = parts[0]
token, err := model.ValidateUserToken(key)