Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
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
张蕾
Geth-Modification
Commits
7813b675
Unverified
Commit
7813b675
authored
Aug 30, 2022
by
Seungbae Yu
Committed by
GitHub
Aug 30, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
node: change JWT error status to 401 Unauthorized (#25629)
parent
8df8eb4e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
jwt_handler.go
node/jwt_handler.go
+7
-7
No files found.
node/jwt_handler.go
View file @
7813b675
...
...
@@ -51,7 +51,7 @@ func (handler *jwtHandler) ServeHTTP(out http.ResponseWriter, r *http.Request) {
strToken
=
strings
.
TrimPrefix
(
auth
,
"Bearer "
)
}
if
len
(
strToken
)
==
0
{
http
.
Error
(
out
,
"missing token"
,
http
.
Status
Forbidden
)
http
.
Error
(
out
,
"missing token"
,
http
.
Status
Unauthorized
)
return
}
// We explicitly set only HS256 allowed, and also disables the
...
...
@@ -63,17 +63,17 @@ func (handler *jwtHandler) ServeHTTP(out http.ResponseWriter, r *http.Request) {
switch
{
case
err
!=
nil
:
http
.
Error
(
out
,
err
.
Error
(),
http
.
Status
Forbidden
)
http
.
Error
(
out
,
err
.
Error
(),
http
.
Status
Unauthorized
)
case
!
token
.
Valid
:
http
.
Error
(
out
,
"invalid token"
,
http
.
Status
Forbidden
)
http
.
Error
(
out
,
"invalid token"
,
http
.
Status
Unauthorized
)
case
!
claims
.
VerifyExpiresAt
(
time
.
Now
(),
false
)
:
// optional
http
.
Error
(
out
,
"token is expired"
,
http
.
Status
Forbidden
)
http
.
Error
(
out
,
"token is expired"
,
http
.
Status
Unauthorized
)
case
claims
.
IssuedAt
==
nil
:
http
.
Error
(
out
,
"missing issued-at"
,
http
.
Status
Forbidden
)
http
.
Error
(
out
,
"missing issued-at"
,
http
.
Status
Unauthorized
)
case
time
.
Since
(
claims
.
IssuedAt
.
Time
)
>
jwtExpiryTimeout
:
http
.
Error
(
out
,
"stale token"
,
http
.
Status
Forbidden
)
http
.
Error
(
out
,
"stale token"
,
http
.
Status
Unauthorized
)
case
time
.
Until
(
claims
.
IssuedAt
.
Time
)
>
jwtExpiryTimeout
:
http
.
Error
(
out
,
"future token"
,
http
.
Status
Forbidden
)
http
.
Error
(
out
,
"future token"
,
http
.
Status
Unauthorized
)
default
:
handler
.
next
.
ServeHTTP
(
out
,
r
)
}
...
...
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