Skip to content

Commit

Permalink
feat(kc): Add support for custom auth CA cert.
Browse files Browse the repository at this point in the history
  • Loading branch information
spbsoluble committed May 13, 2024
1 parent 40a8e21 commit 85f2ef7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
9 changes: 8 additions & 1 deletion auth_providers/auth_core.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,17 @@ func (c *CommandAuthConfig) setClient() {
func (c *CommandAuthConfig) updateCACerts() error {
// check if CommandCACert is set
if c.CommandCACert == "" {
return nil
// check if CommandCACert is set in environment
if caCert, ok := os.LookupEnv(EnvKeyfactorCACert); ok {
c.CommandCACert = caCert
} else {
return nil
}
}

// ensure client is set
c.setClient()

// Load the system certs
rootCAs, pErr := x509.SystemCertPool()
if pErr != nil {
Expand Down
8 changes: 7 additions & 1 deletion auth_providers/keycloak/keycloak_auth_client_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
const (
EnvKeyfactorAuthHostname = "KEYFACTOR_AUTH_HOSTNAME"
EnvKeyfactorAuthPort = "KEYFACTOR_AUTH_PORT"
EnvAuthCACert = "KEYFACTOR_AUTH_CA_CERT"
)

type CommandAuthConfigKeyCloak struct {
Expand Down Expand Up @@ -78,7 +79,12 @@ func (c *CommandAuthConfigKeyCloak) ValidateAuthConfig() error {
func (c *CommandAuthConfigKeyCloak) updateCACerts() error {
// check if CommandCACert is set
if c.AuthCACert == "" {
return nil
// check environment for auth CA cert
if authCACert, ok := os.LookupEnv(EnvAuthCACert); ok {
c.AuthCACert = authCACert
} else {
return nil
}
}

// Load the system certs
Expand Down

0 comments on commit 85f2ef7

Please sign in to comment.