Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly validate JWT CA on bootstrap #8119

Merged
merged 2 commits into from
Sep 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions lib/auth/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ type InitConfig struct {

// StaticTokens are pre-defined host provisioning tokens supplied via config file for
// environments where paranoid security is not needed
//StaticTokens []services.ProvisionToken
StaticTokens types.StaticTokens

// AuthPreference defines the authentication type (local, oidc) and second
Expand Down Expand Up @@ -751,16 +750,26 @@ func checkResourceConsistency(keyStore keystore.KeyStore, clusterName string, re
// check that signing CAs have expected cluster name and that
// all CAs for this cluster do having signing keys.
seemsLocal := r.GetClusterName() == clusterName

var hasKeys bool
_, err := keyStore.GetSSHSigner(r)
var signerErr error
switch r.GetType() {
case types.HostCA, types.UserCA:
_, signerErr = keyStore.GetSSHSigner(r)
case types.JWTSigner:
_, signerErr = keyStore.GetJWTSigner(r)
default:
return trace.BadParameter("unexpected cert_authority type %s for cluster %v", r.GetType(), clusterName)
}
switch {
case err == nil:
case signerErr == nil:
hasKeys = true
case trace.IsNotFound(err):
case trace.IsNotFound(signerErr):
hasKeys = false
default:
return trace.Wrap(err)
return trace.Wrap(signerErr)
}

if seemsLocal && !hasKeys {
return trace.BadParameter("ca for local cluster %q missing signing keys", clusterName)
}
Expand Down
Loading