Skip to content

Commit 7578799

Browse files
authored
Merge branch 'main' into fix/correct-resource-names
2 parents 28883bd + d8bd7ed commit 7578799

File tree

7 files changed

+88
-20
lines changed

7 files changed

+88
-20
lines changed

charts/pdp/Chart.yaml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
apiVersion: v2
22
name: pdp
3-
description: An official Helm chart for Permit.io PDP (Policy Decision Point)
4-
version: 0.0.4
3+
description: An official Helm chart for Permit.io PDP (Policy Decision Point) with OpenShift support
4+
version: 0.0.5
5+
keywords:
6+
- policy
7+
- authorization
8+
- security
9+
- permit
10+
- openshift
11+
maintainers:
12+
- name: Permit.io
13+
url: https://permit.io

charts/pdp/templates/deployment.yaml

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,27 @@ spec:
2626
{{- toYaml . | nindent 8 }}
2727
{{- end }}
2828
spec:
29+
{{- if .Values.openshift.enabled }}
30+
serviceAccountName: {{ .Values.openshift.serviceAccount.name }}
31+
securityContext:
32+
runAsNonRoot: {{ .Values.openshift.securityContext.runAsNonRoot }}
33+
seccompProfile:
34+
type: RuntimeDefault
35+
{{- end }}
2936
containers:
3037
- name: permitio-pdp
3138
image: "{{ .Values.pdp.image.repository }}:{{ .Values.pdp.image.tag }}"
3239
imagePullPolicy: {{ .Values.pdp.image.pullPolicy }}
40+
{{- if .Values.openshift.enabled }}
41+
securityContext:
42+
allowPrivilegeEscalation: false
43+
capabilities:
44+
drop:
45+
- ALL
46+
runAsNonRoot: {{ .Values.openshift.securityContext.runAsNonRoot }}
47+
seccompProfile:
48+
type: RuntimeDefault
49+
{{- end }}
3350
ports:
3451
- containerPort: {{ .Values.pdp.port }}
3552
env:
@@ -94,10 +111,16 @@ spec:
94111
port: 7000
95112
initialDelaySeconds: 10
96113
periodSeconds: 10
97-
{{- if .Values.pdp.logs_forwarder.enabled }}
98114
volumeMounts:
115+
{{- if .Values.pdp.logs_forwarder.enabled }}
99116
- name: logs
100117
mountPath: /tmp/
118+
{{- else if .Values.openshift.enabled }}
119+
# OpenShift requires explicit writable volumes
120+
- name: tmp-volume
121+
mountPath: /tmp
122+
- name: opa-volume
123+
mountPath: /opa
101124
{{- end }}
102125
{{- if .Values.pdp.logs_forwarder.enabled }}
103126
- name: fluentbit
@@ -114,11 +137,17 @@ spec:
114137
fieldRef:
115138
fieldPath: metadata.labels['app']
116139
{{- end }}
117-
{{- if .Values.pdp.logs_forwarder.enabled }}
118140
volumes:
141+
{{- if .Values.pdp.logs_forwarder.enabled }}
119142
- name: fluent-bit-config
120143
configMap:
121144
name: fluentbit-config
122145
- name: logs
123146
emptyDir: {}
147+
{{- else if .Values.openshift.enabled }}
148+
# OpenShift writable volumes
149+
- name: tmp-volume
150+
emptyDir: {}
151+
- name: opa-volume
152+
emptyDir: {}
124153
{{- end }}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{{- if and .Values.openshift.enabled .Values.openshift.serviceAccount.create }}
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: {{ .Values.openshift.serviceAccount.name }}
6+
namespace: {{ .Release.Namespace }}
7+
labels:
8+
{{- include "pdp.labels" . | nindent 4 }}
9+
{{- end }}
10+
11+
{{- if and .Values.openshift.enabled .Values.openshift.serviceAccount.create }}
12+
---
13+
# RoleBinding to allow the ServiceAccount to use the specified SCC
14+
apiVersion: rbac.authorization.k8s.io/v1
15+
kind: RoleBinding
16+
metadata:
17+
name: {{ .Values.openshift.serviceAccount.name }}-scc-binding
18+
namespace: {{ .Release.Namespace }}
19+
labels:
20+
{{- include "pdp.labels" . | nindent 4 }}
21+
subjects:
22+
- kind: ServiceAccount
23+
name: {{ .Values.openshift.serviceAccount.name }}
24+
namespace: {{ .Release.Namespace }}
25+
roleRef:
26+
kind: ClusterRole
27+
name: system:openshift:scc:{{ .Values.openshift.serviceAccount.sccName }}
28+
apiGroup: rbac.authorization.k8s.io
29+
{{- end }}

charts/pdp/values.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ pdp:
2626
# - name: custom_env
2727
# value: "custom_env"
2828
ApiKey: "<your PDP API Key>"
29+
2930
# Use an existing secret for the API key instead of creating one
3031
# If defined, the chart will not create a secret and will use this existing secret
3132
# existingApiKeySecret:
@@ -60,3 +61,17 @@ resources:
6061
memory: "512Mi"
6162
limits:
6263
memory: "1Gi"
64+
65+
# OpenShift configuration
66+
openshift:
67+
enabled: false # Set to true for OpenShift deployments
68+
serviceAccount:
69+
create: true
70+
name: "permitio-pdp-sa"
71+
sccName: "restricted-v2" # OpenShift Security Context Constraint
72+
# Security context (SCC will override user/group settings automatically)
73+
securityContext:
74+
runAsNonRoot: true
75+
runAsUser: 1001
76+
runAsGroup: 1001
77+
fsGroup: 1001

pdp-server/src/api/authzen/errors.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use axum::{
33
response::{IntoResponse, Response},
44
};
55
use serde::{Deserialize, Serialize};
6-
use utoipa::ToSchema;
76

87
/// AuthZen error codes as defined in the specification
98
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
@@ -35,14 +34,6 @@ pub struct AuthZenError {
3534
pub message: String,
3635
}
3736

38-
/// AuthZen error details for OpenAPI documentation only
39-
/// This is NOT used in actual responses, only for OpenAPI schema generation
40-
#[derive(Debug, Serialize, Deserialize, ToSchema)]
41-
pub struct AuthZenErrorDetails {
42-
pub code: String,
43-
pub message: String,
44-
}
45-
4637
impl AuthZenError {
4738
/// Create a new AuthZen error
4839
pub fn new(code: AuthZenErrorCode, message: impl Into<String>) -> Self {

pdp-server/src/cache/mod.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use log::error;
2-
use serde::{de::DeserializeOwned, Deserialize, Serialize};
2+
use serde::{de::DeserializeOwned, Serialize};
33
use thiserror::Error;
44

55
pub mod memory;
@@ -19,12 +19,6 @@ pub enum CacheError {
1919
Config(String),
2020
}
2121

22-
#[derive(Debug, Serialize, Deserialize)]
23-
struct CacheValue {
24-
data: String,
25-
expires_at: u64,
26-
}
27-
2822
/// Cache trait defining the interface for all cache implementations.
2923
///
3024
/// This trait represents the contract that all cache backends must fulfill.

pdp-server/src/opa_client/user_permissions.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ pub struct UserPermissionsResult {
127127
}
128128
// Define a newtype wrapper for HashMap<String, UserPermissionsResult>
129129
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, ToSchema)]
130+
#[allow(dead_code)] // Used for OpenAPI documentation generation
130131
pub struct UserPermissionsResults(pub HashMap<String, UserPermissionsResult>);
131132

132133
// Implement IntoResponse for our newtype

0 commit comments

Comments
 (0)