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
The default algorithm is 'HS256', for symmetric key validation. When using HS256, the value for `auth_jwt_key` should be specified in binhex format. It is recommended to use at least 256 bits of data (32 pairs of hex characters or 64 characters in total) as in the example above. Note that using more than 512 bits will not increase the security. For key guidelines please see NIST Special Publication 800-107 Recommendation for Applications Using Approved Hash Algorithms, Section 5.3.2 The HMAC Key.
51
53
52
-
The configuration also supports the `auth_jwt_algorithm` 'RS256', for RSA 256-bit public key validation. If using "auth_jwt_algorithm RS256;", then the `auth_jwt_key` field must be set to your public key.
54
+
The configuration also supports the `auth_jwt_algorithm` 'RS256', for RSA 256-bit public key validation. If using "auth_jwt_algorithm RS256;", then the `auth_jwt_key` field must be set to your public key**OR**`auth_jwt_use_keyfile` should be set to `on` with the `auth_jwt_keyfile_path` set to the public key path (nginx won't start if the `auth_jwt_use_keyfile` is set to `on` without a keyfile).
53
55
That is the public key, rather than a PEM certificate. I.e.:
54
56
55
57
```
@@ -64,6 +66,13 @@ oQIDAQAB
64
66
-----END PUBLIC KEY-----";
65
67
```
66
68
69
+
**OR**
70
+
71
+
```
72
+
auth_jwt_use_keyfile on;
73
+
auth_jwt_keyfile_path "/etc/nginx/pub_key.pem";
74
+
```
75
+
67
76
A typical use would be to specify the key and loginurl on the main level
68
77
and then only turn on the locations that you want to secure (not the login page).
69
78
Unauthorized requests are given 302 "Moved Temporarily" responses with a ___location of the specified loginurl.
Copy file name to clipboardExpand all lines: test.sh
+5Lines changed: 5 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -25,6 +25,7 @@ main() {
25
25
local MISSING_SUB_JWT=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmaXJzdE5hbWUiOiJoZWxsbyIsImxhc3ROYW1lIjoid29ybGQiLCJlbWFpbEFkZHJlc3MiOiJoZWxsb3dvcmxkQGV4YW1wbGUuY29tIiwicm9sZXMi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75XL-r7TMsPuqzWoKZ06ZsyF_VZIG0Ohn8uZZFeF8dFUhSrEOYe8WFN6Eon8a8LC0OCI9eNdGiD4m_e9TD1Iz2juqaeos-6yd7SWuODr4YS8KD3cqfXndnLRPzp9PC_UIpATsbqOmxGDrRKvHsQq0TuIXImU3rM_m3kFJFgtoJFHx3KmZUo_Ozkyhhc6Pukikhy6odNAtEyLHP5_tabMXtkeAuIlG8dhjAxef4mJLexYFclG-vl7No5VBU4JrMbfgyxtobcYoE-bDIpmQHywrwo6Li7X0hgHJ17sfS3G2YMHmE-Ij_W2Lf9kf5r2r12DUvg44SLIfM58pCINQ
28
+
local INVALID_RSA256_JWT=eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJzb21lLWxvbmctdXVpZCIsImZpcnN0TmFtZSI6ImhlbGxvIiwibGFzdE5hbWUiOiJ3b3JsZCIsImVtYWlsQWRkcmVzcyI6ImhlbGxvd29ybGRAZXhhbXBsZS5jb20iLCJyb2xlcyI6WyJ0aGlzIiwidGhhdCIsInRoZW90aGVyIl0sImlzcyI6Imlzc3VlciIsInBlcnNvbklkIjoiNzViYjNjYzctYjkzMy00NGYwLTkzYzYtMTQ3YjA4MmZhZGI1IiwiZXhwIjoxOTA4ODM1MjAwLCJpYXQiOjE0ODg4MTk2MDAsInVzZXJuYW1lIjoiaGVsbG8ud29ybGQifQ._aQmIBL4CVBxU1fNMOHp0kkagFaaX2TvAEenizytwd0
28
29
29
30
test_jwt "Insecure test""/""200"
30
31
@@ -45,6 +46,10 @@ main() {
45
46
test_jwt "Secure test with jwt cookie - with no email""/secure/""200"" --cookie \"rampartjwt=${MISSING_EMAIL_JWT}\""
46
47
47
48
test_jwt "Secure test with rs256 jwt cookie""/secure-rs256/""200"" --cookie \"rampartjwt=${VALID_RS256_JWT}\""
49
+
50
+
test_jwt "Secure test rsa256 from file with valid jwt""/secure-rs256-file/""200""--header \"Authorization: Bearer ${VALID_RS256_JWT}\""
51
+
52
+
test_jwt "Secure test rsa256 from file with invalid jwt""/secure-rs256-file/""401""--header \"Authorization: Bearer ${INVALID_RSA256_JWT}\""
0 commit comments