From b527a7c27188a3c2973aa05e2725f8c289ee9ac1 Mon Sep 17 00:00:00 2001 From: caixw Date: Mon, 30 Dec 2024 12:10:47 +0800 Subject: [PATCH] =?UTF-8?q?refactor(middlewares/auth):=20=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=E5=90=84=E4=B8=AA=20SecurityScheme.Scheme=20=E5=80=BC?= =?UTF-8?q?=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- middlewares/auth/auth.go | 4 ++-- middlewares/auth/basic/basic.go | 2 +- middlewares/auth/jwt/jwt.go | 2 +- middlewares/auth/temporary/temporary.go | 2 +- middlewares/auth/token/token.go | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/middlewares/auth/auth.go b/middlewares/auth/auth.go index e54e47c..52542e3 100644 --- a/middlewares/auth/auth.go +++ b/middlewares/auth/auth.go @@ -12,8 +12,8 @@ import ( ) const ( - Bearer = "bearer " - Basic = "basic " + Bearer = "bearer " // bearer 验证类型的前缀,属部带空格。 + Basic = "basic " // basic 验证类型的前缀,属部带空格。 ) // Auth 登录凭证的验证接口 diff --git a/middlewares/auth/basic/basic.go b/middlewares/auth/basic/basic.go index 923f23a..aaed975 100644 --- a/middlewares/auth/basic/basic.go +++ b/middlewares/auth/basic/basic.go @@ -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], } } diff --git a/middlewares/auth/jwt/jwt.go b/middlewares/auth/jwt/jwt.go index f383b25..7f63dac 100644 --- a/middlewares/auth/jwt/jwt.go +++ b/middlewares/auth/jwt/jwt.go @@ -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", } } diff --git a/middlewares/auth/temporary/temporary.go b/middlewares/auth/temporary/temporary.go index 92a5318..b1960a7 100644 --- a/middlewares/auth/temporary/temporary.go +++ b/middlewares/auth/temporary/temporary.go @@ -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], } } diff --git a/middlewares/auth/token/token.go b/middlewares/auth/token/token.go index b6ddc0b..2a6a6d8 100644 --- a/middlewares/auth/token/token.go +++ b/middlewares/auth/token/token.go @@ -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], } }