Skip to content

Commit

Permalink
refactor(middlewares/auth): 修正各个 SecurityScheme.Scheme 值的错误
Browse files Browse the repository at this point in the history
  • Loading branch information
caixw committed Dec 30, 2024
1 parent b3fdc03 commit b527a7c
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions middlewares/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
)

const (
Bearer = "bearer "
Basic = "basic "
Bearer = "bearer " // bearer 验证类型的前缀,属部带空格。
Basic = "basic " // basic 验证类型的前缀,属部带空格。
)

// Auth 登录凭证的验证接口
Expand Down
2 changes: 1 addition & 1 deletion middlewares/auth/basic/basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,6 @@ func SecurityScheme(id string, desc web.LocaleStringer) *openapi.SecurityScheme
ID: id,
Type: openapi.SecuritySchemeTypeHTTP,
Description: desc,
Scheme: auth.Basic,
Scheme: auth.Basic[:len(auth.Basic)-1],
}
}
2 changes: 1 addition & 1 deletion middlewares/auth/jwt/jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func SecurityScheme(id string, desc web.LocaleStringer) *openapi.SecurityScheme
ID: id,
Type: openapi.SecuritySchemeTypeHTTP,
Description: desc,
Scheme: auth.Bearer,
Scheme: auth.Bearer[:len(auth.Bearer)-1],
BearerFormat: "JWT",
}
}
2 changes: 1 addition & 1 deletion middlewares/auth/temporary/temporary.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,6 @@ func SecurityScheme(id string, desc web.LocaleStringer, query string) *openapi.S
ID: id,
Type: openapi.SecuritySchemeTypeHTTP,
Description: desc,
Scheme: auth.Bearer,
Scheme: auth.Bearer[:len(auth.Bearer)-1],
}
}
2 changes: 1 addition & 1 deletion middlewares/auth/token/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,6 @@ func SecurityScheme(id string, desc web.LocaleStringer) *openapi.SecurityScheme
ID: id,
Type: openapi.SecuritySchemeTypeHTTP,
Description: desc,
Scheme: auth.Bearer,
Scheme: auth.Bearer[:len(auth.Bearer)-1],
}
}

0 comments on commit b527a7c

Please sign in to comment.