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
40a30d46
Unverified
Commit
40a30d46
authored
Jul 15, 2023
by
boojack
Committed by
GitHub
Jul 15, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update db connection params (#1960)
parent
6b17a27a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
4 deletions
+7
-4
jwt.go
api/v1/jwt.go
+3
-1
system.go
api/v1/system.go
+1
-0
server.go
server/server.go
+2
-2
db.go
store/db/db.go
+1
-1
No files found.
api/v1/jwt.go
View file @
40a30d46
...
@@ -113,12 +113,13 @@ func JWTMiddleware(server *APIV1Service, next echo.HandlerFunc, secret string) e
...
@@ -113,12 +113,13 @@ func JWTMiddleware(server *APIV1Service, next echo.HandlerFunc, secret string) e
})
})
if
!
accessToken
.
Valid
{
if
!
accessToken
.
Valid
{
auth
.
RemoveTokensAndCookies
(
c
)
return
echo
.
NewHTTPError
(
http
.
StatusUnauthorized
,
"Invalid access token."
)
return
echo
.
NewHTTPError
(
http
.
StatusUnauthorized
,
"Invalid access token."
)
}
}
if
!
audienceContains
(
claims
.
Audience
,
auth
.
AccessTokenAudienceName
)
{
if
!
audienceContains
(
claims
.
Audience
,
auth
.
AccessTokenAudienceName
)
{
return
echo
.
NewHTTPError
(
http
.
StatusUnauthorized
,
fmt
.
Sprintf
(
"Invalid access token, audience mismatch, got %q, expected %q."
,
claims
.
Audience
,
auth
.
AccessTokenAudienceName
))
return
echo
.
NewHTTPError
(
http
.
StatusUnauthorized
,
fmt
.
Sprintf
(
"Invalid access token, audience mismatch, got %q, expected %q."
,
claims
.
Audience
,
auth
.
AccessTokenAudienceName
))
}
}
generateToken
:=
time
.
Until
(
claims
.
ExpiresAt
.
Time
)
<
auth
.
RefreshThresholdDuration
generateToken
:=
time
.
Until
(
claims
.
ExpiresAt
.
Time
)
<
auth
.
RefreshThresholdDuration
if
err
!=
nil
{
if
err
!=
nil
{
var
ve
*
jwt
.
ValidationError
var
ve
*
jwt
.
ValidationError
...
@@ -129,6 +130,7 @@ func JWTMiddleware(server *APIV1Service, next echo.HandlerFunc, secret string) e
...
@@ -129,6 +130,7 @@ func JWTMiddleware(server *APIV1Service, next echo.HandlerFunc, secret string) e
generateToken
=
true
generateToken
=
true
}
}
}
else
{
}
else
{
auth
.
RemoveTokensAndCookies
(
c
)
return
echo
.
NewHTTPError
(
http
.
StatusUnauthorized
,
errors
.
Wrap
(
err
,
"Invalid or expired access token"
))
return
echo
.
NewHTTPError
(
http
.
StatusUnauthorized
,
errors
.
Wrap
(
err
,
"Invalid or expired access token"
))
}
}
}
}
...
...
api/v1/system.go
View file @
40a30d46
...
@@ -77,6 +77,7 @@ func (s *APIV1Service) registerSystemRoutes(g *echo.Group) {
...
@@ -77,6 +77,7 @@ func (s *APIV1Service) registerSystemRoutes(g *echo.Group) {
// data desensitize
// data desensitize
systemStatus
.
Host
.
OpenID
=
""
systemStatus
.
Host
.
OpenID
=
""
systemStatus
.
Host
.
Email
=
""
systemStatus
.
Host
.
Email
=
""
systemStatus
.
Host
.
AvatarURL
=
""
}
}
systemSettingList
,
err
:=
s
.
Store
.
ListSystemSettings
(
ctx
,
&
store
.
FindSystemSetting
{})
systemSettingList
,
err
:=
s
.
Store
.
ListSystemSettings
(
ctx
,
&
store
.
FindSystemSetting
{})
...
...
server/server.go
View file @
40a30d46
...
@@ -75,7 +75,7 @@ func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store
...
@@ -75,7 +75,7 @@ func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store
serverID
,
err
:=
s
.
getSystemServerID
(
ctx
)
serverID
,
err
:=
s
.
getSystemServerID
(
ctx
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
fmt
.
Errorf
(
"failed to retrieve system server ID: %w"
,
err
)
}
}
s
.
ID
=
serverID
s
.
ID
=
serverID
...
@@ -85,7 +85,7 @@ func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store
...
@@ -85,7 +85,7 @@ func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store
if
profile
.
Mode
==
"prod"
{
if
profile
.
Mode
==
"prod"
{
secret
,
err
=
s
.
getSystemSecretSessionName
(
ctx
)
secret
,
err
=
s
.
getSystemSecretSessionName
(
ctx
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
fmt
.
Errorf
(
"failed to retrieve system secret session name: %w"
,
err
)
}
}
}
}
s
.
Secret
=
secret
s
.
Secret
=
secret
...
...
store/db/db.go
View file @
40a30d46
...
@@ -43,7 +43,7 @@ func (db *DB) Open(ctx context.Context) (err error) {
...
@@ -43,7 +43,7 @@ func (db *DB) Open(ctx context.Context) (err error) {
}
}
// Connect to the database without foreign_key.
// Connect to the database without foreign_key.
sqliteDB
,
err
:=
sql
.
Open
(
"sqlite"
,
db
.
profile
.
DSN
+
"?cache=
shared&_foreign_keys=
0&_journal_mode=WAL"
)
sqliteDB
,
err
:=
sql
.
Open
(
"sqlite"
,
db
.
profile
.
DSN
+
"?cache=
private&_foreign_keys=0&_busy_timeout=1000
0&_journal_mode=WAL"
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to open db with dsn: %s, err: %w"
,
db
.
profile
.
DSN
,
err
)
return
fmt
.
Errorf
(
"failed to open db with dsn: %s, err: %w"
,
db
.
profile
.
DSN
,
err
)
}
}
...
...
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