Skip to content

Commit 4495658

Browse files
authored
Lab8 OIDC (#54)
* lab8 initial * move garage to optional
1 parent 0fc30b7 commit 4495658

23 files changed

+1179
-38
lines changed

labs/lab8/cafe.example.com.conf

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Nginx 4 Azure - Cafe Nginx with Entra ID / OIDC
2+
# Chris Akker, Shouvik Dutta, Adam Currier - Mar 2024
3+
#
4+
server {
5+
6+
# Include AzureAD Auth configuration files
7+
include /etc/nginx/conf.d/oidc/openid_connect.server_conf; # Authorization code flow and Relying Party processing
8+
9+
listen 443 ssl; # Listening on port 443 with "ssl" parameter for terminating TLS on all IP addresses on this machine
10+
11+
server_name cafe.example.com; # Set hostname to match in request
12+
status_zone cafe.example.com; # Metrics zone name
13+
14+
ssl_certificate /etc/nginx/cert/n4a-cert.cert;
15+
ssl_certificate_key /etc/nginx/cert/n4a-cert.key;
16+
17+
access_log /var/log/nginx/cafe.example.com.log main;
18+
error_log /var/log/nginx/cafe.example.com_error.log info;
19+
20+
location / {
21+
#
22+
# return 200 "You have reached cafe.example.com, location /\n";
23+
24+
proxy_pass http://cafe_nginx; # Proxy AND load balance to a list of servers
25+
add_header X-Proxy-Pass cafe_nginx; # Custom Header
26+
27+
# proxy_pass http://windowsvm; # Proxy AND load balance to a list of servers
28+
# add_header X-Proxy-Pass windowsvm; # Custom Header
29+
30+
#proxy_pass http://aks1_ingress; # Proxy AND load balance to AKS1 Nginx Ingress
31+
#add_header X-Proxy-Pass aks1_ingress; # Custom Header
32+
33+
# proxy_pass http://aks2_ingress; # Proxy AND load balance to AKS2 Nginx Ingress
34+
# add_header X-Proxy-Pass aks1_ingress; # Custom Header
35+
36+
# proxy_pass http://$upstream; # Use Split Clients config
37+
# add_header X-Proxy-Pass $upstream; # Custom Header
38+
39+
}
40+
41+
# starting path regex
42+
# This location is protected with OpenID Connect and Azure Entra ID
43+
#
44+
location ~ ^/(beer|wine)$ {
45+
46+
auth_jwt "" token=$session_jwt;
47+
error_page 401 = @do_oidc_flow;
48+
49+
#auth_jwt_key_file $oidc_jwt_keyfile; # Enable when using filename
50+
auth_jwt_key_request /_jwks_uri; # Enable when using URL
51+
52+
# Successfully authenticated users are proxied to the backend,
53+
# with 'sub' claim passed as HTTP header
54+
proxy_set_header username $jwt_claim_sub;
55+
56+
# Bearer token is used to authorize NGINX to access protected backend
57+
#proxy_set_header Authorization "Bearer $access_token";
58+
59+
# Intercept and redirect "401 Unauthorized" proxied responses to nginx
60+
# for processing with the error_page directive. Necessary if Access Token
61+
# can expire before ID Token.
62+
#proxy_intercept_errors on;
63+
64+
proxy_pass http://cafe_nginx; # The backend site/app
65+
add_header X-Proxy-Pass cafe_nginx_oidc; # Custom Header
66+
67+
access_log /var/log/nginx/access.log main_jwt;
68+
69+
}
70+
}

labs/lab8/media/App_Registration.png

119 KB
Loading
238 KB
Loading
156 KB
Loading
130 KB
Loading
189 KB
Loading
130 KB
Loading

labs/lab8/media/cafe-icon.png

134 KB
Loading

labs/lab8/media/curl_output.png

69 KB
Loading

labs/lab8/media/endpoints.png

241 KB
Loading

0 commit comments

Comments
 (0)