[WIP] add missing secret checks

Signed-off-by: Christian Richter <crichter@owncloud.com>
This commit is contained in:
Christian Richter
2022-04-29 11:55:56 +02:00
parent 72688b3650
commit bc6cd9141d
4 changed files with 28 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ import (
"github.com/owncloud/ocis/extensions/accounts/pkg/config"
defaults "github.com/owncloud/ocis/extensions/accounts/pkg/config/defaults"
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/shared"
"github.com/owncloud/ocis/ocis-pkg/config/envdecode"
)
@@ -33,5 +34,8 @@ func ParseConfig(cfg *config.Config) error {
}
func Validate(cfg *config.Config) error {
if cfg.TokenManager.JWTSecret == "" {
return shared.MissingJWTTokenError(cfg.Service.Name)
}
return nil
}

View File

@@ -2,6 +2,7 @@ package defaults
import (
"github.com/owncloud/ocis/extensions/appprovider/pkg/config"
"github.com/owncloud/ocis/ocis-pkg/shared"
)
func FullDefaultConfig() *config.Config {
@@ -80,3 +81,11 @@ func EnsureDefaults(cfg *config.Config) {
func Sanitize(cfg *config.Config) {
// nothing to sanitize here atm
}
func Validate(cfg *config.Config) error {
if cfg.TokenManager.JWTSecret == "" {
return shared.MissingJWTTokenError(cfg.Service.Name)
}
return nil
}

View File

@@ -6,6 +6,7 @@ import (
"github.com/owncloud/ocis/extensions/auth-basic/pkg/config"
"github.com/owncloud/ocis/extensions/auth-basic/pkg/config/defaults"
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/shared"
"github.com/owncloud/ocis/ocis-pkg/config/envdecode"
)
@@ -33,5 +34,12 @@ func ParseConfig(cfg *config.Config) error {
}
func Validate(cfg *config.Config) error {
if cfg.TokenManager.JWTSecret == "" {
return shared.MissingJWTTokenError(cfg.Service.Name)
}
if cfg.AuthProviders.LDAP.BindPassword == "" && cfg.AuthProvider == "ldap" {
return shared.MissingLDAPBindPassword(cfg.Service.Name)
}
return nil
}

View File

@@ -26,3 +26,10 @@ func MissingRevaTransferSecretError(service string) error {
"(e.g. by running ocis init or setting STORAGE_TRANSFER_SECRET).\n",
service, defaults.BaseConfigPath())
}
func MissingLDAPBindPassword(service string) error {
return fmt.Errorf("bind_password has not been set properly in your config for %s. "+
"Make sure your %s config contains the proper values "+
"(e.g. by running ocis init or setting LDAP_BIND_PASSWORD).\n",
service, defaults.BaseConfigPath())
}