mirror of
https://github.com/pomerium/pomerium.git
synced 2025-06-06 04:42:56 +02:00
core/config: add databroker_storage_connection_string_file (#5242)
* core/config: add databroker_storage_connection_string_file * add file to file list
This commit is contained in:
parent
d062f9d68d
commit
f3620cf6e9
5 changed files with 110 additions and 15 deletions
|
@ -249,11 +249,12 @@ type Options struct {
|
|||
// Supported type: memory, postgres
|
||||
DataBrokerStorageType string `mapstructure:"databroker_storage_type" yaml:"databroker_storage_type,omitempty"`
|
||||
// DataBrokerStorageConnectionString is the data source name for storage backend.
|
||||
DataBrokerStorageConnectionString string `mapstructure:"databroker_storage_connection_string" yaml:"databroker_storage_connection_string,omitempty"`
|
||||
DataBrokerStorageCertFile string `mapstructure:"databroker_storage_cert_file" yaml:"databroker_storage_cert_file,omitempty"`
|
||||
DataBrokerStorageCertKeyFile string `mapstructure:"databroker_storage_key_file" yaml:"databroker_storage_key_file,omitempty"`
|
||||
DataBrokerStorageCAFile string `mapstructure:"databroker_storage_ca_file" yaml:"databroker_storage_ca_file,omitempty"`
|
||||
DataBrokerStorageCertSkipVerify bool `mapstructure:"databroker_storage_tls_skip_verify" yaml:"databroker_storage_tls_skip_verify,omitempty"`
|
||||
DataBrokerStorageConnectionString string `mapstructure:"databroker_storage_connection_string" yaml:"databroker_storage_connection_string,omitempty"`
|
||||
DataBrokerStorageConnectionStringFile string `mapstructure:"databroker_storage_connection_string_file" yaml:"databroker_storage_connection_string_file,omitempty"`
|
||||
DataBrokerStorageCertFile string `mapstructure:"databroker_storage_cert_file" yaml:"databroker_storage_cert_file,omitempty"`
|
||||
DataBrokerStorageCertKeyFile string `mapstructure:"databroker_storage_key_file" yaml:"databroker_storage_key_file,omitempty"`
|
||||
DataBrokerStorageCAFile string `mapstructure:"databroker_storage_ca_file" yaml:"databroker_storage_ca_file,omitempty"`
|
||||
DataBrokerStorageCertSkipVerify bool `mapstructure:"databroker_storage_tls_skip_verify" yaml:"databroker_storage_tls_skip_verify,omitempty"`
|
||||
|
||||
// DownstreamMTLS holds all downstream mTLS settings.
|
||||
DownstreamMTLS DownstreamMTLSSettings `mapstructure:"downstream_mtls" yaml:"downstream_mtls,omitempty"`
|
||||
|
@ -592,7 +593,7 @@ func (o *Options) Validate() error {
|
|||
switch o.DataBrokerStorageType {
|
||||
case StorageInMemoryName:
|
||||
case StoragePostgresName:
|
||||
if o.DataBrokerStorageConnectionString == "" {
|
||||
if o.DataBrokerStorageConnectionString == "" && o.DataBrokerStorageConnectionStringFile == "" {
|
||||
return errors.New("config: missing databroker storage backend dsn")
|
||||
}
|
||||
default:
|
||||
|
@ -1084,6 +1085,17 @@ func (o *Options) GetDataBrokerCertificate() (*tls.Certificate, error) {
|
|||
return cryptutil.CertificateFromFile(o.DataBrokerStorageCertFile, o.DataBrokerStorageCertKeyFile)
|
||||
}
|
||||
|
||||
// GetDataBrokerStorageConnectionString gets the databroker storage connection string from either a file
|
||||
// or the config option directly. If from a file spaces are trimmed off the ends.
|
||||
func (o *Options) GetDataBrokerStorageConnectionString() (string, error) {
|
||||
if o.DataBrokerStorageConnectionStringFile != "" {
|
||||
bs, err := os.ReadFile(o.DataBrokerStorageConnectionStringFile)
|
||||
return strings.TrimSpace(string(bs)), err
|
||||
}
|
||||
|
||||
return o.DataBrokerStorageConnectionString, nil
|
||||
}
|
||||
|
||||
// GetCertificates gets all the certificates from the options.
|
||||
func (o *Options) GetCertificates() ([]tls.Certificate, error) {
|
||||
var certs []tls.Certificate
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue