Skip to content
14 changes: 0 additions & 14 deletions .idea/misc.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

13 changes: 0 additions & 13 deletions .idea/proxy.iml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

354 changes: 0 additions & 354 deletions .idea/workspace.xml

This file was deleted.

15 changes: 12 additions & 3 deletions contrib/endpoints/src/api_manager/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -514,11 +514,20 @@ void Config::SetJwksUri(const string &issuer, const string &jwks_uri,
}

std::string Config::GetFirebaseServer() {
if (server_config_ == nullptr) {
return "";
if (server_config_ != nullptr && server_config_->has_api_check_security_rules_config() &&
server_config_->api_check_security_rules_config().has_firebase_server()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check for !empty()? The has check is not sufficient.

// It is the testing environment, use server config.
return server_config_->api_check_security_rules_config().firebase_server();
}

return server_config_->api_check_security_rules_config().firebase_server();
if (service_.has_experimental() &&
service_.experimental().has_authorization() &&
service_.experimental().authorization().has_provider()) {
// In real environment, server_config_ should be null. And we rely on the
// field in service.
return service_.experimental().authorization().provider();
}
return "";
}

} // namespace api_manager
Expand Down
4 changes: 1 addition & 3 deletions contrib/endpoints/src/api_manager/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ class Config {
// TODO: Remove in favor of service().
const std::string &service_name() const { return service_.name(); }

bool HasAuth() const { return service_.has_experimental() &&
service_.experimental().has_authorization() &&
service_.experimental().authorization().has_provider(); }
bool HasAuth() const { return service_.has_authentication(); }

// Returns true if the caller should try openId discovery to fetch jwksUri.
// url is set to the openId discovery link in this case. Returns false
Expand Down
5 changes: 1 addition & 4 deletions contrib/endpoints/src/api_manager/context/service_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,7 @@ class ServiceContext {

bool IsRulesCheckEnabled() const {
return RequireAuth() && service().apis_size() > 0 &&
(!config_->GetFirebaseServer().empty() ||
(service().has_experimental() &&
service().experimental().has_authorization() &&
service().experimental().authorization().has_provider()));
!config_->GetFirebaseServer().empty();
}

auth::Certs &certs() { return certs_; }
Expand Down