mirror of
https://github.com/zitadel/zitadel.git
synced 2025-01-05 22:52:46 +00:00
fix: Improve and sync checkSSL functions for CockroachDB and PostgreSQL (#6271)
* Improve and sync checkSSL functions for cockroach and postgres * Add missing prefer mode * Fix missing return in postgres checkSSL on disable
This commit is contained in:
parent
133789fee9
commit
c5c773531c
@ -15,6 +15,9 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
sslDisabledMode = "disable"
|
sslDisabledMode = "disable"
|
||||||
|
sslRequireMode = "require"
|
||||||
|
sslAllowMode = "allow"
|
||||||
|
sslPreferMode = "prefer"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
@ -121,6 +124,11 @@ func (c *Config) checkSSL(user User) {
|
|||||||
user.SSL = SSL{Mode: sslDisabledMode}
|
user.SSL = SSL{Mode: sslDisabledMode}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if user.SSL.Mode == sslRequireMode || user.SSL.Mode == sslAllowMode || user.SSL.Mode == sslPreferMode {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if user.SSL.RootCert == "" {
|
if user.SSL.RootCert == "" {
|
||||||
logging.WithFields(
|
logging.WithFields(
|
||||||
"cert set", user.SSL.Cert != "",
|
"cert set", user.SSL.Cert != "",
|
||||||
|
@ -13,6 +13,9 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
sslDisabledMode = "disable"
|
sslDisabledMode = "disable"
|
||||||
|
sslRequireMode = "require"
|
||||||
|
sslAllowMode = "allow"
|
||||||
|
sslPreferMode = "prefer"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
@ -113,6 +116,19 @@ type SSL struct {
|
|||||||
func (s *Config) checkSSL(user User) {
|
func (s *Config) checkSSL(user User) {
|
||||||
if user.SSL.Mode == sslDisabledMode || user.SSL.Mode == "" {
|
if user.SSL.Mode == sslDisabledMode || user.SSL.Mode == "" {
|
||||||
user.SSL = SSL{Mode: sslDisabledMode}
|
user.SSL = SSL{Mode: sslDisabledMode}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if user.SSL.Mode == sslRequireMode || user.SSL.Mode == sslAllowMode || user.SSL.Mode == sslPreferMode {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if user.SSL.RootCert == "" {
|
||||||
|
logging.WithFields(
|
||||||
|
"cert set", user.SSL.Cert != "",
|
||||||
|
"key set", user.SSL.Key != "",
|
||||||
|
"rootCert set", user.SSL.RootCert != "",
|
||||||
|
).Fatal("at least ssl root cert has to be set")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user