Skip to content

Commit ed4f416

Browse files
move email variables into block where they are used
1 parent 2fdd613 commit ed4f416

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,5 @@ auth_jwt_validate_email off;
100100
```
101101
By default, the module will attempt to validate the email address field of the JWT, then set the x-email header of the
102102
session, and will log an error if it isn't found. To disable this behavior, for instance if you are using a different
103-
user identifier property such as 'sub', set `auth_jwt_validate_email` to the value `off`.
103+
user identifier property such as `sub`, set `auth_jwt_validate_email` to the value `off`. _Note that this flag may be
104+
renamed to `auth_jwt_extract_email` in a future release._

src/ngx_http_auth_jwt_module.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,6 @@ static ngx_int_t ngx_http_auth_jwt_handler(ngx_http_request_t *r)
160160
jwt_t *jwt = NULL;
161161
int jwtParseReturnCode;
162162
jwt_alg_t alg;
163-
const char* email;
164-
ngx_str_t email_t;
165163
time_t exp;
166164
time_t now;
167165
ngx_str_t auth_jwt_algorithm;
@@ -266,14 +264,16 @@ static ngx_int_t ngx_http_auth_jwt_handler(ngx_http_request_t *r)
266264

267265
if (jwtcf->auth_jwt_validate_email == 1)
268266
{
269-
email = jwt_get_grant(jwt, "emailAddress");
267+
const char* email = jwt_get_grant(jwt, "emailAddress");
268+
270269
if (email == NULL)
271270
{
272271
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "the jwt does not contain an email address");
273272
}
274273
else
275274
{
276-
email_t = ngx_char_ptr_to_str_t(r->pool, (char *)email);
275+
ngx_str_t email_t = ngx_char_ptr_to_str_t(r->pool, (char *)email);
276+
277277
set_custom_header_in_headers_out(r, &emailHeaderName, &email_t);
278278
}
279279
}

0 commit comments

Comments
 (0)