Skip to content

Commit be76a87

Browse files
authored
refactor: AccessRequest api (#141)
* refactor AccessRequest api * rename 'additionalRoles' to 'roles' * task generate * feat: release v0.12.0
1 parent b14209e commit be76a87

File tree

7 files changed

+328
-150
lines changed

7 files changed

+328
-150
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.11.2-dev
1+
v0.12.0

api/clusters/v1alpha1/accessrequest_types.go

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const (
1616

1717
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.clusterRef) || has(self.clusterRef)", message="clusterRef may not be removed once set"
1818
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.requestRef) || has(self.requestRef)", message="requestRef may not be removed once set"
19+
// +kubebuilder:validation:XValidation:rule="(has(self.token) && !has(self.oidc)) || (!has(self.token) && has(self.oidc))",message="exactly one of spec.token or spec.oidc must be set"
1920
type AccessRequestSpec struct {
2021
// ClusterRef is the reference to the Cluster for which access is requested.
2122
// If set, requestRef will be ignored.
@@ -31,21 +32,37 @@ type AccessRequestSpec struct {
3132
// +optional
3233
RequestRef *commonapi.ObjectReference `json:"requestRef,omitempty"`
3334

35+
// Token is the configuration for token-based access.
36+
// Exactly one of Token or OIDC must be set.
37+
// +optional
38+
Token *TokenConfig `json:"token,omitempty"`
39+
40+
// OIDC is the configuration for OIDC-based access.
41+
// Exactly one of Token or OIDC must be set.
42+
// +optional
43+
OIDC *OIDCConfig `json:"oidc,omitempty"`
44+
}
45+
46+
type TokenConfig struct {
3447
// Permissions are the requested permissions.
35-
// If not empty, corresponding Roles and ClusterRoles will be created in the target cluster, potentially also creating namespaces for Roles.
36-
// For token-based access, the serviceaccount will be bound to the created Roles and ClusterRoles.
48+
// If not empty, corresponding Roles and ClusterRoles will be created in the target cluster.
49+
// The created serviceaccount will be bound to the created Roles and ClusterRoles.
3750
// +optional
3851
Permissions []PermissionsRequest `json:"permissions,omitempty"`
3952

40-
// RoleRefs are references to existing (Cluster)Roles that should be bound to the created serviceaccount or OIDC user.
53+
// RoleRefs are references to existing (Cluster)Roles that should be bound to the created serviceaccount.
4154
// +optional
4255
RoleRefs []commonapi.RoleRef `json:"roleRefs,omitempty"`
56+
}
57+
58+
type OIDCConfig struct {
59+
commonapi.OIDCProviderConfig `json:",inline"`
4360

44-
// OIDCProvider is a configuration for an OIDC provider that should be used for authentication and associated role bindings.
45-
// If set, the handling ClusterProvider will create an OIDC-based access for the AccessRequest, if supported.
46-
// Otherwise, a serviceaccount with a token will be created and bound to the requested permissions.
61+
// Roles are additional (Cluster)Roles that should be created.
62+
// Note that they are not automatically bound to any user.
63+
// It is strongly recommended to set the name field so that the created (Cluster)Roles can be referenced in the RoleBindings field.
4764
// +optional
48-
OIDCProvider *commonapi.OIDCProviderConfig `json:"oidcProvider,omitempty"`
65+
Roles []PermissionsRequest `json:"roles,omitempty"`
4966
}
5067

5168
type PermissionsRequest struct {

api/clusters/v1alpha1/zz_generated.deepcopy.go

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

0 commit comments

Comments
 (0)