Skip to content

Commit 31b489f

Browse files
authored
Merge firebase to master (envoyproxy#258)
* Created check security rules file and a few dummy/helper functions. (envoyproxy#40) * Created check security rules file and a few dummy/helper functions. And added it to check work flow. * Fix format. * Firebase: Merge from master. (envoyproxy#53) * Simple TCP server to show how to retrieve original dest IP:port after an iptables redirect (envoyproxy#38) * Simple TCP server to show how to retrieve original dest IP:port after an iptables redirect * Fixed style. * Rebase Envoy (envoyproxy#41) * Update prototype to use iptables (envoyproxy#42) * Rebase to fixed Envoy (envoyproxy#43) * Handle HEAD request. (envoyproxy#34) * Handle HEAD request. * Try with GET if HEAD fails. * Address comments. * Format file. * Expose bazel target (envoyproxy#48) * Try again (envoyproxy#49) * Enable ESP to invoke Firebase Security rules. (envoyproxy#54) * Enable ESP to invoke Firebase Security rules. * Address code review comments. * Remove some debug logs * Add proto file to capture TestRulesetRequest. * clang-format files * Resolve a merge issue with previous commit * Allow security rules to disabled via serverconfig * format file * Addressed Wayne's review comments. * Add firebase server to Server Config. * Address Lizan's review comments * Address review comments. * Disable check rules service by default. * Address more review comments. * Fix a check. * Delete unwanted constant. * Address Wayne's comments and add a simple config test. * Address a review comment. * Add negative test case for config * Address code review * Remove unwanted const std::string * Merge from master into firebase (envoyproxy#65) * Simple TCP server to show how to retrieve original dest IP:port after an iptables redirect (envoyproxy#38) * Simple TCP server to show how to retrieve original dest IP:port after an iptables redirect * Fixed style. * Rebase Envoy (envoyproxy#41) * Update prototype to use iptables (envoyproxy#42) * Rebase to fixed Envoy (envoyproxy#43) * Handle HEAD request. (envoyproxy#34) * Handle HEAD request. * Try with GET if HEAD fails. * Address comments. * Format file. * Expose bazel target (envoyproxy#48) * Try again (envoyproxy#49) * Integrate with mixer client. (envoyproxy#55) * Integrate with mixer client. * Restore repositories.bzl back. * Add originIp and originHost attributes. (envoyproxy#56) * Add uuid-dev dependency in README.md (envoyproxy#45) * Extract originIp and OriginHost. (envoyproxy#57) * Extract originIp and OriginHost. * Make header x-forwarded-host const. * Update buckets for UI. (envoyproxy#58) * Update buckets for UI. * Only update time_distribution. * Add targetService attribute. (envoyproxy#59) * Use envoy new access_log handler for sending Report. (envoyproxy#60) * use access_log handler. * Not to use Loggable base class. * Update to the latest envoy with envoyproxy#396. (envoyproxy#61) * Fix tclap dependency fetching error (envoyproxy#62) * Update the auth checke to use service.experimental.authorization.providerwq! * Update the auth check to use service.experimental.authorization.provider * Update the auth check to use service.experimental.authorization.provider (envoyproxy#67) * Update the auth check to use service.experimental.authorization.provider * Address comments and revert accidental change. * Remove unnecessary added accidentally. * Another patch * fix the logic * fix lint * Fix broken test and add unit tests * Fix comments * Fix style check * revert style for raw string * fix small lint * fix small lint * fix small lint * Unit tests for check security rules. (envoyproxy#75) * Unit tests for check security rules. * format * Address review comments. * Fix typos * Merge from master to firebase (envoyproxy#143) * Simple TCP server to show how to retrieve original dest IP:port after an iptables redirect (envoyproxy#38) * Simple TCP server to show how to retrieve original dest IP:port after an iptables redirect * Fixed style. * Rebase Envoy (envoyproxy#41) * Update prototype to use iptables (envoyproxy#42) * Rebase to fixed Envoy (envoyproxy#43) * Handle HEAD request. (envoyproxy#34) * Handle HEAD request. * Try with GET if HEAD fails. * Address comments. * Format file. * Expose bazel target (envoyproxy#48) * Try again (envoyproxy#49) * Integrate with mixer client. (envoyproxy#55) * Integrate with mixer client. * Restore repositories.bzl back. * Add originIp and originHost attributes. (envoyproxy#56) * Add uuid-dev dependency in README.md (envoyproxy#45) * Extract originIp and OriginHost. (envoyproxy#57) * Extract originIp and OriginHost. * Make header x-forwarded-host const. * Update buckets for UI. (envoyproxy#58) * Update buckets for UI. * Only update time_distribution. * Add targetService attribute. (envoyproxy#59) * Use envoy new access_log handler for sending Report. (envoyproxy#60) * use access_log handler. * Not to use Loggable base class. * Update to the latest envoy with envoyproxy#396. (envoyproxy#61) * Fix tclap dependency fetching error (envoyproxy#62) * Integrate mixer client directly with envoy. (envoyproxy#66) * Integrate mixer client directly with envoy. * Send response header in Report. * rename filter name from esp to mixer. * add README. * Add release binary script. (envoyproxy#68) * Push tar.gz to GCS (envoyproxy#69) * Push tar.gz to GCS * Rename envoy_esp * Remove mixer_client from api_manager. (envoyproxy#72) * Update mixer client SHA. (envoyproxy#74) * Update readme. (envoyproxy#73) * Adds Jenkinsfile and updates release-binary to create a SHA. (envoyproxy#71) * Adds Jenkinsfile and update release-binary * Update Jenkinsfile and gitignore * Fixes typo and use normal build Node * Uses default bazel config * Using batch mode * Update bazel memory settings * Do not use Jenkins bazel env * Set .bazelrc for postsubmit * Update grpc and protobuf (envoyproxy#70) * protobuf v3.2.0 * grpc v1.1.1 * Align auth lib with grpc 1.1.1 * Add sourceService. (envoyproxy#78) * Add script to build docker image. (envoyproxy#77) * Add script to build docker image. * Add start_envoy for docker image. * Use official attribute names (envoyproxy#80) * Use official attribute names * fix format * Creates a KEY for mixer client dep. Updates release-binary (envoyproxy#79) * Updated mixer repo to use a key for commit * release-binary skip build if file exists. * Update src/envoy/mixer/README. (envoyproxy#82) * Fix src/envoy/mixer/README.md (envoyproxy#85) * Get attributes from envoy config. (envoyproxy#87) * Send all attributes. * Remove unused const strings. * Address comment. * updated SHA to point to newer envoy with RDS API feature (envoyproxy#94) * Disable travis on stable branches (envoyproxy#96) * Publish debug binaries (no release yet) (envoyproxy#98) * Copies the binary instead of linking for release (envoyproxy#102) * Not to use api_key if its service is not actived. (envoyproxy#109) * Update envoy and add c-ares (envoyproxy#107) * Update envoy and add c-ares depedencies * Update release script with debug and normal binary * remove debug ls * formatting * Send StatusCode Attributes to Mixer. (envoyproxy#110) * Add send_attribute filter. (envoyproxy#115) * Add send_attribute filter. * Fix format * rename variable serialized_attributes_ * Address the comments. * Fail request if api_key is not valid. (envoyproxy#116) * Fail request if api_key is not valid. * Format code. * Update comments. * Address comment. * Rename response.http.code (envoyproxy#125) * Send headers as string map. (envoyproxy#129) * Send headers as string map. * Remove origin.ip and origin.host. * Fix format * unify bazel's docker build targets with other istio repos (envoyproxy#127) * update base debug docker image reference (envoyproxy#133) * Update postsubmit to create docker images (envoyproxy#132) * Adding config release for bazel build (envoyproxy#135) * Fix mixer client crash. (envoyproxy#136) * Get mixerclient with response parsing. (envoyproxy#138) * Update nghttp2 to sync with envoy (envoyproxy#140) * Fix src/envoy/mixer/README.md * Update nghttp2 to sync with envoy * update * fix typo * Merge from master to firebase (envoyproxy#159) * Simple TCP server to show how to retrieve original dest IP:port after an iptables redirect (envoyproxy#38) * Simple TCP server to show how to retrieve original dest IP:port after an iptables redirect * Fixed style. * Rebase Envoy (envoyproxy#41) * Update prototype to use iptables (envoyproxy#42) * Rebase to fixed Envoy (envoyproxy#43) * Handle HEAD request. (envoyproxy#34) * Handle HEAD request. * Try with GET if HEAD fails. * Address comments. * Format file. * Expose bazel target (envoyproxy#48) * Try again (envoyproxy#49) * Integrate with mixer client. (envoyproxy#55) * Integrate with mixer client. * Restore repositories.bzl back. * Add originIp and originHost attributes. (envoyproxy#56) * Add uuid-dev dependency in README.md (envoyproxy#45) * Extract originIp and OriginHost. (envoyproxy#57) * Extract originIp and OriginHost. * Make header x-forwarded-host const. * Update buckets for UI. (envoyproxy#58) * Update buckets for UI. * Only update time_distribution. * Add targetService attribute. (envoyproxy#59) * Use envoy new access_log handler for sending Report. (envoyproxy#60) * use access_log handler. * Not to use Loggable base class. * Update to the latest envoy with envoyproxy#396. (envoyproxy#61) * Fix tclap dependency fetching error (envoyproxy#62) * Integrate mixer client directly with envoy. (envoyproxy#66) * Integrate mixer client directly with envoy. * Send response header in Report. * rename filter name from esp to mixer. * add README. * Add release binary script. (envoyproxy#68) * Push tar.gz to GCS (envoyproxy#69) * Push tar.gz to GCS * Rename envoy_esp * Remove mixer_client from api_manager. (envoyproxy#72) * Update mixer client SHA. (envoyproxy#74) * Update readme. (envoyproxy#73) * Adds Jenkinsfile and updates release-binary to create a SHA. (envoyproxy#71) * Adds Jenkinsfile and update release-binary * Update Jenkinsfile and gitignore * Fixes typo and use normal build Node * Uses default bazel config * Using batch mode * Update bazel memory settings * Do not use Jenkins bazel env * Set .bazelrc for postsubmit * Update grpc and protobuf (envoyproxy#70) * protobuf v3.2.0 * grpc v1.1.1 * Align auth lib with grpc 1.1.1 * Add sourceService. (envoyproxy#78) * Add script to build docker image. (envoyproxy#77) * Add script to build docker image. * Add start_envoy for docker image. * Use official attribute names (envoyproxy#80) * Use official attribute names * fix format * Creates a KEY for mixer client dep. Updates release-binary (envoyproxy#79) * Updated mixer repo to use a key for commit * release-binary skip build if file exists. * Update src/envoy/mixer/README. (envoyproxy#82) * Fix src/envoy/mixer/README.md (envoyproxy#85) * Get attributes from envoy config. (envoyproxy#87) * Send all attributes. * Remove unused const strings. * Address comment. * updated SHA to point to newer envoy with RDS API feature (envoyproxy#94) * Disable travis on stable branches (envoyproxy#96) * Publish debug binaries (no release yet) (envoyproxy#98) * Copies the binary instead of linking for release (envoyproxy#102) * Not to use api_key if its service is not actived. (envoyproxy#109) * Update envoy and add c-ares (envoyproxy#107) * Update envoy and add c-ares depedencies * Update release script with debug and normal binary * remove debug ls * formatting * Send StatusCode Attributes to Mixer. (envoyproxy#110) * Add send_attribute filter. (envoyproxy#115) * Add send_attribute filter. * Fix format * rename variable serialized_attributes_ * Address the comments. * Fail request if api_key is not valid. (envoyproxy#116) * Fail request if api_key is not valid. * Format code. * Update comments. * Address comment. * Rename response.http.code (envoyproxy#125) * Send headers as string map. (envoyproxy#129) * Send headers as string map. * Remove origin.ip and origin.host. * Fix format * unify bazel's docker build targets with other istio repos (envoyproxy#127) * update base debug docker image reference (envoyproxy#133) * Update postsubmit to create docker images (envoyproxy#132) * Adding config release for bazel build (envoyproxy#135) * Fix mixer client crash. (envoyproxy#136) * Get mixerclient with response parsing. (envoyproxy#138) * Update nghttp2 to sync with envoy (envoyproxy#140) * Fix src/envoy/mixer/README.md * Update nghttp2 to sync with envoy * update * fix typo * Populate origin.user attribute from the SAN field of client cert (envoyproxy#142) * Test * test * test * revert file * address comments * test * fix typo * fix format * fix format * Update to latest mixer_client. (envoyproxy#145) * Update to latest mixer_client. * Updated the sha. * Not call report if decodeHeaders is not called. (envoyproxy#150) * Update mixerclient with sync-ed grpc write and fail-fast. (envoyproxy#155) * Update mixerclient with sync-ed write and fail-fast. * Update to latest test. * Update again * Update envoy to PR553 (envoyproxy#156) * Update envoy to PR553 * Update libevent to 2.1.8 * Update the Commit id for envoy * Allow for HTTP based function from Firebase rules (envoyproxy#202) * Allow for HTTP based function from Firebase rules * Fix code style check * Added more comments. * Fix style issues. * Address code review comments from Limin and Lizan. * Add more comments and address CR comments. * Fix a typo. * Address Wayne's CR comments. * Merge from master to firebase (envoyproxy#237) * Simple TCP server to show how to retrieve original dest IP:port after an iptables redirect (envoyproxy#38) * Simple TCP server to show how to retrieve original dest IP:port after an iptables redirect * Fixed style. * Rebase Envoy (envoyproxy#41) * Update prototype to use iptables (envoyproxy#42) * Rebase to fixed Envoy (envoyproxy#43) * Handle HEAD request. (envoyproxy#34) * Handle HEAD request. * Try with GET if HEAD fails. * Address comments. * Format file. * Expose bazel target (envoyproxy#48) * Try again (envoyproxy#49) * Integrate with mixer client. (envoyproxy#55) * Integrate with mixer client. * Restore repositories.bzl back. * Add originIp and originHost attributes. (envoyproxy#56) * Add uuid-dev dependency in README.md (envoyproxy#45) * Extract originIp and OriginHost. (envoyproxy#57) * Extract originIp and OriginHost. * Make header x-forwarded-host const. * Update buckets for UI. (envoyproxy#58) * Update buckets for UI. * Only update time_distribution. * Add targetService attribute. (envoyproxy#59) * Use envoy new access_log handler for sending Report. (envoyproxy#60) * use access_log handler. * Not to use Loggable base class. * Update to the latest envoy with envoyproxy#396. (envoyproxy#61) * Fix tclap dependency fetching error (envoyproxy#62) * Integrate mixer client directly with envoy. (envoyproxy#66) * Integrate mixer client directly with envoy. * Send response header in Report. * rename filter name from esp to mixer. * add README. * Add release binary script. (envoyproxy#68) * Push tar.gz to GCS (envoyproxy#69) * Push tar.gz to GCS * Rename envoy_esp * Remove mixer_client from api_manager. (envoyproxy#72) * Update mixer client SHA. (envoyproxy#74) * Update readme. (envoyproxy#73) * Adds Jenkinsfile and updates release-binary to create a SHA. (envoyproxy#71) * Adds Jenkinsfile and update release-binary * Update Jenkinsfile and gitignore * Fixes typo and use normal build Node * Uses default bazel config * Using batch mode * Update bazel memory settings * Do not use Jenkins bazel env * Set .bazelrc for postsubmit * Update grpc and protobuf (envoyproxy#70) * protobuf v3.2.0 * grpc v1.1.1 * Align auth lib with grpc 1.1.1 * Add sourceService. (envoyproxy#78) * Add script to build docker image. (envoyproxy#77) * Add script to build docker image. * Add start_envoy for docker image. * Use official attribute names (envoyproxy#80) * Use official attribute names * fix format * Creates a KEY for mixer client dep. Updates release-binary (envoyproxy#79) * Updated mixer repo to use a key for commit * release-binary skip build if file exists. * Update src/envoy/mixer/README. (envoyproxy#82) * Fix src/envoy/mixer/README.md (envoyproxy#85) * Get attributes from envoy config. (envoyproxy#87) * Send all attributes. * Remove unused const strings. * Address comment. * updated SHA to point to newer envoy with RDS API feature (envoyproxy#94) * Disable travis on stable branches (envoyproxy#96) * Publish debug binaries (no release yet) (envoyproxy#98) * Copies the binary instead of linking for release (envoyproxy#102) * Not to use api_key if its service is not actived. (envoyproxy#109) * Update envoy and add c-ares (envoyproxy#107) * Update envoy and add c-ares depedencies * Update release script with debug and normal binary * remove debug ls * formatting * Send StatusCode Attributes to Mixer. (envoyproxy#110) * Add send_attribute filter. (envoyproxy#115) * Add send_attribute filter. * Fix format * rename variable serialized_attributes_ * Address the comments. * Fail request if api_key is not valid. (envoyproxy#116) * Fail request if api_key is not valid. * Format code. * Update comments. * Address comment. * Rename response.http.code (envoyproxy#125) * Send headers as string map. (envoyproxy#129) * Send headers as string map. * Remove origin.ip and origin.host. * Fix format * unify bazel's docker build targets with other istio repos (envoyproxy#127) * update base debug docker image reference (envoyproxy#133) * Update postsubmit to create docker images (envoyproxy#132) * Adding config release for bazel build (envoyproxy#135) * Fix mixer client crash. (envoyproxy#136) * Get mixerclient with response parsing. (envoyproxy#138) * Update nghttp2 to sync with envoy (envoyproxy#140) * Fix src/envoy/mixer/README.md * Update nghttp2 to sync with envoy * update * fix typo * Populate origin.user attribute from the SAN field of client cert (envoyproxy#142) * Test * test * test * revert file * address comments * test * fix typo * fix format * fix format * Update to latest mixer_client. (envoyproxy#145) * Update to latest mixer_client. * Updated the sha. * Not call report if decodeHeaders is not called. (envoyproxy#150) * Update mixerclient with sync-ed grpc write and fail-fast. (envoyproxy#155) * Update mixerclient with sync-ed write and fail-fast. * Update to latest test. * Update again * Update envoy to PR553 (envoyproxy#156) * Update envoy to PR553 * Update libevent to 2.1.8 * Uses a specific version of the Shared Pipeline lib (envoyproxy#158) * Update lyft/envoy commit Id to latest. (envoyproxy#161) * Update lyft/envoy commit Id to latest. * Remove the comment about pull request * Add new line - will delete in next commit. * Update repositories.bzl (envoyproxy#169) * Always set response latency (envoyproxy#172) * Update mixerclient to sync_transport change. (envoyproxy#178) * Use opaque config to turn on/off forward attribute and mixer filter (envoyproxy#179) * Modify mixer filter * Swap defaults * Make the filter decoder only * cache mixer disabled decision * Fix a bug in opaque config change and test it out (envoyproxy#182) * Fix a bug and test it out * Update filter type * Update README.md * Update mixer client to mixer api with gogoproto. (envoyproxy#184) * Move .bazelrc to tools/bazel.rc (envoyproxy#186) * Move .bazelrc to tools/bazel.rc * Update Jenkinsfile with latest version of pipeline * Support apikey based traffic restriction (envoyproxy#189) * b/36368559 support apikey based traffic restriction * Fixed code formatting * Fix crash in unreachable/overloaded RDS (envoyproxy#190) * Add mixer client end to end integration test. (envoyproxy#177) * Add mixer client end to end integration test. * Split some repositories into a separate file. * use real mixer for fake mixer_server. * Test repository * use mixer bzl file. * Use mixer repositories * Not to use mixer repository. * Add return line at the end of WORKSPACE. * Fix broken link (envoyproxy#193) * Make quota call (envoyproxy#192) * hookup quota call * Make quota call. * Update indent. * Update envoy and update configs (envoyproxy#195) * Update envoy and update configs * Use gcc-4.9 for travis * Use bazel 0.4.5 * Fix SHA of lightstep-tracer-common * Enable check cache and refactory mixer config loading (envoyproxy#197) * Refactory the mixer config loading. * fix format * Add integration test. * updated README.md * s/send/sent/ * Split into separate tests. (envoyproxy#201) * Update README on how to enable check cache. (envoyproxy#204) * Update README on how to enable check cache. * Update the comment. * build: support Envoy native Bazel build. (envoyproxy#210) * build: support Envoy native Bazel build. This patch switches the Envoy build from src/envoy/repositories.bzl to using the upstream native build. See envoyproxy#663 for the corresponding changes on the Envoy side. * Use Envoy master with BUILD.wip rename merged. * Fix clang-format issues. * Fixes bazel.rc issues (envoyproxy#212) * Fixes bazel rc issues * Update Jenkins to latest pipeline version * Fix go build (envoyproxy#224) * Use TranscoderInputStream to reduce confusion around ByteCount() (envoyproxy#225) * Add TranscoderInputStream to reduce confusion * fix_format * Merge latest changes from rate_limiting to master (envoyproxy#221) * Point to googleapi in service control client. (envoyproxy#91) * Point to googleapi in service control client. * Use git repository for service-control-client. * Merge latest changes from master (envoyproxy#104) * Get attributes from envoy config. (envoyproxy#87) * Send all attributes. * Remove unused const strings. * Address comment. * updated SHA to point to newer envoy with RDS API feature (envoyproxy#94) * Disable travis on stable branches (envoyproxy#96) * Publish debug binaries (no release yet) (envoyproxy#98) * Copies the binary instead of linking for release (envoyproxy#102) * Extract quota config from service config. (envoyproxy#101) * Add metric_cost in config. * Remove group rules. * Call loadQuotaConfig in config::create. * Update latest update from master branch (envoyproxy#106) * Get attributes from envoy config. (envoyproxy#87) * Send all attributes. * Remove unused const strings. * Address comment. * updated SHA to point to newer envoy with RDS API feature (envoyproxy#94) * Disable travis on stable branches (envoyproxy#96) * Publish debug binaries (no release yet) (envoyproxy#98) * Copies the binary instead of linking for release (envoyproxy#102) * Added quota contoll without the service control client library (envoyproxy#93) * Added quota contoll without the service control client library * Applied code review * Applied code review * Resolve conflicts * Resolve conflicts * Fixed format error reported by script/check-style * Fixed a bug at Aggregated::GetAuthToken that causes Segmentation Fault * Changed usage of template funcion * Applied latest changes from the repo * Applied latest changes from the repo * Applied latest changes from the repo * Adde comments * Updated log information * Applied envoyproxy#101 * Changed metric_cost_map to metric_cost_vector * Fixed test case compilation error * Fixed test case compilation error * Add unit test for quota config. (envoyproxy#108) * Add unit test for quota config. * Add comments. * Update test specifics. * Merge latest changes from master branch (envoyproxy#112) * Get attributes from envoy config. (envoyproxy#87) * Send all attributes. * Remove unused const strings. * Address comment. * updated SHA to point to newer envoy with RDS API feature (envoyproxy#94) * Disable travis on stable branches (envoyproxy#96) * Publish debug binaries (no release yet) (envoyproxy#98) * Copies the binary instead of linking for release (envoyproxy#102) * Not to use api_key if its service is not actived. (envoyproxy#109) * If QuotaControl service is not available, return utils::Status::OK (envoyproxy#113) * If QuotaControl service is not available, return utils::Status::OK * Updated comment * Return HTTP status code 429 on google.rpc.Code.RESOURCE_EXHAUSTED (envoyproxy#119) * Fixed incorrectly resolved conflicts (envoyproxy#123) * Added unit test cases for rate limiting (envoyproxy#124) * Fixed incorrectly resolved conflicts * Added unit test cases for rate limiting * Added unit test cases for rate limiting * Added unit test cases for rate limiting * Added unit test cases for rate limiting * Added unit test cases for rate limiting * Added unit test cases for rate limiting * Rename response.http.code (envoyproxy#125) (envoyproxy#128) * Added handling of error code QUOTA_SYSTEM_UNAVAILABLE (envoyproxy#148) * Integrated service control client library with quota cache aggregation (envoyproxy#149) * Fixed error on merge (envoyproxy#151) * Integrated service control client library with quota cache aggregation * Fixed error on merge * Fixed the compatibility issue with the latest update on esp (envoyproxy#152) * Removed copied proto files (envoyproxy#208) * Set default allocate quota request timeout to 1sec and applied latest service control client library change (envoyproxy#211) * Merged key_restriction related changes from master (envoyproxy#213) * Merge latest changes from master branch (envoyproxy#217) * Not call report if decodeHeaders is not called. (envoyproxy#150) * Update mixerclient with sync-ed grpc write and fail-fast. (envoyproxy#155) * Update mixerclient with sync-ed write and fail-fast. * Update to latest test. * Update again * Update envoy to PR553 (envoyproxy#156) * Update envoy to PR553 * Update libevent to 2.1.8 * Uses a specific version of the Shared Pipeline lib (envoyproxy#158) * Update lyft/envoy commit Id to latest. (envoyproxy#161) * Update lyft/envoy commit Id to latest. * Remove the comment about pull request * Add new line - will delete in next commit. * Update repositories.bzl (envoyproxy#169) * Always set response latency (envoyproxy#172) * Update mixerclient to sync_transport change. (envoyproxy#178) * Use opaque config to turn on/off forward attribute and mixer filter (envoyproxy#179) * Modify mixer filter * Swap defaults * Make the filter decoder only * cache mixer disabled decision * Fix a bug in opaque config change and test it out (envoyproxy#182) * Fix a bug and test it out * Update filter type * Update README.md * Update mixer client to mixer api with gogoproto. (envoyproxy#184) * Move .bazelrc to tools/bazel.rc (envoyproxy#186) * Move .bazelrc to tools/bazel.rc * Update Jenkinsfile with latest version of pipeline * Support apikey based traffic restriction (envoyproxy#189) * b/36368559 support apikey based traffic restriction * Fixed code formatting * Fix crash in unreachable/overloaded RDS (envoyproxy#190) * Add mixer client end to end integration test. (envoyproxy#177) * Add mixer client end to end integration test. * Split some repositories into a separate file. * use real mixer for fake mixer_server. * Test repository * use mixer bzl file. * Use mixer repositories * Not to use mixer repository. * Add return line at the end of WORKSPACE. * Fix broken link (envoyproxy#193) * Make quota call (envoyproxy#192) * hookup quota call * Make quota call. * Update indent. * Update envoy and update configs (envoyproxy#195) * Update envoy and update configs * Use gcc-4.9 for travis * Use bazel 0.4.5 * Fix SHA of lightstep-tracer-common * Enable check cache and refactory mixer config loading (envoyproxy#197) * Refactory the mixer config loading. * fix format * Add integration test. * updated README.md * s/send/sent/ * Split into separate tests. (envoyproxy#201) * Update README on how to enable check cache. (envoyproxy#204) * Update README on how to enable check cache. * Update the comment. * build: support Envoy native Bazel build. (envoyproxy#210) * build: support Envoy native Bazel build. This patch switches the Envoy build from src/envoy/repositories.bzl to using the upstream native build. See envoyproxy#663 for the corresponding changes on the Envoy side. * Use Envoy master with BUILD.wip rename merged. * Fix clang-format issues. * Fixes bazel.rc issues (envoyproxy#212) * Fixes bazel rc issues * Update Jenkins to latest pipeline version * Updated the commit id of cloudendpoints/service-control-client-cxx (envoyproxy#218) * Update commitid of cloudendpoints/service-control-client-cxx repo (envoyproxy#220) * Send delta metrics for intermediate reports. (envoyproxy#219) * Send delta metrics for intermediate reports. * Move last_request_bytes/last_response_bytes to RequestContext. * Handle final report. * Address comment. * Update attributes to match the canonical attribute list. (envoyproxy#232) * Update response.http.code to response.code and response.latency to response.duration to line up with the canonical attributes in istio/istio.github.io/docs/concepts/attributes.md * Format according to clang-format * Add envoy Buffer based TranscoderInputStream (envoyproxy#231) * Add envoy Buffer based TranscoderInputStream * fix format * A few doc changes for consistency across repos. (envoyproxy#235) * Add repositories.bzl * Added missing export setting in bazel configuration (envoyproxy#236) * Added export missing in bazel configuration * Added export missing in bazel configuration * Allow HTTP functions in firebase rules to specify audience (envoyproxy#244) * Allow HTTP functions in firebase rules to specify audience * Allow GetAuthToken to ignore cache and fix style checks. * Fix GetAuthToken * Address Wayne's comment * Check for empty response body * Remove .bazelrc.jenkins file not present in the master branch. * Remove forward_attribute_filter.cc not present in master.
1 parent 2fcba36 commit 31b489f

23 files changed

+2047
-44
lines changed

contrib/endpoints/src/api_manager/BUILD

+34
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,19 @@ cc_proto_library(
3838
visibility = ["//visibility:public"],
3939
)
4040

41+
cc_proto_library(
42+
name = "security_rules_proto",
43+
srcs = [
44+
"proto/security_rules.proto",
45+
],
46+
default_runtime = "//external:protobuf",
47+
protoc = "//external:protoc",
48+
visibility = ["//visibility:public"],
49+
deps = [
50+
"//external:cc_wkt_protos",
51+
],
52+
)
53+
4154
cc_library(
4255
name = "auth_headers",
4356
hdrs = [
@@ -65,6 +78,8 @@ cc_library(
6578
"api_manager_impl.cc",
6679
"check_auth.cc",
6780
"check_auth.h",
81+
"check_security_rules.cc",
82+
"check_security_rules.h",
6883
"check_service_control.cc",
6984
"check_service_control.h",
7085
"check_workflow.cc",
@@ -95,11 +110,13 @@ cc_library(
95110
":path_matcher",
96111
":impl_headers",
97112
":server_config_proto",
113+
":security_rules_proto",
98114
"//contrib/endpoints/src/api_manager/auth",
99115
"//contrib/endpoints/src/api_manager/cloud_trace",
100116
"//contrib/endpoints/src/api_manager/context",
101117
"//contrib/endpoints/src/api_manager/service_control",
102118
"//contrib/endpoints/src/api_manager/utils",
119+
"//contrib/endpoints/src/api_manager/firebase_rules",
103120
"//external:cc_wkt_protos",
104121
"//external:cloud_trace",
105122
"//external:googletest_prod",
@@ -288,3 +305,20 @@ cc_test(
288305
"//external:googletest_main",
289306
],
290307
)
308+
309+
cc_test(
310+
name = "check_security_rules_test",
311+
size = "small",
312+
srcs = [
313+
"check_security_rules_test.cc",
314+
"mock_request.h",
315+
],
316+
linkstatic = 1,
317+
deps = [
318+
":api_manager",
319+
":mock_api_manager_environment",
320+
":security_rules_proto",
321+
"//external:cc_wkt_protos",
322+
"//external:googletest_main",
323+
],
324+
)

contrib/endpoints/src/api_manager/auth.h

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ struct UserInfo {
4040
// Authorized party of the incoming JWT.
4141
// See http://openid.net/specs/openid-connect-core-1_0.html#IDToken
4242
std::string authorized_party;
43+
// String of claims
44+
std::string claims;
4345

4446
// Returns audiences as a comma separated strings.
4547
std::string AudiencesAsString() const {

contrib/endpoints/src/api_manager/auth/lib/auth_jwt_validator.cc

+8-1
Original file line numberDiff line numberDiff line change
@@ -708,12 +708,19 @@ grpc_jwt_verifier_status JwtValidatorImpl::FillUserInfoAndSetExp(
708708

709709
// Optional field.
710710
const grpc_json *grpc_json = grpc_jwt_claims_json(claims_);
711+
712+
char *json_str =
713+
grpc_json_dump_to_string(const_cast<::grpc_json *>(grpc_json), 0);
714+
if (json_str != nullptr) {
715+
user_info->claims = json_str;
716+
gpr_free(json_str);
717+
}
718+
711719
const char *email = GetStringValue(grpc_json, "email");
712720
user_info->email = email == nullptr ? "" : email;
713721
const char *authorized_party = GetStringValue(grpc_json, "azp");
714722
user_info->authorized_party =
715723
authorized_party == nullptr ? "" : authorized_party;
716-
717724
exp_ = system_clock::from_time_t(grpc_jwt_claims_expires_at(claims_).tv_sec);
718725

719726
return GRPC_JWT_VERIFIER_OK;

contrib/endpoints/src/api_manager/auth/service_account_token.cc

+11-1
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,20 @@ Status ServiceAccountToken::SetClientAuthSecret(const std::string& secret) {
5656
void ServiceAccountToken::SetAudience(JWT_TOKEN_TYPE type,
5757
const std::string& audience) {
5858
GOOGLE_CHECK(type >= 0 && type < JWT_TOKEN_TYPE_MAX);
59-
jwt_tokens_[type].set_audience(audience);
59+
if (jwt_tokens_[type].audience() != audience) {
60+
jwt_tokens_[type].set_token("", 0);
61+
jwt_tokens_[type].set_audience(audience);
62+
}
6063
}
6164

6265
const std::string& ServiceAccountToken::GetAuthToken(JWT_TOKEN_TYPE type) {
66+
return GetAuthToken(type, jwt_tokens_[type].audience());
67+
}
68+
69+
const std::string& ServiceAccountToken::GetAuthToken(
70+
JWT_TOKEN_TYPE type, const std::string& audience) {
71+
SetAudience(type, audience);
72+
6373
// Uses authentication secret if available.
6474
if (!client_auth_secret_.empty()) {
6575
GOOGLE_CHECK(type >= 0 && type < JWT_TOKEN_TYPE_MAX);

contrib/endpoints/src/api_manager/auth/service_account_token.h

+11
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ class ServiceAccountToken {
6464
enum JWT_TOKEN_TYPE {
6565
JWT_TOKEN_FOR_SERVICE_CONTROL = 0,
6666
JWT_TOKEN_FOR_CLOUD_TRACING,
67+
JWT_TOKEN_FOR_FIREBASE,
68+
69+
// JWT token for accessing the http endpoints defined in Firebase Rules.
70+
JWT_TOKEN_FOR_AUTHORIZATION_SERVICE,
6771
JWT_TOKEN_FOR_QUOTA_CONTROL,
6872
JWT_TOKEN_TYPE_MAX,
6973
};
@@ -75,6 +79,13 @@ class ServiceAccountToken {
7579
// Otherwise, use the access token fetched from metadata server.
7680
const std::string& GetAuthToken(JWT_TOKEN_TYPE type);
7781

82+
// Gets the auth token to access Google services. This method accepts an
83+
// audience parameter to set when generating JWT token.
84+
// If client auth secret is specified, use it to calcualte JWT token.
85+
// Otherwise, use the access token fetched from metadata server.
86+
const std::string& GetAuthToken(JWT_TOKEN_TYPE type,
87+
const std::string& audience);
88+
7889
private:
7990
// Stores base token info. Used for both OAuth and JWT tokens.
8091
class TokenInfo {

contrib/endpoints/src/api_manager/check_auth.cc

+2
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ void AuthChecker::CheckAudience(bool cache_hit) {
243243
context_->set_auth_audience(audience);
244244
context_->set_auth_authorized_party(user_info_.authorized_party);
245245

246+
context_->set_auth_claims(user_info_.claims);
247+
246248
// Remove http/s header and trailing '/' for issuer.
247249
std::string issuer = utils::GetUrlContent(user_info_.issuer);
248250
if (!context_->method()->isIssuerAllowed(issuer)) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
// Copyright 2017 Google Inc. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
//
15+
////////////////////////////////////////////////////////////////////////////////
16+
#include "contrib/endpoints/src/api_manager/check_security_rules.h"
17+
#include <iostream>
18+
#include <sstream>
19+
#include "contrib/endpoints/src/api_manager/auth/lib/json_util.h"
20+
#include "contrib/endpoints/src/api_manager/firebase_rules/firebase_request.h"
21+
#include "contrib/endpoints/src/api_manager/utils/marshalling.h"
22+
23+
using ::google::api_manager::auth::GetStringValue;
24+
using ::google::api_manager::firebase_rules::FirebaseRequest;
25+
using ::google::api_manager::utils::Status;
26+
const char kFirebaseAudience[] =
27+
"https://staging-firebaserules.sandbox.googleapis.com/"
28+
"google.firebase.rules.v1.FirebaseRulesService";
29+
30+
namespace google {
31+
namespace api_manager {
32+
namespace {
33+
34+
const std::string kFailedFirebaseReleaseFetch =
35+
"Failed to fetch Firebase Release";
36+
const std::string kFailedFirebaseTest = "Failed to execute Firebase Test";
37+
const std::string kInvalidResponse =
38+
"Invalid JSON response from Firebase Service";
39+
const std::string kV1 = "/v1";
40+
const std::string kHttpGetMethod = "GET";
41+
const std::string kProjects = "/projects";
42+
const std::string kReleases = "/releases";
43+
const std::string kRulesetName = "rulesetName";
44+
const std::string kContentType = "Content-Type";
45+
const std::string kApplication = "application/json";
46+
47+
std::string GetReleaseName(const context::RequestContext &context) {
48+
return context.service_context()->service_name() + ":" +
49+
context.service_context()->service().apis(0).version();
50+
}
51+
52+
std::string GetReleaseUrl(const context::RequestContext &context) {
53+
return context.service_context()->config()->GetFirebaseServer() + kV1 +
54+
kProjects + "/" + context.service_context()->project_id() + kReleases +
55+
"/" + GetReleaseName(context);
56+
}
57+
58+
// An AuthzChecker object is created for every incoming request. It does
59+
// authorizaiton by calling Firebase Rules service.
60+
class AuthzChecker : public std::enable_shared_from_this<AuthzChecker> {
61+
public:
62+
// Constructor
63+
AuthzChecker(ApiManagerEnvInterface *env,
64+
auth::ServiceAccountToken *sa_token);
65+
66+
// Check for Authorization success or failure
67+
void Check(std::shared_ptr<context::RequestContext> context,
68+
std::function<void(Status status)> continuation);
69+
70+
private:
71+
// This method invokes the Firebase TestRuleset API endpoint as well as user
72+
// defined endpoints provided by the TestRulesetResponse.
73+
void CallNextRequest(std::function<void(Status status)> continuation);
74+
75+
// Parse the response for GET RELEASE API call
76+
Status ParseReleaseResponse(const std::string &json_str,
77+
std::string *ruleset_id);
78+
79+
// Invoke the HTTP call
80+
void HttpFetch(const std::string &url, const std::string &method,
81+
const std::string &request_body,
82+
auth::ServiceAccountToken::JWT_TOKEN_TYPE token_type,
83+
const std::string &audience,
84+
std::function<void(Status, std::string &&)> continuation);
85+
86+
std::shared_ptr<AuthzChecker> GetPtr() { return shared_from_this(); }
87+
88+
ApiManagerEnvInterface *env_;
89+
auth::ServiceAccountToken *sa_token_;
90+
std::unique_ptr<FirebaseRequest> request_handler_;
91+
};
92+
93+
AuthzChecker::AuthzChecker(ApiManagerEnvInterface *env,
94+
auth::ServiceAccountToken *sa_token)
95+
: env_(env), sa_token_(sa_token) {}
96+
97+
void AuthzChecker::Check(
98+
std::shared_ptr<context::RequestContext> context,
99+
std::function<void(Status status)> final_continuation) {
100+
// TODO: Check service config to see if "useSecurityRules" is specified.
101+
// If so, call Firebase Rules service TestRuleset API.
102+
103+
if (!context->service_context()->IsRulesCheckEnabled() ||
104+
context->method() == nullptr || !context->method()->auth()) {
105+
env_->LogDebug("Skipping Firebase Rules checks since it is disabled.");
106+
final_continuation(Status::OK);
107+
return;
108+
}
109+
110+
// Fetch the Release attributes and get ruleset name.
111+
auto checker = GetPtr();
112+
HttpFetch(GetReleaseUrl(*context), kHttpGetMethod, "",
113+
auth::ServiceAccountToken::JWT_TOKEN_FOR_FIREBASE,
114+
kFirebaseAudience, [context, final_continuation, checker](
115+
Status status, std::string &&body) {
116+
std::string ruleset_id;
117+
if (status.ok()) {
118+
checker->env_->LogDebug(
119+
std::string("GetReleasName succeeded with ") + body);
120+
status = checker->ParseReleaseResponse(body, &ruleset_id);
121+
} else {
122+
checker->env_->LogError(std::string("GetReleaseName for ") +
123+
GetReleaseUrl(*context.get()) +
124+
" with status " + status.ToString());
125+
status = Status(Code::INTERNAL, kFailedFirebaseReleaseFetch);
126+
}
127+
128+
// If the parsing of the release body is successful, then call the
129+
// Test Api for firebase rules service.
130+
if (status.ok()) {
131+
checker->request_handler_ = std::unique_ptr<FirebaseRequest>(
132+
new FirebaseRequest(ruleset_id, checker->env_, context));
133+
checker->CallNextRequest(final_continuation);
134+
} else {
135+
final_continuation(status);
136+
}
137+
});
138+
}
139+
140+
void AuthzChecker::CallNextRequest(
141+
std::function<void(Status status)> continuation) {
142+
if (request_handler_->is_done()) {
143+
continuation(request_handler_->RequestStatus());
144+
return;
145+
}
146+
147+
auto checker = GetPtr();
148+
firebase_rules::HttpRequest http_request = request_handler_->GetHttpRequest();
149+
HttpFetch(http_request.url, http_request.method, http_request.body,
150+
http_request.token_type, http_request.audience,
151+
[continuation, checker](Status status, std::string &&body) {
152+
153+
checker->env_->LogError(std::string("Response Body = ") + body);
154+
if (status.ok() && !body.empty()) {
155+
checker->request_handler_->UpdateResponse(body);
156+
checker->CallNextRequest(continuation);
157+
} else {
158+
checker->env_->LogError(
159+
std::string("Test API failed with ") +
160+
(status.ok() ? "Empty Response" : status.ToString()));
161+
status = Status(Code::INTERNAL, kFailedFirebaseTest);
162+
continuation(status);
163+
}
164+
});
165+
}
166+
167+
Status AuthzChecker::ParseReleaseResponse(const std::string &json_str,
168+
std::string *ruleset_id) {
169+
grpc_json *json = grpc_json_parse_string_with_len(
170+
const_cast<char *>(json_str.data()), json_str.length());
171+
172+
if (!json) {
173+
return Status(Code::INVALID_ARGUMENT, kInvalidResponse);
174+
}
175+
176+
Status status = Status::OK;
177+
const char *id = GetStringValue(json, kRulesetName.c_str());
178+
*ruleset_id = (id == nullptr) ? "" : id;
179+
180+
if (ruleset_id->empty()) {
181+
env_->LogError("Empty ruleset Id received from firebase service");
182+
status = Status(Code::INTERNAL, kInvalidResponse);
183+
} else {
184+
env_->LogDebug(std::string("Received ruleset Id: ") + *ruleset_id);
185+
}
186+
187+
grpc_json_destroy(json);
188+
return status;
189+
}
190+
191+
void AuthzChecker::HttpFetch(
192+
const std::string &url, const std::string &method,
193+
const std::string &request_body,
194+
auth::ServiceAccountToken::JWT_TOKEN_TYPE token_type,
195+
const std::string &audience,
196+
std::function<void(Status, std::string &&)> continuation) {
197+
env_->LogDebug(std::string("Issue HTTP Request to url :") + url +
198+
" method : " + method + " body: " + request_body);
199+
200+
std::unique_ptr<HTTPRequest> request(new HTTPRequest([continuation](
201+
Status status, std::map<std::string, std::string> &&,
202+
std::string &&body) { continuation(status, std::move(body)); }));
203+
204+
if (!request) {
205+
continuation(Status(Code::INTERNAL, "Out of memory"), "");
206+
return;
207+
}
208+
209+
request->set_method(method).set_url(url).set_auth_token(
210+
sa_token_->GetAuthToken(token_type, audience));
211+
212+
if (!request_body.empty()) {
213+
request->set_header(kContentType, kApplication).set_body(request_body);
214+
}
215+
216+
env_->RunHTTPRequest(std::move(request));
217+
}
218+
219+
} // namespace
220+
221+
void CheckSecurityRules(std::shared_ptr<context::RequestContext> context,
222+
std::function<void(Status status)> continuation) {
223+
std::shared_ptr<AuthzChecker> checker = std::make_shared<AuthzChecker>(
224+
context->service_context()->env(),
225+
context->service_context()->service_account_token());
226+
checker->Check(context, continuation);
227+
}
228+
229+
} // namespace api_manager
230+
} // namespace google

0 commit comments

Comments
 (0)