fix(go): prevent disabling basic auth if deployed by operator; (#3561)

This commit is contained in:
Vishal Dalwadi 2025-07-24 11:57:53 +05:30 committed by GitHub
parent 39ea1ed9fc
commit ffe5e0e65a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 0 deletions

View file

@ -33,6 +33,11 @@ func UpsertServerSettings(s models.ServerSettings) error {
if s.ClientSecret == Mask() {
s.ClientSecret = currSettings.ClientSecret
}
if servercfg.DeployedByOperator() {
s.BasicAuth = true
}
data, err := json.Marshal(s)
if err != nil {
return err
@ -317,6 +322,10 @@ func GetManageDNS() bool {
// IsBasicAuthEnabled - checks if basic auth has been configured to be turned off
func IsBasicAuthEnabled() bool {
if servercfg.DeployedByOperator() {
return true
}
return GetServerSettings().BasicAuth
}

View file

@ -721,6 +721,10 @@ func GetEmqxRestEndpoint() string {
// IsBasicAuthEnabled - checks if basic auth has been configured to be turned off
func IsBasicAuthEnabled() bool {
if DeployedByOperator() {
return true
}
var enabled = true //default
if os.Getenv("BASIC_AUTH") != "" {
enabled = os.Getenv("BASIC_AUTH") == "yes"