Skip to content

Commit b7b6cf6

Browse files
committed
[v18] refactor new join flow
Backport #59331 to branch/v18
1 parent 0ec3c59 commit b7b6cf6

File tree

10 files changed

+1399
-542
lines changed

10 files changed

+1399
-542
lines changed

api/gen/proto/go/teleport/join/v1/joinservice.pb.go

Lines changed: 650 additions & 233 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/gen/proto/go/teleport/join/v1/joinservice_grpc.pb.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/proto/teleport/join/v1/joinservice.proto

Lines changed: 85 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -34,39 +34,11 @@ message ClientInit {
3434
string token_name = 2;
3535
// SystemRole is the system role requested, e.g. Proxy, Node, Instance, Bot.
3636
string system_role = 3;
37-
// PublicTlsKey is the public key requested for the subject of the x509 certificate.
38-
// It must be encoded in PKIX, ASN.1 DER form.
39-
bytes public_tls_key = 4;
40-
// PublicSshKey is the public key requested for the subject of the SSH certificate.
41-
// It must be encoded in SSH wire format.
42-
bytes public_ssh_key = 5;
4337
// ForwardedByProxy will be set to true when the message is forwarded by the
4438
// Proxy service. When this is set the Auth service must ignore any
4539
// any credentials authenticating the request, except for the purpose of
4640
// accepting ProxySuppliedParams.
47-
bool forwarded_by_proxy = 6;
48-
49-
// HostParams holds parameters that are specific to host joining and
50-
// irrelevant to bot joining.
51-
message HostParams {
52-
// HostName is the user-friendly node name for the host. This comes from
53-
// teleport.nodename in the service configuration and defaults to the
54-
// hostname. It is encoded as a valid principal in issued certificates.
55-
string host_name = 1;
56-
// AdditionalPrincipals is a list of additional principals requested.
57-
repeated string additional_principals = 2;
58-
// DnsNames is a list of DNS names requested for inclusion in the x509 certificate.
59-
repeated string dns_names = 3;
60-
}
61-
optional HostParams host_params = 7;
62-
63-
// BotParams holds parameters that are specific to bot joining and irrelevant
64-
// to host joining.
65-
message BotParams {
66-
// Expires is a desired time of the expiry of the returned certificates.
67-
optional google.protobuf.Timestamp expires = 9;
68-
}
69-
optional BotParams bot_params = 8;
41+
bool forwarded_by_proxy = 4;
7042

7143
// ProxySuppliedParams holds parameters set by the Proxy when nodes join
7244
// via the proxy address. They must only be trusted if the incoming join
@@ -78,13 +50,68 @@ message ClientInit {
7850
// ClientVersion is the Teleport version of the client attempting to join.
7951
string client_version = 2;
8052
}
81-
optional ProxySuppliedParams proxy_supplied_parameters = 9;
53+
optional ProxySuppliedParams proxy_supplied_parameters = 5;
54+
}
55+
56+
// PublicKeys holds public keys sent by the client requested subject keys for
57+
// issued certificates.
58+
message PublicKeys {
59+
// PublicTlsKey is the public key requested for the subject of the x509 certificate.
60+
// It must be encoded in PKIX, ASN.1 DER form.
61+
bytes public_tls_key = 1;
62+
// PublicSshKey is the public key requested for the subject of the SSH certificate.
63+
// It must be encoded in SSH wire format.
64+
bytes public_ssh_key = 2;
65+
}
66+
67+
// HostParams holds parameters required for host joining.
68+
message HostParams {
69+
// PublicKeys holds the host public keys.
70+
PublicKeys public_keys = 1;
71+
// HostName is the user-friendly node name for the host. This comes from
72+
// teleport.nodename in the service configuration and defaults to the
73+
// hostname. It is encoded as a valid principal in issued certificates.
74+
string host_name = 2;
75+
// AdditionalPrincipals is a list of additional principals requested.
76+
repeated string additional_principals = 3;
77+
// DnsNames is a list of DNS names requested for inclusion in the x509 certificate.
78+
repeated string dns_names = 4;
79+
}
80+
81+
// BotParams holds parameters required for bot joining.
82+
message BotParams {
83+
// PublicKeys holds the bot public keys.
84+
PublicKeys public_keys = 1;
85+
// Expires is a desired time of the expiry of the returned certificates.
86+
optional google.protobuf.Timestamp expires = 2;
87+
}
88+
89+
// ClientParams holds either host or bot join parameters.
90+
message ClientParams {
91+
oneof payload {
92+
HostParams host_params = 1;
93+
BotParams bot_params = 2;
94+
}
95+
}
96+
97+
// TokenInit is sent by the client in response to the ServerInit message for
98+
// the Token join method.
99+
//
100+
// The Token method join flow is:
101+
// 1. client->server: ClientInit
102+
// 2. server->client: ServerInit
103+
// 3. client->server: TokenInit
104+
// 4. server->client: Result
105+
message TokenInit {
106+
// ClientParams holds parameters for the specific type of client trying to join.
107+
ClientParams client_params = 1;
82108
}
83109

84110
// JoinRequest is the message type sent from the joining client to the server.
85111
message JoinRequest {
86112
oneof payload {
87113
ClientInit client_init = 1;
114+
TokenInit token_init = 2;
88115
}
89116
}
90117

