-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Identity Center Account Assignments to Unified Resource Cache (#4…
…9580) Adds Identity Center Account Assignments to the Unified resource cache so they can be requested in access requests. Unfortunately we can't just include an `identitycenterv1.AccountAssignment` directly in the resource cache ListResources output because the legacy protobuf codegen used for the authservice and the new codegen used for identitycenter/v1 produce incompatible serialization code, so resulting generated code does not compile. To get around this issue, this change introduces a parallel (and slightly simplified) definition of an IdentityCenterAccountAssignment in the authservice protobuf spec to act as the wire format for this type. The cached `identitycenterv1.AccountAssignment` resources are copied into a `proto.IdentityCenterAccountAssignment` on a cache read. Includes: - adding resources to cache - adding account assignment paginated resource - account assignment role condition matching for RBAC
- Loading branch information
Showing
12 changed files
with
2,822 additions
and
1,301 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright 2024 Gravitational, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package proto | ||
|
||
import ( | ||
identitycenterv1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/identitycenter/v1" | ||
"github.com/gravitational/teleport/api/types" | ||
) | ||
|
||
// PackICAccountAssignment packs an Identity Center Account Assignment in to its | ||
// wire format. | ||
func PackICAccountAssignment(assignment *identitycenterv1.AccountAssignment) isPaginatedResource_Resource { | ||
return &PaginatedResource_IdentityCenterAccountAssignment{ | ||
IdentityCenterAccountAssignment: &IdentityCenterAccountAssignment{ | ||
Kind: types.KindIdentityCenterAccountAssignment, | ||
Version: assignment.GetVersion(), | ||
Metadata: types.Metadata153ToLegacy(assignment.Metadata), | ||
DisplayName: assignment.GetSpec().GetDisplay(), | ||
Account: &IdentityCenterAccount{ | ||
AccountName: assignment.GetSpec().GetAccountName(), | ||
ID: assignment.GetSpec().GetAccountId(), | ||
}, | ||
PermissionSet: &IdentityCenterPermissionSet{ | ||
ARN: assignment.GetSpec().GetPermissionSet().GetArn(), | ||
Name: assignment.GetSpec().GetPermissionSet().GetName(), | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
// UnpackICAccountAssignment converts a wire-format IdentityCenterAccountAssignment | ||
// resource back into an identitycenterv1.AccountAssignment instance. | ||
func UnpackICAccountAssignment(src *IdentityCenterAccountAssignment) types.ResourceWithLabels { | ||
dst := &identitycenterv1.AccountAssignment{ | ||
Kind: types.KindIdentityCenterAccountAssignment, | ||
Version: src.Version, | ||
Metadata: types.LegacyTo153Metadata(src.Metadata), | ||
Spec: &identitycenterv1.AccountAssignmentSpec{ | ||
AccountId: src.Account.ID, | ||
AccountName: src.Account.AccountName, | ||
Display: src.DisplayName, | ||
PermissionSet: &identitycenterv1.PermissionSetInfo{ | ||
Arn: src.PermissionSet.ARN, | ||
Name: src.PermissionSet.Name, | ||
}, | ||
}, | ||
} | ||
return types.Resource153ToResourceWithLabels(dst) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.