Skip to content

Commit 03ac710

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 85df2da commit 03ac710

File tree

32 files changed

+6352
-2983
lines changed

32 files changed

+6352
-2983
lines changed

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

Lines changed: 215 additions & 130 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: 15 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.
@@ -280,6 +294,7 @@ message JoinRequest {
280294
IAMInit iam_init = 5;
281295
GivingUp giving_up = 6;
282296
EC2Init ec2_init = 7;
297+
OIDCInit oidc_init = 8;
283298
}
284299
}
285300

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

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1555,6 +1555,8 @@ message ProvisionTokenSpecV2 {
15551555
ProvisionTokenSpecV2BoundKeypair BoundKeypair = 19 [(gogoproto.jsontag) = "bound_keypair,omitempty"];
15561556
// AzureDevops allows the configuration of options specific to the "azure_devops" join method.
15571557
ProvisionTokenSpecV2AzureDevops AzureDevops = 20 [(gogoproto.jsontag) = "azure_devops,omitempty"];
1558+
// Env0 allows the configuration of options specific to the "env0" join method.
1559+
ProvisionTokenSpecV2Env0 Env0 = 21 [(gogoproto.jsontag) = "env0,omitempty"];
15581560
}
15591561

15601562
// ProvisionTokenSpecV2AzureDevops contains the Azure Devops-specific
@@ -2044,6 +2046,51 @@ message ProvisionTokenSpecV2Oracle {
20442046
repeated Rule Allow = 1 [(gogoproto.jsontag) = "allow,omitempty"];
20452047
}
20462048

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

0 commit comments

Comments
 (0)