@@ -10,3 +10,120 @@ nats:
1010 # url is the URL of the NATS server
1111 url : nats://nats.lfx.svc.cluster.local:4222
1212 projects_kv_bucket_name : projects
13+
14+ # heimdall is the configuration for the heimdall middleware
15+ heimdall :
16+ env :
17+ CLIENT_SECRET :
18+ secretKeyRef :
19+ name : heimdall-secrets
20+ key : heimdall_client_secret
21+
22+ mechanisms :
23+ authenticators :
24+ - id : anonymous_authenticator
25+ type : anonymous
26+ config :
27+ subject : " _anonymous"
28+ - id : authelia
29+ type : oauth2_introspection
30+ config :
31+ metadata_endpoint :
32+ url : http://auth.k8s.orb.local/.well-known/oauth-authorization-server
33+ resolved_endpoints :
34+ introspection_endpoint :
35+ auth :
36+ type : basic_auth
37+ config :
38+ user : heimdall
39+ password : ${CLIENT_SECRET}
40+ assertions :
41+ audience :
42+ - " http://lfx-api.k8s.orb.local/"
43+ subject :
44+ # Authelia doesn't provide a "sub" claim for client_credentials token
45+ # introspection. Use a GJSON query to extract either the username or
46+ # the client_id. Client IDs can collide with usernames (and GJSON
47+ # doesn't let us do array concatenation to add a literal prefix), so
48+ # the `sub` claim should NOT be used downstream.
49+ id : ' [username,client_id].0'
50+ contextualizers :
51+ - id : authelia_userinfo
52+ type : generic
53+ config :
54+ endpoint :
55+ url : http://auth.k8s.orb.local/api/oidc/userinfo
56+ method : GET
57+ forward_headers :
58+ - Authorization
59+ # Continuing on error is needed if this contextualizer is used in any
60+ # rulesets that support anonymous access.
61+ continue_pipeline_on_error : true
62+ authorizers :
63+ - id : allow_all
64+ type : allow
65+ - id : deny_all
66+ type : deny
67+ - id : openfga_check
68+ type : remote
69+ config :
70+ endpoint : ${FGA_CHECK_ENDPOINT}
71+ values :
72+ # Most of the `values` are provided by the matching rule, but the
73+ # `model_id` needs to be set by an environment variable.
74+ model_id : ${FGA_MODEL_ID}
75+ payload : |
76+ {
77+ "authorization_model_id": "{{ .Values.model_id }}",
78+ "tuple_key": {
79+ "user": {{
80+ list
81+ "user:"
82+ (
83+ eq .Subject.ID "_anonymous"
84+ | ternary
85+ "_anonymous"
86+ (or
87+ .Subject.Attributes.username
88+ (list "clients@" .Subject.Attributes.client_id | join ""))
89+ )
90+ | join "" | quote
91+ }},
92+ "relation": "{{ .Values.relation }}",
93+ "object": "{{ .Values.object }}"
94+ }
95+ }
96+ expressions :
97+ - expression : |
98+ Payload.allowed == true
99+ finalizers :
100+ - id : create_jwt
101+ type : jwt
102+ config :
103+ signer :
104+ key_store :
105+ path : /secrets/signer.pem
106+ claims : |
107+ {
108+ "principal": {{
109+ eq .Subject.ID "_anonymous"
110+ | ternary
111+ "_anonymous"
112+ (or
113+ .Subject.Attributes.username
114+ (list "clients@" .Subject.Attributes.client_id | join ""))
115+ | quote
116+ }}
117+ {{ if .Outputs.authelia_userinfo.email -}},
118+ "email": {{ quote .Outputs.authelia_userinfo.email }}
119+ {{ end -}}
120+ {{ if .Values.aud -}},
121+ "aud": {{ quote .Values.aud }}
122+ {{ end -}}
123+ }
124+
125+ default_rule :
126+ execute :
127+ - authenticator : anonymous_authenticator
128+ - authorizer : deny_all
129+ - finalizer : create_jwt
0 commit comments