mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
chore: update db connection params (#1960)
This commit is contained in:
@ -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
|
|||||||
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"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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{})
|
||||||
|
@ -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
|
|||||||
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
|
||||||
|
@ -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=10000&_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)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user