Skip to content

Commit

Permalink
Fail request if api_key is not valid. (envoyproxy#116)
Browse files Browse the repository at this point in the history
* Fail request if api_key is not valid.

* Format code.

* Update comments.

* Address comment.
  • Loading branch information
chowchow316 committed Feb 22, 2017
1 parent ef1aecf commit 20e19d2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions contrib/endpoints/src/api_manager/service_control/aggregated.cc
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,14 @@ void Aggregated::Check(
if (status.ok()) {
Status status = Proto::ConvertCheckResponse(
*response, service_control_proto_.service_name(), &response_info);
// If allow_unregistered_calls is true, it is always OK to proceed.
if (allow_unregistered_calls) {
// If server replied with either invalid api_key or not activated service,
// the request is rejected even allow_unregistered_calls is true. Most
// likely, users provide a wrong api key. By failing the request, the
// users will be notified with the error and have chance to correct it.
// Otherwise, the Report call will fail. It is very hard to notice and
// debug the Report failure.
if (allow_unregistered_calls && response_info.is_api_key_valid &&
response_info.service_is_activated) {
on_done(Status::OK, response_info);
} else {
on_done(status, response_info);
Expand Down

0 comments on commit 20e19d2

Please sign in to comment.