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

Provided CA via kumactl #474

Merged
merged 8 commits into from
Dec 12, 2019
14 changes: 7 additions & 7 deletions app/kumactl/cmd/config/config_control_planes_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ func newConfigControlPlanesAddCmd(pctx *kumactl_cmd.RootContext) *cobra.Command
name string
apiServerURL string
overwrite bool
dataplaneTokenClientCert string
dataplaneTokenClientKey string
adminClientCert string
adminClientKey string
}{}
cmd := &cobra.Command{
Use: "add",
Expand Down Expand Up @@ -45,9 +45,9 @@ func newConfigControlPlanesAddCmd(pctx *kumactl_cmd.RootContext) *cobra.Command
Name: cp.Name,
ControlPlane: cp.Name,
Credentials: &config_proto.Context_Credentials{
DataplaneTokenApi: &config_proto.Context_DataplaneTokenApiCredentials{
ClientCert: args.dataplaneTokenClientCert,
ClientKey: args.dataplaneTokenClientKey,
AdminApi: &config_proto.Context_AdminApiCredentials{
ClientCert: args.adminClientCert,
ClientKey: args.adminClientKey,
},
},
}
Expand All @@ -72,7 +72,7 @@ func newConfigControlPlanesAddCmd(pctx *kumactl_cmd.RootContext) *cobra.Command
cmd.Flags().StringVar(&args.apiServerURL, "address", "", "URL of the Control Plane API Server (required)")
_ = cmd.MarkFlagRequired("address")
cmd.Flags().BoolVar(&args.overwrite, "overwrite", false, "overwrite existing Control Plane with the same reference name")
cmd.Flags().StringVar(&args.dataplaneTokenClientCert, "dataplane-token-client-cert", "", "Path to certificate of a client that is authorized to use Dataplane Token Server")
cmd.Flags().StringVar(&args.dataplaneTokenClientKey, "dataplane-token-client-key", "", "Path to certificate key of a client that is authorized to use Dataplane Token Server")
cmd.Flags().StringVar(&args.adminClientCert, "admin-client-cert", "", "Path to certificate of a client that is authorized to use Admin Server")
yskopets marked this conversation as resolved.
Show resolved Hide resolved
cmd.Flags().StringVar(&args.adminClientKey, "admin-client-key", "", "Path to certificate key of a client that is authorized to use Admin Server")
yskopets marked this conversation as resolved.
Show resolved Hide resolved
return cmd
}
4 changes: 2 additions & 2 deletions app/kumactl/cmd/config/config_control_planes_add_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ var _ = Describe("kumactl config control-planes add", func() {
"config", "control-planes", "add",
"--name", "example",
"--address", fmt.Sprintf("http://localhost:%d", port),
"--dataplane-token-client-cert", "/tmp/client.pem",
"--dataplane-token-client-key", "/tmp/client.key.pem"}
"--admin-client-cert", "/tmp/client.pem",
"--admin-client-key", "/tmp/client.key.pem"}
if given.overwrite {
args = append(args, "--overwrite")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ contexts:
- controlPlane: example
name: example
credentials:
dataplaneTokenApi:
adminApi:
clientCert: /tmp/client.pem
clientKey: /tmp/client.key.pem
controlPlanes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ contexts:
- controlPlane: example
name: example
credentials:
dataplaneTokenApi:
adminApi:
clientCert: /tmp/client.pem
clientKey: /tmp/client.key.pem
controlPlanes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ contexts:
- controlPlane: example
name: example
credentials:
dataplaneTokenApi:
adminApi:
clientCert: /tmp/client.pem
clientKey: /tmp/client.key.pem
controlPlanes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var _ = Describe("kumactl generate dataplane-token", func() {
generator = &staticDataplaneTokenGenerator{}
ctx = &kumactl_cmd.RootContext{
Runtime: kumactl_cmd.RootRuntime{
NewDataplaneTokenClient: func(string, *config_kumactl.Context_DataplaneTokenApiCredentials) (tokens.DataplaneTokenClient, error) {
NewDataplaneTokenClient: func(string, *config_kumactl.Context_AdminApiCredentials) (tokens.DataplaneTokenClient, error) {
return generator, nil
},
NewCatalogClient: func(s string) (catalog_client.CatalogClient, error) {
Expand Down
12 changes: 6 additions & 6 deletions app/kumactl/cmd/manage/ca/provided.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,12 @@ func printListCertificates(certs []types.SigningCert, out io.Writer) error {
cert := certs[i]
x509Cert := x509Certs[i]
return []string{
cert.Id, // ID
x509Cert.Subject.CommonName, // COMMON NAME
x509Cert.SerialNumber.String(), // SERIAL NUMBER
x509Cert.NotBefore.String(), // NOT VALID BEFORE
x509Cert.NotAfter.String(), // NOT VALID AFTER
fmt.Sprintf("%x", sha1.Sum(x509Cert.Raw)), // SHA-1 FINGERPRINT
cert.Id, // ID
x509Cert.Subject.CommonName, // COMMON NAME
x509Cert.SerialNumber.String(), // SERIAL NUMBER
x509Cert.NotBefore.String(), // NOT VALID BEFORE
x509Cert.NotAfter.String(), // NOT VALID AFTER
fmt.Sprintf("%x", sha1.Sum(x509Cert.Raw)), // SHA-1 FINGERPRINT
fmt.Sprintf("%x", sha256.New().Sum(x509Cert.Raw)), // SHA-256 FINGERPRINT
}
}
Expand Down
6 changes: 3 additions & 3 deletions app/kumactl/pkg/cmd/root_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type RootRuntime struct {
Now func() time.Time
NewResourceStore func(*config_proto.ControlPlaneCoordinates_ApiServer) (core_store.ResourceStore, error)
NewDataplaneOverviewClient func(*config_proto.ControlPlaneCoordinates_ApiServer) (kumactl_resources.DataplaneOverviewClient, error)
NewDataplaneTokenClient func(string, *kumactl_config.Context_DataplaneTokenApiCredentials) (tokens.DataplaneTokenClient, error)
NewDataplaneTokenClient func(string, *kumactl_config.Context_AdminApiCredentials) (tokens.DataplaneTokenClient, error)
NewCatalogClient func(string) (catalog_client.CatalogClient, error)
NewProvidedCaClient func(string) (rest.ProvidedCaClient, error)
}
Expand Down Expand Up @@ -158,12 +158,12 @@ func (rc *RootContext) CurrentDataplaneTokenClient() (tokens.DataplaneTokenClien
}
dpTokenUrl = components.Apis.DataplaneToken.PublicUrl
}
return rc.Runtime.NewDataplaneTokenClient(dpTokenUrl, ctx.GetCredentials().GetDataplaneTokenApi())
return rc.Runtime.NewDataplaneTokenClient(dpTokenUrl, ctx.GetCredentials().GetAdminApi())
}

func validateRemoteDataplaneTokenServerSettings(ctx *kumactl_config.Context, components catalog.Catalog) error {
reason := ""
clientConfigured := ctx.GetCredentials().GetDataplaneTokenApi().HasClientCert()
clientConfigured := ctx.GetCredentials().GetAdminApi().HasClientCert()
serverConfigured := components.Apis.DataplaneToken.PublicUrl != ""
if !clientConfigured && serverConfigured {
reason = "dataplane token server in kuma-cp is configured with TLS and kumactl is not."
Expand Down
2 changes: 1 addition & 1 deletion app/kumactl/pkg/tokens/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const (
timeout = 10 * time.Second
)

func NewDataplaneTokenClient(address string, config *kumactl_config.Context_DataplaneTokenApiCredentials) (DataplaneTokenClient, error) {
func NewDataplaneTokenClient(address string, config *kumactl_config.Context_AdminApiCredentials) (DataplaneTokenClient, error) {
baseURL, err := url.Parse(address)
if err != nil {
return nil, errors.Wrapf(err, "failed to parse Dataplane Token Server URL")
Expand Down
4 changes: 2 additions & 2 deletions app/kumactl/pkg/tokens/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ var _ = Describe("Tokens Client", func() {

type testCase struct {
url func() string
config *config_kumactl.Context_DataplaneTokenApiCredentials
config *config_kumactl.Context_AdminApiCredentials
}
DescribeTable("should return a token",
func(given testCase) {
Expand Down Expand Up @@ -107,7 +107,7 @@ var _ = Describe("Tokens Client", func() {
url: func() string {
return fmt.Sprintf("https://localhost:%d", publicPort)
},
config: &config_kumactl.Context_DataplaneTokenApiCredentials{
config: &config_kumactl.Context_AdminApiCredentials{
ClientCert: filepath.Join("..", "..", "..", "..", "pkg", "admin-server", "testdata", "authorized-client-cert.pem"),
ClientKey: filepath.Join("..", "..", "..", "..", "pkg", "admin-server", "testdata", "authorized-client-key.pem"),
},
Expand Down
4 changes: 3 additions & 1 deletion pkg/api-server/catalog_ws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ var _ = Describe("Catalog WS", func() {
cfg := config.DefaultApiServerConfig()
cfg.Catalog.Admin.LocalUrl = "http://localhost:1111"
cfg.Catalog.Admin.PublicUrl = "https://kuma.internal:2222"
cfg.Catalog.DataplaneToken.LocalUrl = "http://localhost:1111"
cfg.Catalog.DataplaneToken.PublicUrl = "https://kuma.internal:2222"
cfg.Catalog.Bootstrap.Url = "http://kuma.internal:3333"

// setup
Expand Down Expand Up @@ -53,7 +55,7 @@ var _ = Describe("Catalog WS", func() {
"dataplaneToken": {
"localUrl": "http://localhost:1111",
"publicUrl": "https://kuma.internal:2222"
}
},
"admin": {
"localUrl": "http://localhost:1111",
"publicUrl": "https://kuma.internal:2222"
Expand Down
125 changes: 61 additions & 64 deletions pkg/config/app/kumactl/v1alpha1/config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading