Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

Commit

Permalink
add database columns and config for feature flag (#1594)
Browse files Browse the repository at this point in the history
* add database columns and config for feature flag

* yay presubmits

* no automigrate
  • Loading branch information
mikehelmick authored Jan 14, 2021
1 parent c19be95 commit ac18c09
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
5 changes: 4 additions & 1 deletion pkg/config/certificate_signing_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
)

// CertificateSigningConfig represents the settings for system-wide certificate
// signing. These should be used if you are managing certifiate keys externally.
// signing. These should be used if you are managing certificate keys externally.
type CertificateSigningConfig struct {
// Keys determines the key manager configuration for this certificate signing
// configuration.
Expand All @@ -34,4 +34,7 @@ type CertificateSigningConfig struct {
CertificateIssuer string `env:"CERTIFICATE_ISSUER, default=diagnosis-verification-example"`
CertificateAudience string `env:"CERTIFICATE_AUDIENCE, default=exposure-notifications-server"`
CertificateDuration time.Duration `env:"CERTIFICATE_DURATION, default=15m"`
// EnableAutoRotation indicates if auto rotation settings should be shown in the UI.
// This will become the default in v0.21.0 of the verification server.
EnableAutoRotation bool `env:"ENABLE_VERIFICATION_KEY_AUTO_ROTATION, default=false"`
}
12 changes: 12 additions & 0 deletions pkg/database/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -1968,6 +1968,18 @@ func (db *Database) Migrations(ctx context.Context) []*gormigrate.Migration {
`DELETE FROM users WHERE deleted_at IS NOT NULL`)
},
},
{
ID: "00086-AddRealmAutoRotateSetting",
Migrate: func(tx *gorm.DB) error {
return multiExec(tx,
`ALTER TABLE realms ADD COLUMN IF NOT EXISTS auto_rotate_certificate_key BOOLEAN DEFAULT false`,
`ALTER TABLE realms ALTER COLUMN auto_rotate_certificate_key SET NOT NULL`)
},
Rollback: func(tx *gorm.DB) error {
return multiExec(tx,
`ALTER TABLE realms DROP COLUMN IF EXISTS auto_rotate_certificate_key`)
},
},
}
}

Expand Down
9 changes: 5 additions & 4 deletions pkg/database/realm.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,11 @@ type Realm struct {
RequireDate bool `gorm:"type:boolean; not null; default:false;"`

// Signing Key Settings
UseRealmCertificateKey bool `gorm:"type:boolean; default: false;"`
CertificateIssuer string `gorm:"type:varchar(150); default: '';"`
CertificateAudience string `gorm:"type:varchar(150); default: '';"`
CertificateDuration DurationSeconds `gorm:"type:bigint; default: 900;"` // 15m
UseRealmCertificateKey bool `gorm:"type:boolean; default: false;"`
CertificateIssuer string `gorm:"type:varchar(150); default: '';"`
CertificateAudience string `gorm:"type:varchar(150); default: '';"`
CertificateDuration DurationSeconds `gorm:"type:bigint; default: 900;"` // 15m
AutoRotateCertificateKey bool `gorm:"type:boolean; default: false;"`

// EN Express
EnableENExpress bool `gorm:"type:boolean; default: false;"`
Expand Down

0 comments on commit ac18c09

Please sign in to comment.