Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. events {
  2. worker_connections 1024;
  3. }
  4.  
  5. http {
  6.  
  7. lua_package_path "/usr/local/openresty/?.lua;;";
  8.  
  9. resolver 192.168.20.1;
  10.  
  11. lua_ssl_trusted_certificate /etc/ssl/certs/ca-certificates.crt;
  12. lua_ssl_verify_depth 5;
  13.  
  14. # cache for discovery metadata documents
  15. lua_shared_dict discovery 1m;
  16. # cache for JWKs
  17. lua_shared_dict jwks 1m;
  18.  
  19. server {
  20. listen 80 default_server;
  21. server_name _;
  22. return 301 https://$host$request_uri;
  23. }
  24. server {
  25. listen 443 ssl;
  26.  
  27. ssl_certificate /usr/local/openresty/nginx/ssl/nginx.crt;
  28. ssl_certificate_key /usr/local/openresty/nginx/ssl/nginx.key;
  29.  
  30. location / {
  31.  
  32. access_by_lua_block {
  33.  
  34. local opts = {
  35. redirect_uri_path = "/welcome",
  36. discovery = "https://portal.example.com/.well-known/openid-configuration",
  37. client_id = "@!1234.1234.1234.1234!1234!1234.1234!1234!1234.1234.1234.1234",
  38. client_secret = "SECRETPASSWORD",
  39. ssl_verify = "no",
  40. scope = "openid email profile",
  41. redirect_uri_scheme = "https",
  42. }
  43.  
  44. -- call authenticate for OpenID Connect user authentication
  45. local res, err = require("resty.openidc").authenticate(opts)
  46.  
  47. if err then
  48. ngx.status = 500
  49. ngx.say(err)
  50. ngx.exit(ngx.HTTP_INTERNAL_SERVER_ERROR)
  51. end
  52.  
  53. ngx.req.set_header("X-USER", res.id_token.sub)
  54. }
  55. }
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement