Skip to content

Commit 6b5ca73

Browse files
committed
Run as non root
1 parent 71ea045 commit 6b5ca73

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

Dockerfile

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Use Python 3.13 slim image
22
FROM python:3.13-slim
33

4+
# Create non-root user
5+
RUN groupadd -r syncuser && useradd -r -g syncuser -u 1000 syncuser
6+
47
# Set working directory
58
WORKDIR /app
69

@@ -10,6 +13,7 @@ RUN apt-get update && \
1013
libldap2-dev \
1114
libsasl2-dev \
1215
gcc \
16+
procps \
1317
&& rm -rf /var/lib/apt/lists/*
1418

1519
# Copy requirements first for better layer caching
@@ -21,12 +25,17 @@ RUN pip install --no-cache-dir -r requirements.txt
2125
# Copy application code
2226
COPY *.py ./
2327

24-
# Create log directory
25-
RUN mkdir -p /var/log/ldap-openfga-sync
26-
28+
# Copy entrypoint script
2729
COPY entrypoint.sh /app/entrypoint.sh
2830
RUN chmod +x /app/entrypoint.sh
2931

32+
# Create log directory and set ownership
33+
RUN mkdir -p /var/log/ldap-openfga-sync && \
34+
chown -R syncuser:syncuser /app /var/log/ldap-openfga-sync
35+
36+
# Switch to non-root user
37+
USER syncuser
38+
3039
# Expose volume for logs
3140
VOLUME ["/var/log/ldap-openfga-sync"]
3241

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ This script synchronizes group memberships from LDAP to OpenFGA using the [diffs
99
- Supports dry-run mode to preview changes before applying them
1010
- Users are identified by their email addresses
1111
- Comprehensive logging
12+
- Runs as non-root user for enhanced security
1213

1314
## Requirements
1415

helm/ldap-openfga-sync/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ podLabels: {}
3131
podSecurityContext:
3232
runAsNonRoot: true
3333
runAsUser: 1000
34+
runAsGroup: 1000
3435
fsGroup: 1000
3536

3637
securityContext:
@@ -39,6 +40,8 @@ securityContext:
3940
drop:
4041
- ALL
4142
readOnlyRootFilesystem: false
43+
runAsNonRoot: true
44+
runAsUser: 1000
4245

4346
resources:
4447
limits:

0 commit comments

Comments
 (0)