Skip to content

Commit 0e01b36

Browse files
committed
clean up
1 parent 8c77e17 commit 0e01b36

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/ngx_http_auth_jwt_module.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,11 @@ ngx_module_t ngx_http_auth_jwt_module = {
8585

8686
static ngx_int_t ngx_http_auth_jwt_handler(ngx_http_request_t *r)
8787
{
88+
static const ngx_str_t jwtCookieName = ngx_string("rampartjwt");
89+
static const ngx_str_t passportKeyCookieName = ngx_string("PassportKey");
90+
static const ngx_str_t authorizationHeaderName = ngx_string("Authorization");
91+
static const int BEARER_LEN = 7; // strlen("Bearer ");
8892
ngx_int_t n;
89-
ngx_str_t jwtCookieName = ngx_string("rampartjwt");
90-
ngx_str_t passportKeyCookieName = ngx_string("PassportKey");
9193
ngx_str_t jwtCookieVal;
9294
char* jwtCookieValChrPtr;
9395
char* return_url;
@@ -98,7 +100,7 @@ static ngx_int_t ngx_http_auth_jwt_handler(ngx_http_request_t *r)
98100
jwt_alg_t alg;
99101
time_t exp;
100102
time_t now;
101-
int BEARER_LEN = 7; // strlen("Bearer ");
103+
ngx_table_elt_t *authorizationHeader;
102104

103105
jwtcf = ngx_http_get_module_loc_conf(r, ngx_http_auth_jwt_module);
104106

@@ -167,8 +169,6 @@ static ngx_int_t ngx_http_auth_jwt_handler(ngx_http_request_t *r)
167169
}
168170

169171
// if an Authorization header exists, it must match the cookie
170-
ngx_table_elt_t *authorizationHeader;
171-
ngx_str_t authorizationHeaderName = ngx_string("Authorization");
172172
authorizationHeader = search_headers_in(r, authorizationHeaderName.data, authorizationHeaderName.len);
173173
if (authorizationHeader != NULL)
174174
{
@@ -179,14 +179,12 @@ static ngx_int_t ngx_http_auth_jwt_handler(ngx_http_request_t *r)
179179
goto redirect;
180180
}
181181

182+
// compare content
182183
if (0 != strncmp((const char *)(authorizationHeader->value.data + BEARER_LEN), (const char *)jwtCookieVal.data, jwtCookieVal.len))
183184
{
184185
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "Authorization and Cookie do not match content");
185186
goto redirect;
186187
}
187-
188-
char* authvalue = ngx_str_t_to_char_ptr(r->pool, authorizationHeader->value);
189-
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "authorization header %s", authvalue);
190188
}
191189

192190
return NGX_OK;

0 commit comments

Comments
 (0)