Skip to content

Commit

Permalink
feat: add oauth2 proxy for dagster
Browse files Browse the repository at this point in the history
  • Loading branch information
reinthal committed Dec 2, 2024
1 parent 5f6fed3 commit 53a5e90
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 2 deletions.
2 changes: 2 additions & 0 deletions apps/base/dagster/.env.example.oauth2-proxy
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
OAUTH2_PROXY_COOKIE_SECRET=CONFIGUREME
OAUTH2_PROXY_CLIENT_SECRET=CONFIGUREME
2 changes: 2 additions & 0 deletions apps/base/dagster/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.oauth2-secret.env
oauth2-proxy-dagster-secrets.yaml
4 changes: 4 additions & 0 deletions apps/base/dagster/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@ resources:
- codeserver-configuration.yaml
- codeserver-secrets-sealed.yaml
- postgres-auth-sealed.yaml
# Oauth2 Proxy
- oauth2-proxy-dagster-config.yaml
- oauth2-proxy-dagster-helmrelease.yaml
- oauth2-proxy-dagster-secrets-sealed.yaml
# frontend
- ingress.yaml
14 changes: 14 additions & 0 deletions apps/base/dagster/oauth2-proxy-dagster-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: oauth2-dagster-proxy-config
namespace: dagster
data:
OAUTH2_PROXY_PROVIDER: keycloak-oidc
OAUTH2_PROXY_CLIENT_ID: dagster-webserver
OAUTH2_PROXY_REDIRECT_URL: https://dagster.local.reinthal.cc/oauth2/callback
OAUTH2_PROXY_OIDC_ISSUER_URL: https://keycloak.local.reinthal.cc/auth/realms/reinthal
OAUTH2_PROXY_EMAIL_DOMAINS: reinthal.me
OAUTH2_PROXY_ALLOWED_ROLES: dagster-operator
OAUTH2_PROXY_CODE_CHALLENGE_METHOD: S256
OAUTH2_PROXY_UPSTREAMS: "http://dagster-dagster-webserver.dagster.svc"
51 changes: 51 additions & 0 deletions apps/base/dagster/oauth2-proxy-dagster-helmrelease.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
apiVersion: source.toolkit.fluxcd.io/v1beta2
kind: HelmRepository
metadata:
name: oauth2-proxy
namespace: dagster
spec:
interval: 1m0s
url: https://oauth2-proxy.github.io/manifests
---
apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease
metadata:
name: oauth2-proxy
namespace: dagster
spec:
chart:
spec:
chart: oauth2-proxy
reconcileStrategy: ChartVersion
sourceRef:
kind: HelmRepository
name: oauth2-proxy
namespace: dagster
version: 7.8.0
install:
createNamespace: false
interval: 1m0s
releaseName: oauth2-dagster-webui-proxy
targetNamespace: dagster
values:

config:

existingSecret: oauth2-proxy-secrets
existingConfig: oauth2-dagster-proxy-config

image:
pullPolicy: IfNotPresent
repository: quay.io/oauth2-proxy/oauth2-proxy
tag: "v7.7.1"
kubeVersion: null
namespaceOverride: ""
replicaCount: 2
resources:
limits:
cpu: 100m
memory: 300Mi
requests:
cpu: 100m
memory: 300Mi
16 changes: 16 additions & 0 deletions apps/base/dagster/oauth2-proxy-dagster-secrets-sealed.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
apiVersion: bitnami.com/v1alpha1
kind: SealedSecret
metadata:
creationTimestamp: null
name: oauth2-proxy-secrets
namespace: dagster
spec:
encryptedData:
OAUTH2_PROXY_CLIENT_SECRET: AgB5JWtR4e7oD7QgBOMYPc6oLqUtAZa3LpkSPp4+3DRnNzdbZyGDmSf256/9X8bdmYAWBn17Iqbnb/UVu8iN6NhpxoPkIErrgV0ZzWnl+qcTE44KyMFX1PwMdHuOf070DvkmboanX+gjHaPGgXdhMZffuGPKpBp2M7XYRHpydHf6EMpkfx7GlrfEKvcRlQcEh9img2Ujb7sR/TMM/zVVUf4zDryrirADs0Sj7nhtUv5jt+j0foTWsyJRaQvEJv8Ky04IWAGZ9G0Dgw4KEssLf6s/DhJz0yrb+KKvc538S33gBb5Jj0JnyR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srIwK23uneopoL5W0jtZBQpsUIa7jXU3VRMeatFk6Qp4Rel7iW8c2woVZMrdjafvCXcMv987fsGIHxeilhYcrXlSjCwa1+3+9bhX6/a2mewEYW7fTWuTdvM1gHQ2Wb6Y+PTijByn2oN8qWIV3Q8i3/ZxeMFdtWUytPMhUm1aA==
template:
metadata:
creationTimestamp: null
name: oauth2-proxy-secrets
namespace: dagster
7 changes: 5 additions & 2 deletions apps/base/dagster/readme.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
# Oauth2 Proxy

## Generating a Cookie Secret

```bash
python -c 'import os,base64; print(base64.urlsafe_b64encode(os.urandom(32)).decode())'
```

## Generating the Client Secret

TODO

## Generating the sealed secret

```bash
cp .env.example.oauth2-proxy .oauth2-secret.env
```

Perform the above steps and put the secrets in `.oauth2-secret.env`. Then perform the below command.

```bash
kubectl create secret generic oauth2-proxy-secrets \
-n dagster --from-env-file=.oauth2-secret.env -o yaml \
--dry-run | tee oauth2-secret.yaml | \
--dry-run | tee oauth2-proxy-dagster-secrets.yaml | \
kubeseal --format=yaml --cert=../../../keys/pub-sealed-secrets.pem | \
tee snowflake-secrets-sealed.yaml
tee oauth2-proxy-dagster-secrets-sealed.yaml
```

Commit changes and push using `deploy` script.

0 comments on commit 53a5e90

Please sign in to comment.