Skip to content

Commit 35e0953

Browse files
Merge branch 'feature/rs256-key-file' of github.com:penumbra23/ngx-http-auth-jwt-module into feature/rs256-key-file
2 parents 97f0dd4 + 83f839f commit 35e0953

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,13 @@ auth_jwt_loginurl "https://yourdomain.com/loginpage";
4545
auth_jwt_enabled on;
4646
auth_jwt_algorithm HS256; # or RS256
4747
auth_jwt_validate_email on; # or off
48+
auth_jwt_use_keyfile off; # or on
49+
auth_jwt_keyfile_path "/app/pub_key";
4850
```
4951

5052
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.
5153

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 (which defaults to `"/app/pub_key"`).
5355
That is the public key, rather than a PEM certificate. I.e.:
5456

5557
```
@@ -64,6 +66,13 @@ oQIDAQAB
6466
-----END PUBLIC KEY-----";
6567
```
6668

69+
**OR**
70+
71+
```
72+
auth_jwt_use_keyfile on;
73+
auth_jwt_keyfile_path "/etc/nginx/pub_key.pem";
74+
```
75+
6776
A typical use would be to specify the key and loginurl on the main level
6877
and then only turn on the locations that you want to secure (not the login page).
6978
Unauthorized requests are given 302 "Moved Temporarily" responses with a ___location of the specified loginurl.

src/ngx_http_auth_jwt_module.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ typedef struct {
2929
ngx_flag_t auth_jwt_redirect;
3030
ngx_str_t auth_jwt_validation_type;
3131
ngx_str_t auth_jwt_algorithm;
32-
ngx_flag_t auth_jwt_use_keyfile;
33-
ngx_str_t auth_jwt_keyfile_path;
32+
ngx_flag_t auth_jwt_use_keyfile;
33+
ngx_str_t auth_jwt_keyfile_path;
3434
ngx_flag_t auth_jwt_validate_email;
3535

3636
} ngx_http_auth_jwt_loc_conf_t;

0 commit comments

Comments
 (0)