mirror of
https://github.com/pomerium/pomerium.git
synced 2025-07-03 01:48:02 +02:00
databroker server backend config (#1127)
* config,docs: add databroker storage backend configuration * cache: allow configuring which backend storage to use Currently supported types are "memory", "redis".
This commit is contained in:
parent
c9182f757e
commit
1640151bc1
9 changed files with 99 additions and 6 deletions
|
@ -25,6 +25,8 @@ import (
|
|||
"github.com/pomerium/pomerium/internal/telemetry/metrics"
|
||||
"github.com/pomerium/pomerium/internal/urlutil"
|
||||
"github.com/pomerium/pomerium/pkg/cryptutil"
|
||||
"github.com/pomerium/pomerium/pkg/storage/inmemory"
|
||||
"github.com/pomerium/pomerium/pkg/storage/redis"
|
||||
)
|
||||
|
||||
// DisableHeaderKey is the key used to check whether to disable setting header
|
||||
|
@ -225,6 +227,11 @@ type Options struct {
|
|||
// DataBrokerURL is the routable destination of the databroker service's gRPC endpiont.
|
||||
DataBrokerURLString string `mapstructure:"databroker_service_url" yaml:"databroker_service_url,omitempty"`
|
||||
DataBrokerURL *url.URL `yaml:",omitempty"`
|
||||
// DataBrokerStorageType is the storage backend type that databroker will use.
|
||||
// Supported type: memory, redis
|
||||
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"`
|
||||
|
||||
// ClientCA is the base64-encoded certificate authority to validate client mTLS certificates against.
|
||||
ClientCA string `mapstructure:"client_ca" yaml:"client_ca,omitempty"`
|
||||
|
@ -279,6 +286,7 @@ var defaultOptions = Options{
|
|||
AutocertOptions: AutocertOptions{
|
||||
Folder: dataDir(),
|
||||
},
|
||||
DataBrokerStorageType: "memory",
|
||||
}
|
||||
|
||||
// NewDefaultOptions returns a copy the default options. It's the caller's
|
||||
|
@ -482,6 +490,15 @@ func (o *Options) Validate() error {
|
|||
log.Warn().Msg("config: cache url will be deprecated in v0.11.0")
|
||||
o.DataBrokerURLString = o.CacheURLString
|
||||
}
|
||||
switch o.DataBrokerStorageType {
|
||||
case inmemory.Name:
|
||||
case redis.Name:
|
||||
if o.DataBrokerStorageConnectionString == "" {
|
||||
return errors.New("config: missing databroker storage backend dsn")
|
||||
}
|
||||
default:
|
||||
return errors.New("config: unknown databroker storage backend type")
|
||||
}
|
||||
|
||||
if IsAuthorize(o.Services) || IsCache(o.Services) {
|
||||
// if authorize is set, we don't really need a http server
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue