File tree Expand file tree Collapse file tree 3 files changed +38
-1
lines changed Expand file tree Collapse file tree 3 files changed +38
-1
lines changed Original file line number Diff line number Diff line change
1
+ {% if openidc_enabled -%}
2
+ access_by_lua_block {
3
+ local openidc = require("resty.openidc")
4
+ local opts = {
5
+ redirect_uri = "{{- openidc_redirect_uri -}}",
6
+ discovery = "{{- openidc_discovery -}}",
7
+ token_endpoint_auth_method = "{{- openidc_auth_method -}}",
8
+ client_id = "{{- openidc_client_id -}}",
9
+ client_secret = "{{- openidc_client_secret -}}",
10
+ scope = "openid email profile"
11
+ }
12
+
13
+ local res, err = openidc.authenticate(opts)
14
+
15
+ if err then
16
+ ngx.status = 500
17
+ ngx.say(err)
18
+ ngx.exit(ngx.HTTP_INTERNAL_SERVER_ERROR)
19
+ end
20
+
21
+
22
+ ngx.req.set_header("X-OIDC-SUB", res.id_token.sub)
23
+ ngx.req.set_header("X-OIDC-EMAIL", res.id_token.email)
24
+ ngx.req.set_header("X-OIDC-NAME", res.id_token.name)
25
+ }
26
+ {% endif %}
Original file line number Diff line number Diff line change @@ -51,7 +51,8 @@ proxy_http_version 1.1;
51
51
52
52
{% endif %}
53
53
54
- {% include "_hsts.conf" %}
54
+ {% include "_openid_connect.conf" %}
55
+ {% include "_hsts.conf" %}
55
56
56
57
{% if allow_websocket_upgrade == 1 or allow_websocket_upgrade == true %}
57
58
proxy_set_header Upgrade $http_upgrade;
Original file line number Diff line number Diff line change @@ -43,6 +43,16 @@ http {
43
43
proxy_cache_path /var/lib/nginx/cache/public levels=1:2 keys_zone=public-cache:30m max_size=192m;
44
44
proxy_cache_path /var/lib/nginx/cache/private levels=1:2 keys_zone=private-cache:5m max_size=1024m;
45
45
46
+ lua_package_path '~/lua/?.lua;;' ;
47
+
48
+ lua_ssl_trusted_certificate /etc/ssl/certs/ca-certificates.crt;
49
+ lua_ssl_verify_depth 5;
50
+
51
+ # cache for discovery metadata documents
52
+ lua_shared_dict discovery 1m ;
53
+ # cache for JWKs
54
+ lua_shared_dict jwks 1m ;
55
+
46
56
log_format proxy '[$time_local ] $upstream_cache_status $upstream_status $status - $request_method $scheme $host "$request_uri " [Client $remote_addr ] [Length $body_bytes_sent ] [Gzip $gzip_ratio ] [Sent-to $server ] "$http_user_agent " "$http_referer "' ;
47
57
log_format standard '[$time_local ] $status - $request_method $scheme $host "$request_uri " [Client $remote_addr ] [Length $body_bytes_sent ] [Gzip $gzip_ratio ] "$http_user_agent " "$http_referer "' ;
48
58
You can’t perform that action at this time.
0 commit comments