Skip to content

Commit ced0cac

Browse files
committed
Add Env0 join method (#60386)
* Add Env0 method This adds a new `env0` join method to support joining from env0 workflows, and especially the embedded tbot in the Terraform provider when running on env0. This is the first OIDC join method on the new join service, and will not support legacy joining. As such, it won't be backported beyond v18. Closes #53798 changelog: Add new `env0` join method to support joining within Env0 workflows * Fix imports * Fix failing test * Add env0 token source * Fix missing env0 join method in tbot * Fix env0 validation This fixes some issues in env0 token validation: - azp check is disabled since it's set to a random (ish) value - Use correct audience URL (their docs specified the wrong value) * Fix incorrect date in new file copyright header * Fix generated tfschema * Fix failing test after adding the token source * First round of code review * Add example token claims in comment * Move common OIDC handling logic into a separate handler Specific validation logic is now separate and the validator is passed as an argument to a generic `handleOIDCJoin()` handler. * Fix imports * Rename joinclient/join_env0.go to join_oidc.go
1 parent fb8248f commit ced0cac

File tree

32 files changed

+6334
-2958
lines changed

32 files changed

+6334
-2958
lines changed

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

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

api/gen/proto/go/teleport/workloadidentity/v1/join_attrs.pb.go

Lines changed: 209 additions & 15 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: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,20 @@ message TokenInit {
107107
ClientParams client_params = 1;
108108
}
109109

110+
// OIDCInit holds the OIDC identity token used for all OIDC-based join methods.
111+
//
112+
// The join flow for all OIDC-based join methods is:
113+
// 1. client->server: ClientInit
114+
// 2. server->client: ServerInit
115+
// 3. client->server: OIDCInit
116+
// 4. server->client: Result
117+
message OIDCInit {
118+
// ClientParams holds parameters for the specific type of client trying to join.
119+
ClientParams client_params = 1;
120+
// IdToken is the OIDC identity token.
121+
bytes id_token = 2;
122+
}
123+
110124
// BoundKeypairInit is sent from the client in response to the ServerInit
111125
// message for the bound keypair join method.
112126
// The server is expected to respond with a BoundKeypairChallenge.
@@ -233,12 +247,16 @@ message ChallengeSolution {
233247

234248
// JoinRequest is the message type sent from the joining client to the server.
235249
message JoinRequest {
250+
reserved 6, 7;
251+
236252
oneof payload {
237253
ClientInit client_init = 1;
238254
TokenInit token_init = 2;
239255
BoundKeypairInit bound_keypair_init = 3;
240256
ChallengeSolution solution = 4;
241257
IAMInit iam_init = 5;
258+
// 6, 7 reserved pending backport
259+
OIDCInit oidc_init = 8;
242260
}
243261
}
244262

api/proto/teleport/legacy/types/types.proto

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,6 +1540,8 @@ message ProvisionTokenSpecV2 {
15401540
ProvisionTokenSpecV2BoundKeypair BoundKeypair = 19 [(gogoproto.jsontag) = "bound_keypair,omitempty"];
15411541
// AzureDevops allows the configuration of options specific to the "azure_devops" join method.
15421542
ProvisionTokenSpecV2AzureDevops AzureDevops = 20 [(gogoproto.jsontag) = "azure_devops,omitempty"];
1543+
// Env0 allows the configuration of options specific to the "env0" join method.
1544+
ProvisionTokenSpecV2Env0 Env0 = 21 [(gogoproto.jsontag) = "env0,omitempty"];
15431545
}
15441546

15451547
// ProvisionTokenSpecV2AzureDevops contains the Azure Devops-specific
@@ -2029,6 +2031,51 @@ message ProvisionTokenSpecV2Oracle {
20292031
repeated Rule Allow = 1 [(gogoproto.jsontag) = "allow,omitempty"];
20302032
}
20312033

2034+
// ProvisionTokenSpecV2Env0 contains env0-specific parts of the
2035+
// ProvisionTokenSpecV2.
2036+
message ProvisionTokenSpecV2Env0 {
2037+
// Rule is a set of properties the env0 environment might have to be allowed
2038+
// to use this provision token.
2039+
message Rule {
2040+
// OrganizationID is the unique organization identifier, corresponding to
2041+
// `organizationId` in an Env0 OIDC token.
2042+
string OrganizationID = 1 [(gogoproto.jsontag) = "organization_id,omitempty"];
2043+
// ProjectID is a unique project identifier, corresponding to `projectId` in
2044+
// an Env0 OIDC token.
2045+
string ProjectID = 2 [(gogoproto.jsontag) = "project_id,omitempty"];
2046+
// ProjectName is the name of the project under which the job was run
2047+
// corresponding to `projectName` in an Env0 OIDC token.
2048+
string ProjectName = 3 [(gogoproto.jsontag) = "project_name,omitempty"];
2049+
// TemplateID is the unique identifier of the Env0 template, corresponding
2050+
// to `templateId` in an Env0 OIDC token.
2051+
string TemplateID = 4 [(gogoproto.jsontag) = "template_id,omitempty"];
2052+
// TemplateName is the name of the Env0 template, corresponding to
2053+
// `templateName` in an Env0 OIDC token.
2054+
string TemplateName = 5 [(gogoproto.jsontag) = "template_name,omitempty"];
2055+
// EnvironmentID is the unique identifier of the Env0 environment,
2056+
// corresponding to `environmentId` in an Env0 OIDC token.
2057+
string EnvironmentID = 6 [(gogoproto.jsontag) = "environment_id,omitempty"];
2058+
// EnvironmentName is the name of the Env0 environment, corresponding to
2059+
// `environmentName` in an Env0 OIDC token.
2060+
string EnvironmentName = 7 [(gogoproto.jsontag) = "environment_name,omitempty"];
2061+
// WorkspaceName is the name of the Env0 workspace, corresponding to
2062+
// `workspaceName` in an Env0 OIDC token.
2063+
string WorkspaceName = 8 [(gogoproto.jsontag) = "workspace_name,omitempty"];
2064+
// DeploymentType is the env0 deployment type, such as "deploy", "destroy",
2065+
// etc. Corresponds to `deploymentType` in an Env0 OIDC token.
2066+
string DeploymentType = 9 [(gogoproto.jsontag) = "deployment_type,omitempty"];
2067+
// DeployerEmail is the email of the person that triggered the deployment,
2068+
// corresponding to `deployerEmail` in an Env0 OIDC token.
2069+
string DeployerEmail = 10 [(gogoproto.jsontag) = "deployer_email,omitempty"];
2070+
// Env0Tag is a custom tag value corresponding to `env0Tag` when
2071+
// `ENV0_OIDC_TAG` is set.
2072+
string Env0Tag = 11 [(gogoproto.jsontag) = "env0_tag,omitempty"];
2073+
}
2074+
// Allow is a list of Rules, jobs using this token must match at least one
2075+
// allow rule to use this token.
2076+
repeated Rule Allow = 1 [(gogoproto.jsontag) = "allow,omitempty"];
2077+
}
2078+
20322079
// ProvisionTokenSpecV2BoundKeypair contains configuration for bound_keypair
20332080
// type join tokens.
20342081
message ProvisionTokenSpecV2BoundKeypair {

0 commit comments

Comments
 (0)