Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Kplcloud
Commits
3818f009
Commit
3818f009
authored
5 years ago
by
icowan
Browse files
Options
Download
Email Patches
Plain Diff
fix 下载日志提示"没有授权登陆"的错误信息
parent
01b658a8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/middleware/transport.go
+3
-0
src/middleware/transport.go
src/pkg/pod/transport.go
+1
-1
src/pkg/pod/transport.go
with
4 additions
and
1 deletion
+4
-1
src/middleware/transport.go
+
3
-
0
View file @
3818f009
...
...
@@ -10,12 +10,14 @@ package middleware
import
(
"context"
"github.com/go-kit/kit/auth/casbin"
"github.com/go-kit/kit/auth/jwt"
"github.com/go-kit/kit/transport/http"
"github.com/gorilla/mux"
kplcasbin
"github.com/kplcloud/kplcloud/src/casbin"
"github.com/kplcloud/kplcloud/src/util/uid"
stdhttp
"net/http"
"strconv"
"strings"
)
func
NamespaceToContext
()
http
.
RequestFunc
{
...
...
@@ -59,6 +61,7 @@ func CookieToContext() http.RequestFunc {
return
func
(
ctx
context
.
Context
,
r
*
stdhttp
.
Request
)
context
.
Context
{
if
c
,
err
:=
r
.
Cookie
(
"Authorization"
);
err
==
nil
{
ctx
=
context
.
WithValue
(
ctx
,
http
.
ContextKeyRequestAuthorization
,
c
.
Value
)
ctx
=
context
.
WithValue
(
ctx
,
jwt
.
JWTTokenContextKey
,
strings
.
Split
(
c
.
Value
,
"Bearer "
)[
1
])
r
.
Header
.
Set
(
string
(
http
.
ContextKeyRequestAuthorization
),
c
.
Value
)
}
return
ctx
...
...
This diff is collapsed.
Click to expand it.
src/pkg/pod/transport.go
+
1
-
1
View file @
3818f009
...
...
@@ -36,8 +36,8 @@ func MakeHandler(svc Service, logger log.Logger, repository repository.Repositor
opts
:=
[]
kithttp
.
ServerOption
{
kithttp
.
ServerErrorLogger
(
logger
),
kithttp
.
ServerErrorEncoder
(
encode
.
EncodeError
),
kithttp
.
ServerBefore
(
middleware
.
CookieToContext
()),
kithttp
.
ServerBefore
(
kithttp
.
PopulateRequestContext
),
kithttp
.
ServerBefore
(
middleware
.
CookieToContext
()),
kithttp
.
ServerBefore
(
kitjwt
.
HTTPToContext
()),
kithttp
.
ServerBefore
(
middleware
.
NamespaceToContext
()),
kithttp
.
ServerBefore
(
middleware
.
CasbinToContext
()),
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment