mirror of
https://github.com/pomerium/pomerium.git
synced 2025-06-25 05:58:16 +02:00
* Add new configurable bootstrap writers (#2405) This PR adds the ability to configure different backends to use for storing modifications to the zero bootstrap config. The two currently implemented backends allow writing changes to a file or to a Kubernetes secret. Backend selection is determined by the scheme in a URI passed to the flag '--config-writeback-uri'. In a Kubernetes environment, where the bootstrap config is mounted into the pod from a secret, this option allows Pomerium to write changes back to the secret, as writes to the mounted secret file on disk are not persisted. * Use env vars for bootstrap config filepath/writeback uri * linter pass and code cleanup * Add new config writer options mechanism This moves the encryption cipher parameter out of the WriteConfig() method in the ConfigWriter interface and into a new ConfigWriterOptions struct. Options (e.g. cipher) can be applied to an existing ConfigWriter to allow customizing implementation-specific behavior. * Code cleanup/lint fixes * Move vendored k8s code into separate package, and add license header and package comment
This commit is contained in:
parent
927f24e1ff
commit
de603f87de
18 changed files with 726 additions and 74 deletions
|
@ -15,6 +15,7 @@ import (
|
|||
"github.com/pomerium/pomerium/internal/atomicutil"
|
||||
"github.com/pomerium/pomerium/internal/deterministicecdsa"
|
||||
sdk "github.com/pomerium/pomerium/internal/zero/api"
|
||||
"github.com/pomerium/pomerium/internal/zero/bootstrap/writers"
|
||||
"github.com/pomerium/pomerium/pkg/cryptutil"
|
||||
"github.com/pomerium/pomerium/pkg/netutil"
|
||||
)
|
||||
|
@ -27,13 +28,14 @@ type Source struct {
|
|||
|
||||
fileCachePath *string
|
||||
fileCipher cipher.AEAD
|
||||
writer writers.ConfigWriter
|
||||
|
||||
checkForUpdate chan struct{}
|
||||
updateInterval atomicutil.Value[time.Duration]
|
||||
}
|
||||
|
||||
// New creates a new bootstrap config source
|
||||
func New(secret []byte, fileCachePath *string, api *sdk.API) (*Source, error) {
|
||||
func New(secret []byte, fileCachePath *string, writer writers.ConfigWriter, api *sdk.API) (*Source, error) {
|
||||
cfg := new(config.Config)
|
||||
|
||||
err := setConfigDefaults(cfg)
|
||||
|
@ -53,12 +55,19 @@ func New(secret []byte, fileCachePath *string, api *sdk.API) (*Source, error) {
|
|||
return nil, fmt.Errorf("init cypher: %w", err)
|
||||
}
|
||||
|
||||
if writer != nil {
|
||||
writer = writer.WithOptions(writers.ConfigWriterOptions{
|
||||
Cipher: cipher,
|
||||
})
|
||||
}
|
||||
|
||||
svc := &Source{
|
||||
api: api,
|
||||
source: source{ready: make(chan struct{})},
|
||||
fileCachePath: fileCachePath,
|
||||
fileCipher: cipher,
|
||||
checkForUpdate: make(chan struct{}, 1),
|
||||
writer: writer,
|
||||
}
|
||||
svc.cfg.Store(cfg)
|
||||
svc.updateInterval.Store(DefaultCheckForUpdateIntervalWhenDisconnected)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue