Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
745902e8
Commit
745902e8
authored
Sep 25, 2023
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update access token order
parent
ad3487a9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
8 deletions
+9
-8
jwt.go
api/v1/jwt.go
+7
-7
acl.go
api/v2/acl.go
+2
-1
No files found.
api/v1/jwt.go
View file @
745902e8
...
...
@@ -36,15 +36,15 @@ func extractTokenFromHeader(c echo.Context) (string, error) {
}
func
findAccessToken
(
c
echo
.
Context
)
string
{
accessToken
:=
""
cookie
,
_
:=
c
.
Cookie
(
auth
.
AccessTokenCookieName
)
if
cookie
!=
nil
{
accessToken
=
cookie
.
Value
}
// Check the HTTP request header first.
accessToken
,
_
:=
extractTokenFromHeader
(
c
)
if
accessToken
==
""
{
accessToken
,
_
=
extractTokenFromHeader
(
c
)
// Check the cookie.
cookie
,
_
:=
c
.
Cookie
(
auth
.
AccessTokenCookieName
)
if
cookie
!=
nil
{
accessToken
=
cookie
.
Value
}
}
return
accessToken
}
...
...
api/v2/acl.go
View file @
745902e8
...
...
@@ -127,6 +127,7 @@ func (in *GRPCAuthInterceptor) authenticate(ctx context.Context, accessToken str
}
func
getTokenFromMetadata
(
md
metadata
.
MD
)
(
string
,
error
)
{
// Check the HTTP request header first.
authorizationHeaders
:=
md
.
Get
(
"Authorization"
)
if
len
(
md
.
Get
(
"Authorization"
))
>
0
{
authHeaderParts
:=
strings
.
Fields
(
authorizationHeaders
[
0
])
...
...
@@ -135,7 +136,7 @@ func getTokenFromMetadata(md metadata.MD) (string, error) {
}
return
authHeaderParts
[
1
],
nil
}
//
check the HTTP cookie
//
Check the cookie header.
var
accessToken
string
for
_
,
t
:=
range
append
(
md
.
Get
(
"grpcgateway-cookie"
),
md
.
Get
(
"cookie"
)
...
)
{
header
:=
http
.
Header
{}
...
...
Write
Preview
Markdown
is supported
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