Skip to content

Commit 0c85428

Browse files
committed
Support JWT auth in mergeable minions
1 parent 42e53c9 commit 0c85428

File tree

12 files changed

+856
-112
lines changed

12 files changed

+856
-112
lines changed

examples/jwt/README.md

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ The Ingress controller provides the following 4 annotations for configuring JWT
99
* Optional: ```nginx.com/jwt-token: "token"``` -- specifies a variable that contains JSON Web Token. By default, a JWT is expected in the `Authorization` header as a Bearer Token.
1010
* Optional: ```nginx.com/jwt-login-url: "url"``` -- specifies a URL to which a client is redirected in case of an invalid or missing JWT.
1111

12-
## Example
12+
## Example 1: the Same JWT Key for All Paths
1313

14-
In the following example we enable JWT validation for the cafe-ingress Ingress:
14+
In the following example we enable JWT validation for the cafe-ingress Ingress for all paths using the same key `cafe-jwk`:
1515
```yaml
1616
apiVersion: extensions/v1beta1
1717
kind: Ingress
@@ -44,3 +44,74 @@ spec:
4444
* The realm is `Cafe App`.
4545
* The token is extracted from the `auth_token` cookie.
4646
* The login URL is `https://login.example.com`.
47+
48+
## Example 2: a Separate JWT Key Per Path
49+
50+
In the following example we enable JWT validation for the [mergeable Ingresses](../mergeable-ingress-types) with a separate JWT key per path:
51+
52+
* Master:
53+
```yaml
54+
apiVersion: extensions/v1beta1
55+
kind: Ingress
56+
metadata:
57+
name: cafe-ingress-master
58+
annotations:
59+
kubernetes.io/ingress.class: "nginx"
60+
nginx.org/mergeable-ingress-type: "master"
61+
spec:
62+
tls:
63+
- hosts:
64+
- cafe.example.com
65+
secretName: cafe-secret
66+
rules:
67+
- host: cafe.example.com
68+
```
69+
70+
* Tea minion:
71+
```yaml
72+
apiVersion: extensions/v1beta1
73+
kind: Ingress
74+
metadata:
75+
name: cafe-ingress-tea-minion
76+
annotations:
77+
kubernetes.io/ingress.class: "nginx"
78+
nginx.org/mergeable-ingress-type: "minion"
79+
nginx.com/jwt-key: "tea-jwk"
80+
nginx.com/jwt-realm: "Tea"
81+
nginx.com/jwt-token: "$cookie_auth_token"
82+
nginx.com/jwt-login-url: "https://login-tea.cafe.example.com"
83+
spec:
84+
rules:
85+
- host: cafe.example.com
86+
http:
87+
paths:
88+
- path: /tea
89+
backend:
90+
serviceName: tea-svc
91+
servicePort: 80
92+
```
93+
94+
* Coffee minion:
95+
```yaml
96+
apiVersion: extensions/v1beta1
97+
kind: Ingress
98+
metadata:
99+
name: cafe-ingress-coffee-minion
100+
annotations:
101+
kubernetes.io/ingress.class: "nginx"
102+
nginx.org/mergeable-ingress-type: "minion"
103+
nginx.com/jwt-key: "coffee-jwk"
104+
nginx.com/jwt-realm: "Coffee"
105+
nginx.com/jwt-token: "$cookie_auth_token"
106+
nginx.com/jwt-login-url: "https://login-coffee.cafe.example.com"
107+
spec:
108+
rules:
109+
- host: cafe.example.com
110+
http:
111+
paths:
112+
- path: /coffee
113+
backend:
114+
serviceName: coffee-svc
115+
servicePort: 80
116+
```
117+

examples/mergeable-ingress-types/README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ Minions cannot contain the following annotations:
3636
* nginx.org/server-tokens
3737
* nginx.org/listen-ports
3838
* nginx.org/listen-ports-ssl
39-
* nginx.com/jwt-key
40-
* nginx.com/jwt-realm
41-
* nginx.com/jwt-token
42-
* nginx.com/jwt-login-url
4339
* nginx.org/server-snippets
4440

4541
Minions inherent the following annotations from the master, unless they override them:

0 commit comments

Comments
 (0)