@@ -93,6 +120,9 @@ message JoinRequest {
93120
message ServerInit {
94121
// JoinMethod is the name of the selected join method.
95122
string join_method = 1;
123+
// SignatureAlgorithmSuite is the name of the signature algorithm suite
124+
// currently configured for the cluster.
125+
string signature_algorithm_suite = 2;
96126
}
97127

98128
// Challenge is a challenge message sent from the server that the client must solve.
@@ -102,18 +132,38 @@ message Challenge {}
102132
// contains the result of the joining process including the assigned host ID
103133
// and issued certificates.
104134
message Result {
135+
oneof payload {
136+
HostResult host_result = 1;
137+
BotResult bot_result = 2;
138+
}
139+
}
140+
141+
// Certificates holds issued certificates and cluster CAs.
142+
message Certificates {
105143
// TlsCert is an X.509 certificate encoded in ASN.1 DER form.
106144
bytes tls_cert = 1;
107-
// TlsCaCerts is a list of TLS certificate authorities that the agent should trust.
145+
// TlsCaCerts is a list of TLS certificate authorities that the client should trust.
108146
// Each certificate is encoding in ASN.1 DER form.
109147
repeated bytes tls_ca_certs = 2;
110148
// SshCert is an SSH certificate encoded in SSH wire format.
111149
bytes ssh_cert = 3;
112-
// SshCaKey is a list of SSH certificate authority public keys that the agent should trust.
150+
// SshCaKey is a list of SSH certificate authority public keys that the client should trust.
113151
// Each CA key is encoded in SSH wire format.
114152
repeated bytes ssh_ca_keys = 4;
153+
}
154+
155+
// HostResult holds results for host joining.
156+
message HostResult {
157+
// Certificates holds issued certificates and cluster CAs.
158+
Certificates certificates = 1;
115159
// HostId is the unique ID assigned to the host.
116-
optional string host_id = 5;
160+
string host_id = 2;
161+
}
162+
163+
// HostResult holds results for bot joining.
164+
message BotResult {
165+
// Certificates holds issued certificates and cluster CAs.
166+
Certificates certificates = 1;
117167
}
118168

119169
// JoinResponse is the message type sent from the server to the joining client.
@@ -163,7 +213,7 @@ service JoinService {
163213
// The client must send an ClientInit message on the JoinRequest stream to
164214
// initiate the join flow.
165215
//
166-
// The server will reply with a JoinResponse where the payload will vary
167-
// based on the join method specified in the provision token.
216+
// The server will reply with a ServerInit message, and subsequent messages
217+
// on the stream will depend on the join method.
168218
rpc Join(stream JoinRequest) returns (stream JoinResponse);
169219
}

api/types/signaturealgorithmsuite.go

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,35 @@ import (
2020
"github.com/gravitational/trace"
2121
)
2222

23-
// MarshalText marshals a SignatureAlgorithmSuite value to text. This gets used
24-
// by json.Marshal.
25-
func (s SignatureAlgorithmSuite) MarshalText() ([]byte, error) {
23+
// SignatureAlgorithmSuiteToString converts a [SignatureAlgorithmSuite] to a user-friendly string.
24+
func SignatureAlgorithmSuiteToString(s SignatureAlgorithmSuite) string {
2625
switch s {
2726
case SignatureAlgorithmSuite_SIGNATURE_ALGORITHM_SUITE_LEGACY:
28-
return []byte("legacy"), nil
27+
return "legacy"
2928
case SignatureAlgorithmSuite_SIGNATURE_ALGORITHM_SUITE_BALANCED_V1:
30-
return []byte("balanced-v1"), nil
29+
return "balanced-v1"
3130
case SignatureAlgorithmSuite_SIGNATURE_ALGORITHM_SUITE_FIPS_V1:
32-
return []byte("fips-v1"), nil
31+
return "fips-v1"
3332
case SignatureAlgorithmSuite_SIGNATURE_ALGORITHM_SUITE_HSM_V1:
34-
return []byte("hsm-v1"), nil
33+
return "hsm-v1"
3534
default:
36-
return []byte(s.String()), nil
35+
return s.String()
3736
}
3837
}
3938

39+
// SignatureAlgorithmSuiteFromString parses a string to return a [SignatureAlgorithmSuite].
40+
func SignatureAlgorithmSuiteFromString(str string) (SignatureAlgorithmSuite, error) {
41+
var suite SignatureAlgorithmSuite
42+
err := suite.UnmarshalText([]byte(str))
43+
return suite, trace.Wrap(err)
44+
}
45+
46+
// MarshalText marshals a SignatureAlgorithmSuite value to text. This gets used
47+
// by json.Marshal.
48+
func (s SignatureAlgorithmSuite) MarshalText() ([]byte, error) {
49+
return []byte(SignatureAlgorithmSuiteToString(s)), nil
50+
}
51+
4052
// UnmarshalJSON unmarshals a SignatureAlgorithmSuite and supports the custom
4153
// string format or numeric types matching an enum value.
4254
func (s *SignatureAlgorithmSuite) UnmarshalJSON(data []byte) error {

buf.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ breaking:
8686
ignore:
8787
# TODO(codingllama): Remove ignore once the PDP API is stable.
8888
- api/proto/teleport/decision/v1alpha1
89+
# TODO(nklaassen): Remove ignore once the new join API is stable.
90+
- api/proto/teleport/join/v1
8991

9092
plugins:
9193
- plugin:

0 commit comments

Comments
 (0)