Skip to content

Commit fbdf883

Browse files
authored
Add Env0 join method (#60386) (#60710)
* 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 d936e1f commit fbdf883

File tree

32 files changed

+6741
-3373
lines changed

32 files changed

+6741
-3373
lines changed

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

Lines changed: 232 additions & 147 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 & 2 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.
@@ -312,8 +326,6 @@ message GivingUp {
312326

313327
// JoinRequest is the message type sent from the joining client to the server.
314328
message JoinRequest {
315-
reserved 8;
316-
reserved "oidc_init";
317329
oneof payload {
318330
ClientInit client_init = 1;
319331
TokenInit token_init = 2;
@@ -322,6 +334,7 @@ message JoinRequest {
322334
IAMInit iam_init = 5;
323335
GivingUp giving_up = 6;
324336
EC2Init ec2_init = 7;
337+
OIDCInit oidc_init = 8;
325338
OracleInit oracle_init = 9;
326339
}
327340
}

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
@@ -2048,6 +2050,51 @@ message ProvisionTokenSpecV2Oracle {
20482050
repeated Rule Allow = 1 [(gogoproto.jsontag) = "allow,omitempty"];
20492051
}
20502052

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

0 commit comments

Comments
 (0)