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

feat(openshift): add configuration for proxy SubjectAccessReview #132

Merged
merged 20 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
f56cfbb
feat(openshift): add configuration for proxy SubjectAccessReview
andrewazores Apr 17, 2024
8572e51
remove commented flag, wrap SAR as array
andrewazores Apr 17, 2024
b76445b
pipe full access object through toJson filter, then interpret as a te…
andrewazores Apr 17, 2024
aa3aca4
access object becomes list
andrewazores Apr 17, 2024
e3e382b
add clusterrole(binding) and enable auth master delegation - enables …
andrewazores Apr 17, 2024
fc49cfa
make tokenreview configurable, fix doc comments
andrewazores Apr 17, 2024
a7f4047
fixup docs, regenerate readme and schema
andrewazores Apr 17, 2024
58b3303
use system:auth-delegator clusterrole
andrewazores Apr 18, 2024
d1e9711
document tokenreview usage
andrewazores Apr 18, 2024
3bfd2bf
add more configuration parameters for customization
andrewazores Apr 18, 2024
8d83291
secure /api, /grafana, storage separately rather than under / catchall
andrewazores Apr 18, 2024
e50fcbc
do not require auth on /health
andrewazores Apr 24, 2024
67355b4
simplify config for skipping auth on /health
andrewazores Apr 26, 2024
d58bee8
safer health check auth bypass regex
andrewazores May 2, 2024
dd509cf
rename accessReview -> subjectAccessReview, tokenReview -> tokenAcces…
andrewazores May 2, 2024
c84463d
fixup! rename accessReview -> subjectAccessReview, tokenReview -> tok…
andrewazores May 2, 2024
e18068c
add JMC Agent probes bucket to precreate list
andrewazores May 3, 2024
27bf241
fixup! safer health check auth bypass regex
andrewazores May 3, 2024
0714655
unify subjectaccessreview/tokenaccessreview config
andrewazores May 22, 2024
ce7aec0
accessreview can be disabled
andrewazores May 29, 2024
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
41 changes: 29 additions & 12 deletions charts/cryostat/README.md

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions charts/cryostat/templates/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{- if and (.Values.rbac.create) (.Values.authentication.openshift.enabled) -}}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "cryostat.fullname" . }}
labels:
{{- include "cryostat.labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ .Values.authentication.openshift.clusterRole.name }}
subjects:
- kind: ServiceAccount
name: {{ include "cryostat.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
{{- end }}
2 changes: 1 addition & 1 deletion charts/cryostat/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ spec:
imagePullPolicy: {{ (.Values.storage).image.pullPolicy }}
env:
- name: CRYOSTAT_BUCKETS
value: archivedrecordings,archivedreports,eventtemplates
value: archivedrecordings,archivedreports,eventtemplates,probes
- name: CRYOSTAT_ACCESS_KEY
value: cryostat
- name: CRYOSTAT_SECRET_KEY
Expand Down
3 changes: 3 additions & 0 deletions charts/cryostat/templates/oauth2Proxy.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
{{- if not .Values.authentication.basicAuth.enabled }}
- name: OAUTH2_PROXY_SKIP_AUTH_ROUTES
value: ".*"
{{- else }}
- name: OAUTH2_PROXY_SKIP_AUTH_ROUTES
value: "^/health(/liveness)?$"
{{- end }}
ports:
- containerPort: 4180
Expand Down
5 changes: 5 additions & 0 deletions charts/cryostat/templates/openshiftOauthProxy.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
- --tls-cert=/etc/tls/private/tls.crt
- --tls-key=/etc/tls/private/tls.key
- --proxy-prefix=/oauth2
{{- if .Values.openshiftOauthProxy.accessReview.enabled }}
- --openshift-sar=[{{ tpl ( omit .Values.openshiftOauthProxy.accessReview "enabled" | toJson ) . }}]
- --openshift-delegate-urls={"/":{{ tpl ( omit .Values.openshiftOauthProxy.accessReview "enabled" | toJson ) . }}}
{{- end }}
- --bypass-auth-for=^/health(/liveness)?$
{{- if .Values.authentication.basicAuth.enabled }}
- --htpasswd-file=/etc/openshift_oauth_proxy/basicauth/{{ .Values.authentication.basicAuth.filename }}
{{- end }}
Expand Down
99 changes: 77 additions & 22 deletions charts/cryostat/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,51 @@
}
}
},
"authentication": {
"type": "object",
"properties": {
"openshift": {
"type": "object",
"properties": {
"enabled": {
"type": "boolean",
"description": "Whether the OAuth Proxy deployed for securing Cryostat's Pods should be one that integrates with OpenShift-specific features, or a generic one.",
"default": false
},
"clusterRole": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "The name of the ClusterRole to bind for the OpenShift OAuth Proxy",
"default": "system:auth-delegator"
}
}
}
}
},
"basicAuth": {
"type": "object",
"properties": {
"enabled": {
"type": "boolean",
"description": "Whether Cryostat should use basic authentication for users. When false, Cryostat will not perform any form of authentication",
"default": false
},
"secretName": {
"type": "string",
"description": "Name of the Secret that contains the credentials within Cryostat's namespace **(Required if basicAuth is enabled)**",
"default": ""
},
"filename": {
"type": "string",
"description": "Key within Secret containing the `htpasswd` file. The file should contain one user definition entry per line, with the syntax \"user:passHash\", where \"user\" is the username and \"passHash\" is the `bcrypt` hash of the desired password. Such an entry can be generated with ex. `htpasswd -nbB username password` **(Required if basicAuth is enabled)**",
"default": ""
}
}
}
}
},
"openshiftOauthProxy": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -515,38 +560,48 @@
"default": "latest"
}
}
}
}
},
"authentication": {
"type": "object",
"properties": {
"openshift": {
"type": "object",
"properties": {
"enabled": {
"type": "boolean",
"description": "Whether the OAuth Proxy deployed for securing Cryostat's Pods should be one that integrates with OpenShift-specific features, or a generic one.",
"default": false
}
}
},
"basicAuth": {
"accessReview": {
"type": "object",
"properties": {
"enabled": {
"type": "boolean",
"description": "Whether Cryostat should use basic authentication for users. When false, Cryostat will not perform any form of authentication",
"default": false
"description": "Whether the SubjectAccessReview/TokenAccessReview role checks for users and clients are enabled. If this is disabled then the proxy will only check that the user has valid credentials or holds a valid token.",
"default": true
},
"secretName": {
"group": {
"type": "string",
"description": "Name of the Secret that contains the credentials within Cryostat's namespace **(Required if basicAuth is enabled)**",
"description": "The OpenShift resource group that the SubjectAccessReview/TokenAccessReview will be performed for. See https://github.com/openshift/oauth-proxy/?tab=readme-ov-file#delegate-authentication-and-authorization-to-openshift-for-infrastructure",
"default": ""
},
"filename": {
"resource": {
"type": "string",
"description": "Key within Secret containing the `htpasswd` file. The file should contain one user definition entry per line, with the syntax \"user:passHash\", where \"user\" is the username and \"passHash\" is the `bcrypt` hash of the desired password. Such an entry can be generated with ex. `htpasswd -nbB username password` **(Required if basicAuth is enabled)**",
"description": "The OpenShift resource that the SubjectAccessReview/TokenAccessReview will be performed for.",
"default": "pods"
},
"subresource": {
"type": "string",
"description": "The OpenShift resource that the SubjectAccessReview/TokenAccessReview will be performed for.",
"default": "exec"
},
"name": {
"type": "string",
"description": "The OpenShift resource name that the SubjectAccessReview/TokenAccessReview will be performed for.",
"default": ""
},
"namespace": {
"type": "string",
"description": "The OpenShift namespace that the SubjectAccessReview/TokenAccessReview will be performed for.",
"default": "{{ .Release.Namespace }}"
},
"verb": {
"type": "string",
"description": "The OpenShift resource name that the SubjectAccessReview/TokenAccessReview will be performed for.",
"default": "create"
},
"version": {
"type": "string",
"description": "The OpenShift resource version that the SubjectAccessReview/TokenAccessReview will be performed for.",
"default": ""
}
}
Expand Down
20 changes: 20 additions & 0 deletions charts/cryostat/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ authentication:
openshift:
## @param authentication.openshift.enabled Whether the OAuth Proxy deployed for securing Cryostat's Pods should be one that integrates with OpenShift-specific features, or a generic one.
enabled: false
clusterRole:
## @param authentication.openshift.clusterRole.name The name of the ClusterRole to bind for the OpenShift OAuth Proxy
name: system:auth-delegator
basicAuth:
## @param authentication.basicAuth.enabled Whether Cryostat should use basic authentication for users. When false, Cryostat will not perform any form of authentication
enabled: false
Expand Down Expand Up @@ -193,6 +196,23 @@ openshiftOauthProxy:
pullPolicy: Always
## @param openshiftOauthProxy.image.tag Tag for the OpenShift OAuth Proxy container image
tag: "latest"
accessReview:
## @param openshiftOauthProxy.accessReview.enabled Whether the SubjectAccessReview/TokenAccessReview role checks for users and clients are enabled. If this is disabled then the proxy will only check that the user has valid credentials or holds a valid token.
enabled: true
## @param openshiftOauthProxy.accessReview.group The OpenShift resource group that the SubjectAccessReview/TokenAccessReview will be performed for. See https://github.com/openshift/oauth-proxy/?tab=readme-ov-file#delegate-authentication-and-authorization-to-openshift-for-infrastructure
group: ""
## @param openshiftOauthProxy.accessReview.resource The OpenShift resource that the SubjectAccessReview/TokenAccessReview will be performed for.
resource: "pods"
## @param openshiftOauthProxy.accessReview.subresource The OpenShift resource that the SubjectAccessReview/TokenAccessReview will be performed for.
subresource: "exec"
## @param openshiftOauthProxy.accessReview.name The OpenShift resource name that the SubjectAccessReview/TokenAccessReview will be performed for.
name: ""
## @param openshiftOauthProxy.accessReview.namespace The OpenShift namespace that the SubjectAccessReview/TokenAccessReview will be performed for.
namespace: "{{ .Release.Namespace }}"
## @param openshiftOauthProxy.accessReview.verb The OpenShift resource name that the SubjectAccessReview/TokenAccessReview will be performed for.
verb: "create"
## @param openshiftOauthProxy.accessReview.version The OpenShift resource version that the SubjectAccessReview/TokenAccessReview will be performed for.
version: ""
## @param openshiftOauthProxy.securityContext [object] Security Context for the OpenShift OAuth Proxy container. Defaults to meet "restricted" [Pod Security Standard](https://kubernetes.io/docs/concepts/security/pod-security-standards/#restricted). See: [SecurityContext](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#security-context-1)
securityContext:
## @skip openshiftOauthProxy.securityContext.allowPrivilegeEscalation
Expand Down