@ -47,9 +47,11 @@ const (
Endpoint = "endpoint"
Endpoint = "endpoint"
AuthToken = "auth_token"
AuthToken = "auth_token"
EnvLoggerWebhookEnable = "MINIO_LOGGER_WEBHOOK_ENABLE"
EnvLoggerWebhookEndpoint = "MINIO_LOGGER_WEBHOOK_ENDPOINT"
EnvLoggerWebhookEndpoint = "MINIO_LOGGER_WEBHOOK_ENDPOINT"
EnvLoggerWebhookAuthToken = "MINIO_LOGGER_WEBHOOK_AUTH_TOKEN"
EnvLoggerWebhookAuthToken = "MINIO_LOGGER_WEBHOOK_AUTH_TOKEN"
EnvAuditWebhookEnable = "MINIO_AUDIT_WEBHOOK_ENABLE"
EnvAuditWebhookEndpoint = "MINIO_AUDIT_WEBHOOK_ENDPOINT"
EnvAuditWebhookEndpoint = "MINIO_AUDIT_WEBHOOK_ENDPOINT"
EnvAuditWebhookAuthToken = "MINIO_AUDIT_WEBHOOK_AUTH_TOKEN"
EnvAuditWebhookAuthToken = "MINIO_AUDIT_WEBHOOK_AUTH_TOKEN"
)
)
@ -144,115 +146,117 @@ func LookupConfig(scfg config.Config) (Config, error) {
loggerAuditTargets = append ( loggerAuditTargets , target )
loggerAuditTargets = append ( loggerAuditTargets , target )
}
}
for starget , kv := range scfg [ config . LoggerWebhookSubSys ] {
// Load HTTP logger from the environment if found
subSysTarget := config . LoggerWebhookSubSys
for _ , target := range loggerTargets {
if starget != config . Default {
enableEnv := EnvLoggerWebhookEnable
subSysTarget = config . LoggerWebhookSubSys + config . SubSystemSeparator + starget
if target != config . Default {
}
enableEnv = EnvLoggerWebhookEnable + config . Default + target
if err := config . CheckValidKeys ( subSysTarget , kv , DefaultKVS ) ; err != nil {
return cfg , err
}
enabled , err := config . ParseBool ( kv . Get ( config . Enable ) )
if err != nil {
return cfg , err
}
}
if ! enabled {
enable , err := config . ParseBool ( env . Get ( enableEnv , config . EnableOn ) )
if err != nil || ! enable {
continue
continue
}
}
endpointEnv := EnvLoggerWebhookEndpoint
endpointEnv := EnvLoggerWebhookEndpoint
if s target != config . Default {
if target != config . Default {
endpointEnv = EnvLoggerWebhookEndpoint + config . Default + s target
endpointEnv = EnvLoggerWebhookEndpoint + config . Default + target
}
}
authTokenEnv := EnvLoggerWebhookAuthToken
authTokenEnv := EnvLoggerWebhookAuthToken
if s target != config . Default {
if target != config . Default {
authTokenEnv = EnvLoggerWebhookAuthToken + config . Default + s target
authTokenEnv = EnvLoggerWebhookAuthToken + config . Default + target
}
}
cfg . HTTP [ s target] = HTTP {
cfg . HTTP [ target ] = HTTP {
Enabled : true ,
Enabled : true ,
Endpoint : env . Get ( endpointEnv , kv . Get ( Endpoint ) ) ,
Endpoint : env . Get ( endpointEnv , "" ) ,
AuthToken : env . Get ( authTokenEnv , kv . Get ( AuthToken ) ) ,
AuthToken : env . Get ( authTokenEnv , "" ) ,
}
}
}
}
for starget , kv := range scfg [ config . AuditWebhookSubSys ] {
for _ , target := range loggerAuditTargets {
subSysTarget := config . AuditWebhookSubSys
enableEnv := EnvAuditWebhookEnable
if starget != config . Default {
if target != config . Default {
subSysTarget = config . AuditWebhookSubSys + config . SubSystemSeparator + starget
enableEnv = EnvAuditWebhookEnable + config . Default + target
}
if err := config . CheckValidKeys ( subSysTarget , kv , DefaultAuditKVS ) ; err != nil {
return cfg , err
}
enabled , err := config . ParseBool ( kv . Get ( config . Enable ) )
if err != nil {
return cfg , err
}
}
if ! enabled {
enable , err := config . ParseBool ( env . Get ( enableEnv , config . EnableOn ) )
if err != nil || ! enable {
continue
continue
}
}
endpointEnv := EnvAuditWebhookEndpoint
endpointEnv := EnvAuditWebhookEndpoint
if s target != config . Default {
if target != config . Default {
endpointEnv = EnvAuditWebhookEndpoint + config . Default + s target
endpointEnv = EnvAuditWebhookEndpoint + config . Default + target
}
}
legacyEndpointEnv := EnvAuditLoggerHTTPEndpoint
legacyEndpointEnv := EnvAuditLoggerHTTPEndpoint
if s target != config . Default {
if target != config . Default {
legacyEndpointEnv = EnvAuditLoggerHTTPEndpoint + config . Default + s target
legacyEndpointEnv = EnvAuditLoggerHTTPEndpoint + config . Default + target
}
}
endpoint := env . Get ( legacyEndpointEnv , "" )
endpoint := env . Get ( legacyEndpointEnv , "" )
if endpoint == "" {
if endpoint == "" {
endpoint = env . Get ( endpointEnv , kv . Get ( Endpoint ) )
endpoint = env . Get ( endpointEnv , "" )
}
}
authTokenEnv := EnvAuditWebhookAuthToken
authTokenEnv := EnvAuditWebhookAuthToken
if s target != config . Default {
if target != config . Default {
authTokenEnv = EnvAuditWebhookAuthToken + config . Default + s target
authTokenEnv = EnvAuditWebhookAuthToken + config . Default + target
}
}
cfg . Audit [ s target] = HTTP {
cfg . Audit [ target ] = HTTP {
Enabled : true ,
Enabled : true ,
Endpoint : endpoint ,
Endpoint : endpoint ,
AuthToken : env . Get ( authTokenEnv , kv . Get ( AuthToken ) ) ,
AuthToken : env . Get ( authTokenEnv , "" ) ,
}
}
}
}
for _ , target := range loggerTargets {
for starget , kv := range scfg [ config . LoggerWebhookSubSys ] {
endpointEnv := EnvLoggerWebhookEndpoint
if l , ok := cfg . HTTP [ starget ] ; ok && l . Enabled {
if target != config . Default {
// Ignore this HTTP logger config since there is
endpointEnv = EnvLoggerWebhookEndpoint + config . Default + target
// a target with the same name loaded and enabled
// from the environment.
continue
}
}
authTokenEnv := EnvLoggerWebhookAuthToken
subSysTarget := config . LoggerWebhookSubSys
if target != config . Default {
if s target != config . Default {
authTokenEnv = EnvLoggerWebhookAuthToken + config . Default + target
subSysTarget = config . LoggerWebhookSubSys + config . SubSystemSeparator + s target
}
}
cfg . HTTP [ target ] = HTTP {
if err := config . CheckValidKeys ( subSysTarget , kv , DefaultKVS ) ; err != nil {
return cfg , err
}
enabled , err := config . ParseBool ( kv . Get ( config . Enable ) )
if err != nil {
return cfg , err
}
if ! enabled {
continue
}
cfg . HTTP [ starget ] = HTTP {
Enabled : true ,
Enabled : true ,
Endpoint : env . Get ( endpointEnv , "" ) ,
Endpoint : k v. Get ( Endpoint ) ,
AuthToken : env . Get ( authTokenEnv , "" ) ,
AuthToken : k v. Get ( AuthToken ) ,
}
}
}
}
for _ , target := range loggerAuditTargets {
for starget , kv := range scfg [ config . AuditWebhookSubSys ] {
endpointEnv := EnvLoggerWebhookEndpoint
if l , ok := cfg . Audit [ starget ] ; ok && l . Enabled {
if target != config . Default {
// Ignore this audit config since another target
endpointEnv = EnvLoggerWebhookEndpoint + config . Default + target
// with the same name is already loaded and enabled
// in the shell environment.
continue
}
}
legacyEndpointEnv := EnvAuditLoggerHTTPEndpoint
subSysTarget := config . AuditWebhookSubSys
if target != config . Default {
if s target != config . Default {
legacyEndpointEnv = EnvAuditLoggerHTTPEndpoint + config . Default + target
subSysTarget = config . AuditWebhookSubSys + config . SubSystemSeparator + s target
}
}
endpoint := env . Get ( legacyEndpointEnv , "" )
if err := config . CheckValidKeys ( subSysTarget , kv , DefaultAuditKVS ) ; err != nil {
if endpoint == "" {
return cfg , err
endpoint = env . Get ( endpointEnv , "" )
}
}
authTokenEnv := EnvLoggerWebhookAuthToken
enabled , err := config . ParseBool ( kv . Get ( config . Enable ) )
if target != config . Default {
if err != nil {
authTokenEnv = EnvLoggerWebhookAuthToken + config . Default + target
return cfg , err
}
}
cfg . Audit [ target ] = HTTP {
if ! enabled {
continue
}
cfg . Audit [ starget ] = HTTP {
Enabled : true ,
Enabled : true ,
Endpoint : endpoint ,
Endpoint : kv . G et ( E ndpoint) ,
AuthToken : env . Get ( authTokenEnv , "" ) ,
AuthToken : k v. Get ( AuthToken ) ,
}
}
}
}