feat(auth): Add option to disable registration and tenant creation
This commit is contained in:
@@ -22,8 +22,10 @@ type Config struct {
|
||||
RedisPort string
|
||||
RedisPassword string
|
||||
JwtSecret string
|
||||
ENV string
|
||||
UNPROTECTED_ENDPOINTS []string
|
||||
Environment string
|
||||
UnprotectedEndpoints []string
|
||||
AllowRegistration bool
|
||||
AllowTenantCreation bool
|
||||
}
|
||||
|
||||
var CONFIG *Config
|
||||
@@ -33,11 +35,11 @@ func generateSecret() string {
|
||||
}
|
||||
|
||||
func NewConfig() *Config {
|
||||
ENV := utils.GetEnv("ENV", "development")
|
||||
UNPROTECTED_ENDPOINTS := strings.Split(utils.GetEnv("UNPROTECTED_ENDPOINTS", ""), ",")
|
||||
Environment := utils.GetEnv("ENV", "development")
|
||||
UnprotectedEndpoints := strings.Split(utils.GetEnv("UNPROTECTED_ENDPOINTS", ""), ",")
|
||||
|
||||
if ENV == "development" {
|
||||
UNPROTECTED_ENDPOINTS = append(UNPROTECTED_ENDPOINTS, "/api_keys")
|
||||
if Environment == "development" {
|
||||
UnprotectedEndpoints = append(UnprotectedEndpoints, "/api_keys")
|
||||
}
|
||||
|
||||
c := &Config{
|
||||
@@ -56,8 +58,10 @@ func NewConfig() *Config {
|
||||
RedisHost: utils.GetEnv("REDIS_HOST", "localhost"),
|
||||
RedisPort: utils.GetEnv("REDIS_PORT", "6379"),
|
||||
RedisPassword: utils.GetEnv("REDIS_PASSWORD", ""),
|
||||
ENV: ENV,
|
||||
UNPROTECTED_ENDPOINTS: UNPROTECTED_ENDPOINTS,
|
||||
AllowRegistration: utils.GetEnvBool("ALLOW_REGISTRATION", false),
|
||||
AllowTenantCreation: utils.GetEnvBool("ALLOW_TENANT_CREATION", false),
|
||||
Environment: Environment,
|
||||
UnprotectedEndpoints: UnprotectedEndpoints,
|
||||
}
|
||||
CONFIG = c
|
||||
return c
|
||||
|
||||
Reference in New Issue
Block a user