Move Tokenmanager to shared.Commons

Signed-off-by: Christian Richter <crichter@owncloud.com>
This commit is contained in:
Christian Richter
2022-04-25 16:35:10 +02:00
parent 699f929422
commit acf75afebc
22 changed files with 408 additions and 362 deletions
+1 -6
View File
@@ -19,7 +19,7 @@ type Config struct {
HTTP HTTP `yaml:"http,omitempty"`
GRPC GRPC `yaml:"grpc,omitempty"`
TokenManager TokenManager `yaml:"token_manager"`
TokenManager *shared.TokenManager `yaml:"token_manager,omitempty"`
Asset Asset `yaml:"asset,omitempty"`
Repo Repo `yaml:"repo,omitempty"`
@@ -36,11 +36,6 @@ type Asset struct {
Path string `yaml:"path" env:"ACCOUNTS_ASSET_PATH" desc:"The path to the ui assets."`
}
// TokenManager is the config for using the reva token manager
type TokenManager struct {
JWTSecret string `yaml:"jwt_secret" env:"OCIS_JWT_SECRET;ACCOUNTS_JWT_SECRET" desc:"The secret to mint jwt tokens."`
}
// Repo defines which storage implementation is to be used.
type Repo struct {
Backend string `yaml:"backend" env:"ACCOUNTS_STORAGE_BACKEND" desc:"Defines which storage implementation is to be used"`
@@ -6,6 +6,7 @@ import (
"github.com/owncloud/ocis/extensions/accounts/pkg/config"
"github.com/owncloud/ocis/ocis-pkg/config/defaults"
"github.com/owncloud/ocis/ocis-pkg/shared"
)
func FullDefaultConfig() *config.Config {
@@ -44,10 +45,7 @@ func DefaultConfig() *config.Config {
Service: config.Service{
Name: "accounts",
},
Asset: config.Asset{},
TokenManager: config.TokenManager{
JWTSecret: "Pive-Fumkiu4",
},
Asset: config.Asset{},
HashDifficulty: 11,
DemoUsersAndGroups: false,
Repo: config.Repo{
@@ -101,6 +99,14 @@ func EnsureDefaults(cfg *config.Config) {
} else if cfg.Tracing == nil {
cfg.Tracing = &config.Tracing{}
}
if cfg.TokenManager == nil && cfg.Commons != nil && cfg.Commons.TokenManager != nil {
cfg.TokenManager = &shared.TokenManager{
JWTSecret: cfg.Commons.TokenManager.JWTSecret,
}
} else {
cfg.TokenManager = &shared.TokenManager{}
}
}
func Sanitize(cfg *config.Config) {