File tree 1 file changed +15
-2
lines changed
1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 1
1
{{- $v := .Values }}
2
+ {{- $escapedDomain := $v.cluster.domainSuffix | replace "." "\\." }}
2
3
{{- $domain := printf "auth.%s" $v.cluster.domainSuffix }}
3
4
{{- $consoleUrl := printf "https://console.%s" $v.cluster.domainSuffix }}
4
5
{{- $cm := $v.apps | get "cert-manager" }}
@@ -29,8 +30,20 @@ resources:
29
30
nginx.ingress.kubernetes.io/auth-response-headers: Authorization
30
31
{{- end }}
31
32
nginx.ingress.kubernetes.io/configuration-snippet: |
32
- # rewrite auth redirects to original hosts
33
- rewrite ^/oauth2/redirect/(.*) https://$1 redirect;
33
+ set $redirect_target "";
34
+
35
+ # if $request_uri starts with "/oauth2/redirect/", the $redirect_target will be set to whatever comes after that.
36
+ # e.g. https://auth.lkeid.akamai-apl.net/oauth2/redirect/example.com/ will set $redirect_target to https://example.com/
37
+ if ($request_uri ~* ^/oauth2/redirect/(.*)) {
38
+ set $redirect_target $1;
39
+ }
40
+
41
+ # if the redirect_target matches a cluster's subdomain it will redirect to the cluster's subdomain with the rest of the path.
42
+ # e.g. https://auth.lkeid.akamai-apl.net/oauth2/redirect/console.lkeid.akamai-apl.net/ will redirect to console.lkeid.akamai-apl.net/
43
+ # e.g. https://auth.lkeid.akamai-apl.net/oauth2/redirect/evil.com will not be processed by the ingress controller.
44
+ if ($redirect_target ~* "^([a-zA-Z0-9-]+\.){{ $escapedDomain }}(%2F)?(/.*)?$") {
45
+ return 302 https://$redirect_target;
46
+ }
34
47
{{- with $ingress | get "sourceIpAddressFiltering" nil }}
35
48
nginx.ingress.kubernetes.io/whitelist-source-range: "{{ . }}"
36
49
{{- end}}
You can’t perform that action at this time.
0 commit comments