Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add user RBAC to default config #25

Merged
merged 2 commits into from
Jan 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config/deployment/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ spec:
- "--cert-dir=/apiserver.local.config/certificates"
- "--secure-port=9443"
- "--feature-gates=APIPriorityAndFairness=false"
- "--cluster-roles=control-api:organization-viewer,control-api:organization-admin"
- "--username-prefix=appuio#"
volumeMounts:
- name: apiserver-certs
mountPath: /apiserver.local.config/certificates
Expand Down
14 changes: 14 additions & 0 deletions config/user-rbac/basic-user-role.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: control-api:basic-user
rules:
- apiGroups: ["organization.appuio.io"]
resources: ["organizations"]
verbs: ["get", "watch", "list", "patch", "edit", "create"]
- apiGroups: ["rbac.appuio.io"]
resources: ["organizations"]
verbs: ["watch", "list", "create"]
- apiGroups: ["appuio.io"]
resources: ["zones"]
verbs: ["get", "watch", "list"]
Comment on lines +12 to +14
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aggregating to view might be a good idea. I'll try that!

I personally wouldn't use kubebuilder for that as it's not a role for the controller.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait no. We don't actually want to give users the view role 😅 They shouldn't be able to see other resources such as namespaces or pods

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, right :)

12 changes: 12 additions & 0 deletions config/user-rbac/basic-user-rolebinding.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: control-api:basic-user
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: control-api:basic-user
subjects:
- apiGroup: rbac.authorization.k8s.io
kind: Group
name: system:authenticated
5 changes: 5 additions & 0 deletions config/user-rbac/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
resources:
- basic-user-rolebinding.yml
- basic-user-role.yml
- organization-admin-role.yml
- organization-viewer-role.yml
11 changes: 11 additions & 0 deletions config/user-rbac/organization-admin-role.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: control-api:organization-admin
rules:
- apiGroups: ["rbac.appuio.io"]
resources: ["organizations"]
verbs: ["get", "watch", "list", "patch", "edit", "create"]
- apiGroups: ["appuio.io"]
resources: ["organizationmembers"]
verbs: ["get", "watch", "list", "patch", "edit", "create"]
14 changes: 14 additions & 0 deletions config/user-rbac/organization-viewer-role.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: control-api:organization-viewer
rules:
- apiGroups: ["rbac.appuio.io"]
resources: ["organizations"]
verbs: ["get", "watch", "list"]
- apiGroups: ["appuio.io"]
resources: ["organizationmembers"]
verbs: ["get", "watch", "list"]
- apiGroups: ["rbac.authorization.k8s.io"]
resources: ["rolebindings"]
verbs: ["get", "watch", "list"]
1 change: 1 addition & 0 deletions local-env/setup-kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ kubectl config set-credentials oidc-user \
kubectl config set-context --current --user=oidc-user
kubectl apply -k "${script_dir}/../config/crd/apiextensions.k8s.io/v1"
kubectl apply -k "${script_dir}/../config/deployment"
kubectl apply -k "${script_dir}/../config/user-rbac"

echo =======
echo "Setup finished. To interact with the local dev cluster, set the KUBECONFIG environment variable as follows:"
Expand Down
3 changes: 2 additions & 1 deletion local-env/templates/kind-oidc.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ nodes:
extraArgs:
oidc-issuer-url: ISSUER_KEYCLOAK/auth/realms/REALM
oidc-client-id: local-dev
oidc-username-claim: email
oidc-username-claim: preferred_username
oidc-username-prefix: "appuio#"
oidc-groups-claim: groups