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
49f8cfd5
Commit
49f8cfd5
authored
Apr 13, 2024
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update jwt middleware
parent
b27004da
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 addition
and
11 deletions
+1
-11
jwt.go
server/route/api/auth/jwt.go
+0
-10
server.go
server/server.go
+1
-1
No files found.
server/route/api/auth/jwt.go
View file @
49f8cfd5
...
@@ -53,12 +53,6 @@ func JWTMiddleware(storeInstance *store.Store, next echo.HandlerFunc, secret str
...
@@ -53,12 +53,6 @@ func JWTMiddleware(storeInstance *store.Store, next echo.HandlerFunc, secret str
return
func
(
c
echo
.
Context
)
error
{
return
func
(
c
echo
.
Context
)
error
{
ctx
:=
c
.
Request
()
.
Context
()
ctx
:=
c
.
Request
()
.
Context
()
path
:=
c
.
Request
()
.
URL
.
Path
path
:=
c
.
Request
()
.
URL
.
Path
method
:=
c
.
Request
()
.
Method
// Skip validation for server status endpoints.
if
util
.
HasPrefixes
(
path
,
"/api/v1/ping"
,
"/api/v1/status"
)
&&
method
==
http
.
MethodGet
{
return
next
(
c
)
}
accessToken
:=
findAccessToken
(
c
)
accessToken
:=
findAccessToken
(
c
)
if
accessToken
==
""
{
if
accessToken
==
""
{
...
@@ -66,10 +60,6 @@ func JWTMiddleware(storeInstance *store.Store, next echo.HandlerFunc, secret str
...
@@ -66,10 +60,6 @@ func JWTMiddleware(storeInstance *store.Store, next echo.HandlerFunc, secret str
if
util
.
HasPrefixes
(
path
,
"/o"
)
{
if
util
.
HasPrefixes
(
path
,
"/o"
)
{
return
next
(
c
)
return
next
(
c
)
}
}
// When the request is not authenticated, we allow the user to access the memo endpoints for those public memos.
if
util
.
HasPrefixes
(
path
,
"/api/v1/idp"
,
"/api/v1/memo"
,
"/api/v1/user"
)
&&
path
!=
"/api/v1/user"
&&
method
==
http
.
MethodGet
{
return
next
(
c
)
}
return
echo
.
NewHTTPError
(
http
.
StatusUnauthorized
,
"Missing access token"
)
return
echo
.
NewHTTPError
(
http
.
StatusUnauthorized
,
"Missing access token"
)
}
}
...
...
server/server.go
View file @
49f8cfd5
...
@@ -88,7 +88,7 @@ func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store
...
@@ -88,7 +88,7 @@ func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store
// Create and register resource public routes.
// Create and register resource public routes.
resource
.
NewResourceService
(
s
.
Profile
,
s
.
Store
)
.
RegisterRoutes
(
publicGroup
)
resource
.
NewResourceService
(
s
.
Profile
,
s
.
Store
)
.
RegisterRoutes
(
publicGroup
)
// Create and register
rss public
routes.
// Create and register
RSS
routes.
rss
.
NewRSSService
(
s
.
Profile
,
s
.
Store
)
.
RegisterRoutes
(
rootGroup
)
rss
.
NewRSSService
(
s
.
Profile
,
s
.
Store
)
.
RegisterRoutes
(
rootGroup
)
apiV2Service
:=
apiv2
.
NewAPIV2Service
(
s
.
Secret
,
profile
,
store
,
s
.
Profile
.
Port
+
1
)
apiV2Service
:=
apiv2
.
NewAPIV2Service
(
s
.
Secret
,
profile
,
store
,
s
.
Profile
.
Port
+
1
)
...
...
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