Skip to content

Commit

Permalink
[v16] Add wildcard-workload-identity-issuer preset role (#51238) (#…
Browse files Browse the repository at this point in the history
…51346)

* Add `wildcard-workload-identity-issuer` preset role (#51238)

* Add `wildcard-workload-identity-issuer` preset role for UX

* Fix TestPresets

* CLA please update
  • Loading branch information
strideynet authored Jan 22, 2025
1 parent b9b3124 commit ab03fbf
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
6 changes: 6 additions & 0 deletions constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,12 @@ const (
// access to Okta resources. This will be used by the Okta requester role to
// search for Okta resources.
SystemOktaAccessRoleName = "okta-access"

// PresetWildcardWorkloadIdentityIssuerRoleName is a name of a preset role
// that includes the permissions necessary to issue workload identity
// credentials using any workload_identity resource. This exists to simplify
// Day 0 UX experience with workload identity.
PresetWildcardWorkloadIdentityIssuerRoleName = "wildcard-workload-identity-issuer"
)

var PresetRoles = []string{PresetEditorRoleName, PresetAccessRoleName, PresetAuditorRoleName}
Expand Down
1 change: 1 addition & 0 deletions lib/auth/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,7 @@ func GetPresetRoles() []types.Role {
services.NewSystemOktaAccessRole(),
services.NewSystemOktaRequesterRole(),
services.NewPresetTerraformProviderRole(),
services.NewPresetWildcardWorkloadIdentityIssuerRole(),
}

// Certain `New$FooRole()` functions will return a nil role if the
Expand Down
1 change: 1 addition & 0 deletions lib/auth/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,7 @@ func TestPresets(t *testing.T) {
teleport.PresetAccessRoleName,
teleport.PresetAuditorRoleName,
teleport.PresetTerraformProviderRoleName,
teleport.PresetWildcardWorkloadIdentityIssuerRoleName,
}

t.Run("EmptyCluster", func(t *testing.T) {
Expand Down
28 changes: 28 additions & 0 deletions lib/services/presets.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,34 @@ func NewPresetRequireTrustedDeviceRole() types.Role {
}
}

// NewPresetWildcardWorkloadIdentityIssuerRole returns a new pre-defined role
// for issuing workload identities.
func NewPresetWildcardWorkloadIdentityIssuerRole() types.Role {
role := &types.RoleV6{
Kind: types.KindRole,
Version: types.V7,
Metadata: types.Metadata{
Name: teleport.PresetWildcardWorkloadIdentityIssuerRoleName,
Namespace: apidefaults.Namespace,
Description: "Issue workload identities",
Labels: map[string]string{
types.TeleportInternalResourceType: types.PresetResource,
},
},
Spec: types.RoleSpecV6{
Allow: types.RoleConditions{
WorkloadIdentityLabels: types.Labels{
types.Wildcard: []string{types.Wildcard},
},
Rules: []types.Rule{
types.NewRule(types.KindWorkloadIdentity, RO()),
},
},
},
}
return role
}

// SystemOktaAccessRoleName is the name of the system role that allows
// access to Okta resources. This will be used by the Okta requester role to
// search for Okta resources.
Expand Down

0 comments on commit ab03fbf

Please sign in to comment.