Skip to content

Commit

Permalink
rename TLSSecretFileMode to ReadWriteOnlyFileMode (#6854)
Browse files Browse the repository at this point in the history
  • Loading branch information
pdabelf5 authored Nov 25, 2024
1 parent a57f673 commit ee602b3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions cmd/nginx-ingress/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ func processDefaultServerSecret(ctx context.Context, kubeClient *kubernetes.Clie
}

bytes := configs.GenerateCertAndKeyFileContent(secret)
nginxManager.CreateSecret(configs.DefaultServerSecretFileName, bytes, nginx.TLSSecretFileMode)
nginxManager.CreateSecret(configs.DefaultServerSecretFileName, bytes, nginx.ReadWriteOnlyFileMode)
} else {
_, err := os.Stat(configs.DefaultServerSecretPath)
if err != nil {
Expand All @@ -596,7 +596,7 @@ func processWildcardSecret(ctx context.Context, kubeClient *kubernetes.Clientset
}

bytes := configs.GenerateCertAndKeyFileContent(secret)
nginxManager.CreateSecret(configs.WildcardSecretFileName, bytes, nginx.TLSSecretFileMode)
nginxManager.CreateSecret(configs.WildcardSecretFileName, bytes, nginx.ReadWriteOnlyFileMode)
}
return *wildcardTLSSecret != ""
}
Expand Down
8 changes: 4 additions & 4 deletions internal/configs/configurator.go
Original file line number Diff line number Diff line change
Expand Up @@ -823,8 +823,8 @@ func (cnf *Configurator) addOrUpdateCASecret(secret *api_v1.Secret) string {
crtData, crlData := GenerateCAFileContent(secret)
crtSecretName := fmt.Sprintf("%s-%s", name, CACrtKey)
crlSecretName := fmt.Sprintf("%s-%s", name, CACrlKey)
crtFileName := cnf.nginxManager.CreateSecret(crtSecretName, crtData, nginx.TLSSecretFileMode)
crlFileName := cnf.nginxManager.CreateSecret(crlSecretName, crlData, nginx.TLSSecretFileMode)
crtFileName := cnf.nginxManager.CreateSecret(crtSecretName, crtData, nginx.ReadWriteOnlyFileMode)
crlFileName := cnf.nginxManager.CreateSecret(crlSecretName, crlData, nginx.ReadWriteOnlyFileMode)
return fmt.Sprintf("%s %s", crtFileName, crlFileName)
}

Expand Down Expand Up @@ -919,7 +919,7 @@ func (cnf *Configurator) AddOrUpdateResources(resources ExtendedResources, reloa
func (cnf *Configurator) addOrUpdateTLSSecret(secret *api_v1.Secret) string {
name := objectMetaToFileName(&secret.ObjectMeta)
data := GenerateCertAndKeyFileContent(secret)
return cnf.nginxManager.CreateSecret(name, data, nginx.TLSSecretFileMode)
return cnf.nginxManager.CreateSecret(name, data, nginx.ReadWriteOnlyFileMode)
}

// AddOrUpdateSpecialTLSSecrets adds or updates a file with a TLS cert and a key from a Special TLS Secret (eg. DefaultServerSecret, WildcardTLSSecret).
Expand All @@ -929,7 +929,7 @@ func (cnf *Configurator) AddOrUpdateSpecialTLSSecrets(secret *api_v1.Secret, sec
data := GenerateCertAndKeyFileContent(secret)

for _, secretName := range secretNames {
cnf.nginxManager.CreateSecret(secretName, data, nginx.TLSSecretFileMode)
cnf.nginxManager.CreateSecret(secretName, data, nginx.ReadWriteOnlyFileMode)
}

if !cnf.DynamicSSLReloadEnabled() {
Expand Down
4 changes: 2 additions & 2 deletions internal/nginx/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ const (
ReloadForEndpointsUpdate = true
// ReloadForOtherUpdate means that a reload is caused by an update for a resource(s) other than endpoints.
ReloadForOtherUpdate = false
// TLSSecretFileMode defines the default filemode for files with TLS Secrets.
TLSSecretFileMode = 0o600
// ReadWriteOnlyFileMode defines the default filemode for files with Secrets.
ReadWriteOnlyFileMode = 0o600
// JWKSecretFileMode defines the default filemode for files with JWK Secrets.
JWKSecretFileMode = 0o644
// HtpasswdSecretFileMode defines the default filemode for HTTP basic auth user files.
Expand Down

0 comments on commit ee602b3

Please sign in to comment.