Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ bind(

new_git_repository(
name = "googleapis_git",
commit = "6c1d6d4067364a21f8ffefa3401b213d652bf121",
commit = "db1d4547dc56a798915e0eb2c795585385922165",
remote = "https://github.com/googleapis/googleapis.git",
build_file = "third_party/BUILD.googleapis",
)
Expand Down
13 changes: 8 additions & 5 deletions contrib/endpoints/src/api_manager/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ bool Config::LoadRpcMethods(ApiManagerEnvInterface *env,
bool Config::LoadAuthentication(ApiManagerEnvInterface *env) {
// Parsing auth config.
const ::google::api::Authentication &auth = service_.authentication();
map<string, string> provider_id_issuer_map;
map<string, ::google::api::AuthProvider> provider_id_provider_map;
for (const auto &provider : auth.providers()) {
if (provider.id().empty()) {
env->LogError("Missing id field in AuthProvider.");
Expand All @@ -274,7 +274,7 @@ bool Config::LoadAuthentication(ApiManagerEnvInterface *env) {
} else {
SetJwksUri(provider.issuer(), string(), true);
}
provider_id_issuer_map[provider.id()] = provider.issuer();
provider_id_provider_map[provider.id()] = provider;
}

for (const auto &rule : auth.rules()) {
Expand All @@ -296,12 +296,15 @@ bool Config::LoadAuthentication(ApiManagerEnvInterface *env) {
env->LogError(error.c_str());
continue;
}
auto issuer = utils::FindOrNull(provider_id_issuer_map, provider_id);
if (issuer == nullptr) {
auto provider = utils::FindOrNull(provider_id_provider_map, provider_id);
if (provider == nullptr) {
std::string error = "Undefined provider_id: " + provider_id;
env->LogError(error.c_str());
} else {
(*method)->addAudiencesForIssuer(*issuer, requirement.audiences());
std::string audiences = provider->audiences().empty()
? requirement.audiences()
: provider->audiences();
(*method)->addAudiencesForIssuer(provider->issuer(), audiences);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion contrib/endpoints/src/api_manager/config_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ static const char auth_config[] =
" id: \"provider-id1\"\n"
" issuer: \"issuer1@gserviceaccount.com\"\n"
" jwks_uri: \"https://www.googleapis.com/jwks_uri1\"\n"
" audiences: \"ok_audience1\"\n"
" }\n"
" providers {\n"
" id: \"provider-id2\"\n"
Expand All @@ -326,7 +327,6 @@ static const char auth_config[] =
" selector: \"Xyz.Method1\"\n"
" requirements {\n"
" provider_id: \"provider-id1\"\n"
" audiences: \"ok_audience1\"\n"
" }\n"
" }\n"
" rules {\n"
Expand Down