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