@@ -47,16 +47,9 @@ ngx_str_t application_grpc = ngx_string("application/grpc");
47
47
48
48
ngx_str_t www_authenticate = ngx_string(" WWW-Authenticate" );
49
49
const u_char www_authenticate_lowcase[] = " www-authenticate" ;
50
- ngx_str_t kLocation = ngx_string(" Location" );
51
- const u_char kLocationLowcase [] = " location" ;
52
50
ngx_str_t missing_credential = ngx_string(" Bearer" );
53
51
ngx_str_t invalid_token = ngx_string(" Bearer, error=\" invalid_token\" " );
54
52
55
- const char *kInvalidAuthToken =
56
- " JWT validation failed: Missing or invalid credentials" ;
57
- const char *kExpiredAuthToken =
58
- " JWT validation failed: TIME_CONSTRAINT_FAILURE" ;
59
-
60
53
ngx_http_output_header_filter_pt ngx_http_next_header_filter;
61
54
ngx_http_output_body_filter_pt ngx_http_next_body_filter;
62
55
@@ -109,39 +102,6 @@ ngx_int_t ngx_esp_handle_www_authenticate(ngx_http_request_t *r,
109
102
return NGX_OK;
110
103
}
111
104
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
-
145
105
ngx_int_t ngx_esp_error_header_filter (ngx_http_request_t *r) {
146
106
ngx_esp_request_ctx_t *ctx = reinterpret_cast <ngx_esp_request_ctx_t *>(
147
107
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) {
170
130
ngx_int_t ret;
171
131
ret = ngx_esp_handle_www_authenticate (r, ctx);
172
132
if (ret != NGX_OK) return ret;
173
-
174
- ret = ngx_esp_handle_authorization_url (r, ctx);
175
- if (ret != NGX_OK) return ret;
176
133
}
177
134
178
135
// Clear headers (refilled by subsequent NGX header filters)
0 commit comments