Skip to content

Commit 621211d

Browse files
authored
remove authorizationUrl redirect (#824)
Signed-off-by: Wayne Zhang <[email protected]>
1 parent aa75c21 commit 621211d

File tree

3 files changed

+0
-174
lines changed

3 files changed

+0
-174
lines changed

src/nginx/error.cc

-43
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,9 @@ ngx_str_t application_grpc = ngx_string("application/grpc");
4747

4848
ngx_str_t www_authenticate = ngx_string("WWW-Authenticate");
4949
const u_char www_authenticate_lowcase[] = "www-authenticate";
50-
ngx_str_t kLocation = ngx_string("Location");
51-
const u_char kLocationLowcase[] = "location";
5250
ngx_str_t missing_credential = ngx_string("Bearer");
5351
ngx_str_t invalid_token = ngx_string("Bearer, error=\"invalid_token\"");
5452

55-
const char *kInvalidAuthToken =
56-
"JWT validation failed: Missing or invalid credentials";
57-
const char *kExpiredAuthToken =
58-
"JWT validation failed: TIME_CONSTRAINT_FAILURE";
59-
6053
ngx_http_output_header_filter_pt ngx_http_next_header_filter;
6154
ngx_http_output_body_filter_pt ngx_http_next_body_filter;
6255

@@ -109,39 +102,6 @@ ngx_int_t ngx_esp_handle_www_authenticate(ngx_http_request_t *r,
109102
return NGX_OK;
110103
}
111104

112-
// If authentication fails, and authorization url is not empty,
113-
// Reply 302 and authorization url.
114-
ngx_int_t ngx_esp_handle_authorization_url(ngx_http_request_t *r,
115-
ngx_esp_request_ctx_t *ctx) {
116-
if (ctx && ctx->status.code() == Code::UNAUTHENTICATED &&
117-
ctx->status.error_cause() == utils::Status::AUTH &&
118-
(ctx->status.message() == kInvalidAuthToken ||
119-
ctx->status.message() == kExpiredAuthToken)) {
120-
std::string url = ctx->request_handler->GetAuthorizationUrl();
121-
if (!url.empty()) {
122-
r->headers_out.status = NGX_HTTP_MOVED_TEMPORARILY;
123-
124-
ngx_table_elt_t *loc;
125-
loc = reinterpret_cast<ngx_table_elt_t *>(
126-
ngx_list_push(&r->headers_out.headers));
127-
if (loc == nullptr) {
128-
return NGX_ERROR;
129-
}
130-
131-
loc->key = kLocation;
132-
loc->lowcase_key = const_cast<u_char *>(kLocationLowcase);
133-
loc->hash = ngx_hash_key(const_cast<u_char *>(kLocationLowcase),
134-
sizeof(kLocationLowcase) - 1);
135-
136-
ngx_str_copy_from_std(r->pool, url, &loc->value);
137-
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
138-
"ESP authorization_url: %V", &loc->value);
139-
r->headers_out.location = loc;
140-
}
141-
}
142-
return NGX_OK;
143-
}
144-
145105
ngx_int_t ngx_esp_error_header_filter(ngx_http_request_t *r) {
146106
ngx_esp_request_ctx_t *ctx = reinterpret_cast<ngx_esp_request_ctx_t *>(
147107
ngx_http_get_module_ctx(r, ngx_esp_module));
@@ -170,9 +130,6 @@ ngx_int_t ngx_esp_error_header_filter(ngx_http_request_t *r) {
170130
ngx_int_t ret;
171131
ret = ngx_esp_handle_www_authenticate(r, ctx);
172132
if (ret != NGX_OK) return ret;
173-
174-
ret = ngx_esp_handle_authorization_url(r, ctx);
175-
if (ret != NGX_OK) return ret;
176133
}
177134

178135
// Clear headers (refilled by subsequent NGX header filters)

src/nginx/t/BUILD

-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ nginx_suite(
5757
"auth_ok_check_fail.t",
5858
"auth_pass_user_info.t",
5959
"auth_pkey_cache.t",
60-
"auth_redirect.t",
6160
"auth_remove_user_info.t",
6261
"auth_unreachable_pkey.t",
6362
"new_http.t",

src/nginx/t/auth_redirect.t

-130
This file was deleted.

0 commit comments

Comments
 (0)