This repository was archived by the owner on Jul 12, 2023. It is now read-only.
File tree 3 files changed +10
-2
lines changed
3 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ package config
16
16
17
17
import (
18
18
"context"
19
+ "fmt"
19
20
"time"
20
21
21
22
"github.com/google/exposure-notifications-verification-server/pkg/database"
@@ -65,6 +66,7 @@ func (c *CleanupConfig) Validate() error {
65
66
{c .CleanupPeriod , "CLEANUP_PERIOD" },
66
67
{c .VerificationCodeMaxAge , "VERIFICATION_CODE_MAX_AGE" },
67
68
{c .VerificationTokenMaxAge , "VERIFICATION_TOKEN_MAX_AGE" },
69
+ {c .AuditEntryMaxAge , "AUDIT_ENTRY_MAX_AGE" },
68
70
}
69
71
70
72
for _ , f := range fields {
@@ -73,6 +75,11 @@ func (c *CleanupConfig) Validate() error {
73
75
}
74
76
}
75
77
78
+ // Audit entries need to persist for at least 7 days. The default is 30d ays.
79
+ if c .AuditEntryMaxAge < 7 * 24 * time .Hour {
80
+ return fmt .Errorf ("AUDIT_ENTRY_MAX_AGE must be at least 7 days" )
81
+ }
82
+
76
83
return nil
77
84
}
78
85
Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ type AuditEntry struct {
51
51
52
52
// TargetID and TargetDisplay are the same as the actor, but are for the
53
53
// target of the action.
54
- TargetID string `gorm:"column:target_name ; type:text; not null;"`
54
+ TargetID string `gorm:"column:target_id ; type:text; not null;"`
55
55
TargetDisplay string `gorm:"column:target_display; type:text; not null;"`
56
56
57
57
// Diff is the change of structure that occurred, if any.
Original file line number Diff line number Diff line change @@ -1376,7 +1376,8 @@ func (db *Database) getMigrations(ctx context.Context) *gormigrate.Gormigrate {
1376
1376
1377
1377
sqls := []string {
1378
1378
`CREATE INDEX IF NOT EXISTS idx_audit_entries_realm_id ON audit_entries (realm_id)` ,
1379
- `CREATE INDEX IF NOT EXISTS idx_audit_entries_actor_id ON audit_entries (realm_id)` ,
1379
+ `CREATE INDEX IF NOT EXISTS idx_audit_entries_actor_id ON audit_entries (actor_id)` ,
1380
+ `CREATE INDEX IF NOT EXISTS idx_audit_entries_target_id ON audit_entries (target_id)` ,
1380
1381
`CREATE INDEX IF NOT EXISTS idx_audit_entries_created_at ON audit_entries (created_at)` ,
1381
1382
}
1382
1383
You can’t perform that action at this time.
0 commit comments