You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`sudo install.sh luaoauth`| Installs jwtverify.lua and its dependencies to **/usr/local/share/lua/5.3/jwtverify.lua**|
28
-
|`sudo install.sh haproxy`| Installs HAProxy |
29
-
|`sudo install.sh all`| Installs HAProxy and jwtverify.lua and its dependencies |
30
-
31
-
## Sample
32
-
33
-
A sample application can be found at https://github.com/haproxytechblog/haproxy-jwt-vagrant.
23
+
This installs jwtverify.lua and its dependencies to **/usr/local/share/lua/5.3/jwtverify.lua**.
34
24
35
25
## Usage
36
26
@@ -72,3 +62,47 @@ After calling `http-request lua.jwtverify`, you get access to variables for each
72
62
*`var(txn.oauth.scope)`
73
63
74
64
For example, you could track rate limiting based on the clientId or set different rate limit thresholds based on the scope.
65
+
66
+
## Example
67
+
68
+
Try it out using the Docker Compose.
69
+
70
+
1. Sign up for a free account at https://auth0.com/ and create a new API.
71
+
1. Give the API any name, such as "My OAuth Test" and set the identifier to "https://api.mywebsite.com".
72
+
1. Once created, go to the API's "Permissions" tab and add permissions (aka scopes) that grant users different levels of access. The colon syntax is just a personal style, and colons do not mean anything special.
73
+
74
+
| permission | description |
75
+
|-------------|-----------------------|
76
+
| read:myapp| Read access to my app |
77
+
| write:myapp| Write access to myapp |
78
+
79
+
1. Now that you have an API defined in Auth0, add an application that is allowed to authenticate to it. Go to the "Applications" tab and add a new "Machine to Machine Application" and select the API you just created. Give it the "read:myapp" and "write:myapp"permissions (or only one or the other).
80
+
1. On the Settings page for the new application, go to **Advanced Settings > Certificates** and download the certificate in PEM format. HAProxy will validate the access tokens against this certificate, which was signed by the OAuth provider, Auth0.
81
+
82
+
1. Convert it first using `openssl x509 -pubkey -noout -in ./mycert.pem > pubkey.pem` and save **pubkey.pem** to **/example/haproxy/pem/pubkey.pem**.
83
+
1. Edit **example/haproxy/haproxy.cfg**:
84
+
85
+
* replace the `OAUTH_ISSUER` variable in the global section with the Auth0 domain URL with your own, such as https://myaccount.auth0.com/.
86
+
* replace the `OAUTH_AUDIENCE` variable with your API name in Auth0, such as "https://api.mywebsite.com".
87
+
* replace the `OAUTH_PUBKEY_PATH` variable with the path to your PEM certificate. (also update the docker-compose file)
0 commit comments