-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoauth2-proxy-dex.yaml
294 lines (294 loc) · 7.48 KB
/
oauth2-proxy-dex.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
app.kubernetes.io/name: dexidp
name: dexidp-sa
---
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
app: oauth2-proxy
name: oauth2-proxy-sa
---
apiVersion: v1
kind: Secret
metadata:
labels:
app.kubernetes.io/name: dexidp
name: dexidp-secret
stringData:
config.yaml: |-
issuer: http://dex.localtest.me
storage:
config:
inCluster: true
type: kubernetes
logger:
level: debug
web:
http: 0.0.0.0:5556
oauth2:
alwaysShowLoginScreen: false
skipApprovalScreen: true
staticClients:
- id: oauth2-proxy
name: OAuth2 Proxy
redirectURIs:
- http://oauth2-proxy.localtest.me/oauth2/callback
secret: b2F1dGgyLXByb3h5LWNsaWVudC1zZWNyZXQK
enablePasswordDB: true
staticPasswords:
- email: [email protected]
hash: $2a$10$2b2cU8CPhOTaGrs1HRQuAueS7JTT5ZHsHSzYiFPm1leZck7Mc8T4W
userID: 08a8684b-db88-4b73-90a9-3cd1661f5466
username: admin
expiry:
idTokens: 1h
signingKeys: 4h
---
# Source: kubernetes/charts/oauth2-proxy/templates/configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
labels:
app: oauth2-proxy
name: oauth2-proxy-config
data:
oauth2_proxy.cfg: "cookie_secret=\"OQINaROshtE9TcZkNAm-5Zs2Pv3xaWytBmc5W7sPX7w=\"\ncookie_domain=\".localtest.me\"\nwhitelist_domains=[\".localtest.me\"]\n# only users with this domain will be let in\nemail_domains=[\"example.com\"]\n\nclient_id=\"oauth2-proxy\"\nclient_secret=\"b2F1dGgyLXByb3h5LWNsaWVudC1zZWNyZXQK\"\ncookie_secure=\"false\"\n\nredirect_url=\"http://oauth2-proxy.localtest.me/oauth2/callback\"\n\n# we don't want to proxy anything so pick a non-existent directory\nupstreams = [ \"file:///dev/null\" ]\n\n# return authenticated user to nginx\nset_xauthrequest = true\n# using http://dex.localtest.me/.well-known/openid-configuration oauth2-proxy will populate\n# login_url, redeem_url, and oidc_jwks_url\nprovider=\"oidc\"\noidc_issuer_url=\"http://dex.localtest.me\""
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
app.kubernetes.io/name: dexidp
name: dexidp-cr
rules:
- apiGroups: ["dex.coreos.com"] # API group created by dex
resources: ["*"]
verbs: ["*"]
- apiGroups: ["apiextensions.k8s.io"]
resources: ["customresourcedefinitions"]
verbs: ["create"] # To manage its own resources, dex must be able to create customresourcedefinitions
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
labels:
app.kubernetes.io/name: dex
name: dexidp-crb
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: dexidp-cr
subjects:
- kind: ServiceAccount
name: dexidp-sa
namespace: default
---
apiVersion: v1
kind: Service
metadata:
name: dexidp-service
labels:
app.kubernetes.io/name: dexidp
spec:
type: ClusterIP
sessionAffinity: None
ports:
- name: http
targetPort: http
port: 32000
selector:
app.kubernetes.io/name: dexidp
app.kubernetes.io/instance: auth-example
---
apiVersion: v1
kind: Service
metadata:
labels:
app: oauth2-proxy
name: oauth2-proxy-service
spec:
type: ClusterIP
ports:
- port: 80
targetPort: http
protocol: TCP
name: http
selector:
app: oauth2-proxy
release: oauth2-proxy-example
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: dexidp
labels:
app.kubernetes.io/name: dexidp
spec:
replicas: 1
strategy:
rollingUpdate:
maxSurge: 0
maxUnavailable: 1
type: RollingUpdate
selector:
matchLabels:
app.kubernetes.io/name: dexidp
app.kubernetes.io/instance: auth-example
template:
metadata:
labels:
app.kubernetes.io/name: dexidp
app.kubernetes.io/instance: auth-example
annotations:
checksum/config: 185f32cfabdf4f7467868dc301d4bd33e68951e12eddeb69f23ebc1d0f91ba28
spec:
serviceAccountName: dexidp-sa
nodeSelector:
{}
containers:
- name: main
image: "quay.io/dexidp/dex:v2.23.0"
imagePullPolicy: IfNotPresent
command:
- /usr/local/bin/dex
- serve
- /etc/dex/cfg/config.yaml
resources:
null
ports:
- name: http
containerPort: 5556
protocol: TCP
livenessProbe:
httpGet:
path: /healthz
port: http
initialDelaySeconds: 1
periodSeconds: 10
timeoutSeconds: 1
failureThreshold: 1
readinessProbe:
httpGet:
path: /healthz
port: http
initialDelaySeconds: 1
periodSeconds: 10
timeoutSeconds: 1
failureThreshold: 1
env:
[]
volumeMounts:
- mountPath: /etc/dex/cfg
name: config
volumes:
- secret:
defaultMode: 420
items:
- key: config.yaml
path: config.yaml
secretName: dexidp-secret
name: config
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: oauth2-proxy
name: oauth2-proxy
spec:
replicas: 1
selector:
matchLabels:
app: oauth2-proxy
release: oauth2-proxy-example
template:
metadata:
annotations:
checksum/config: 5d8892a7b1d9eb03f9d59b787ce339b374fa2be51991e4e7533cb0a541984fac
checksum/config-emails: 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b
checksum/secret: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
checksum/google-secret: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
labels:
app: oauth2-proxy
release: oauth2-proxy-example
spec:
serviceAccountName: oauth2-proxy-sa
containers:
- name: oauth2-proxy
image: "quay.io/pusher/oauth2_proxy:v5.1.0"
imagePullPolicy: IfNotPresent
args:
- --http-address=0.0.0.0:4180
- --config=/etc/oauth2_proxy/oauth2_proxy.cfg
ports:
- containerPort: 4180
name: http
protocol: TCP
livenessProbe:
httpGet:
path: /ping
port: http
scheme: HTTP
initialDelaySeconds: 0
timeoutSeconds: 1
readinessProbe:
httpGet:
path: /ping
port: http
scheme: HTTP
initialDelaySeconds: 0
timeoutSeconds: 1
successThreshold: 1
periodSeconds: 10
resources:
{}
volumeMounts:
- mountPath: /etc/oauth2_proxy
name: configmain
volumes:
- configMap:
defaultMode: 420
name: oauth2-proxy-config
name: configmain
tolerations:
[]
---
# Source: kubernetes/charts/dex/templates/ingress.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: dexidp-ingress
labels:
app.kubernetes.io/name: dexidp
spec:
rules:
- host: "dex.localtest.me"
http:
paths:
- path: /
backend:
serviceName: dexidp-service
servicePort: 32000
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
labels:
app: oauth2-proxy
name: oauth2-proxy-ingress
annotations:
nginx.ingress.kubernetes.io/server-snippet: |
large_client_header_buffers 4 32k;
spec:
rules:
- host: oauth2-proxy.localtest.me
http:
paths:
- path: /
backend:
serviceName: oauth2-proxy-service
servicePort: 80