1amends "../../config/Service.pkl"
2
3import "../../config/site.pkl" as site
4import "../../config/OpenID.pkl" as sso
5
6local isPreview = read?("prop:preview") == "true"
7
8name = "Forward Auth"
9rollout = "overlapped"
10
11requirements {
12 new sso.Client {
13 clientId = module.id
14 name = module.name
15 redirectUris {
16 when (isPreview) { "https://\(module.id).\(site.domain)/snow.oauth2/callback" }
17 when (!isPreview) { for (host in new Listing<String> { "music"; "seedbox"; "ddns"; "redis"; "pg"; "snr"; "rdr"; "logs"; "metrics"; "traces"; "jkt"; "openclaw" }) {
18 "https://\(host).\(site.domain)/snow.oauth2/callback"
19 } }
20 }
21 }
22}
23
24secrets {
25 ["cookie"] { bytes = 16 }
26}
27
28container {
29 build = "../forward-auth"
30 cpu = 100
31 memory = 256
32
33 http {
34 containerPort = 4180
35 checkPath = "/ping"
36 subdomain = if (isPreview) module.id else null
37 }
38
39 volumes {
40 ["/etc/ssl/certs/ca-certificates.crt"] {
41 src = "/var/lib/snowglobe/ca-bundle.crt"
42 readOnly = true
43 }
44 }
45
46 env {
47 ["OAUTH2_PROXY_CLIENT_ID"] = "${secret.oidc.clientId}"
48 ["OAUTH2_PROXY_CLIENT_SECRET"] = "${secret.oidc.clientSecret}"
49 ["OAUTH2_PROXY_COOKIE_SECRET"] = "${secret.own.cookie}"
50 ["OAUTH2_PROXY_PROVIDER"] = "oidc"
51 ["OAUTH2_PROXY_OIDC_ISSUER_URL"] = sso.issuer
52 ["OAUTH2_PROXY_SCOPE"] = "openid profile email groups"
53 ["OAUTH2_PROXY_OIDC_GROUPS_CLAIM"] = "groups"
54 // Existing accounts may have no email.
55 ["OAUTH2_PROXY_OIDC_EMAIL_CLAIM"] = "preferred_username"
56 ["OAUTH2_PROXY_CODE_CHALLENGE_METHOD"] = "S256"
57 ["OAUTH2_PROXY_EMAIL_DOMAINS"] = "*"
58 ["OAUTH2_PROXY_HTTP_ADDRESS"] = "0.0.0.0:4180"
59 ["OAUTH2_PROXY_PROXY_PREFIX"] = "/snow.oauth2"
60 ["OAUTH2_PROXY_SKIP_PROVIDER_BUTTON"] = "true"
61 ["OAUTH2_PROXY_REVERSE_PROXY"] = "true"
62 ["OAUTH2_PROXY_WHITELIST_DOMAINS"] = "*.\(site.domain)"
63 ["OAUTH2_PROXY_COOKIE_DOMAINS"] = ".\(site.domain)"
64 when (isPreview) { ["OAUTH2_PROXY_COOKIE_NAME"] = "_snow_stage_\(module.id)" }
65 ["OAUTH2_PROXY_SET_XAUTHREQUEST"] = "true"
66 ["OAUTH2_PROXY_PASS_USER_HEADERS"] = "true"
67 ["OAUTH2_PROXY_INSECURE_OIDC_ALLOW_UNVERIFIED_EMAIL"] = "true"
68 ["OAUTH2_PROXY_UPSTREAMS"] = "static://202"
69 }
70}