Skip to content

Commit

Permalink
Load client keys from GCS (#209)
Browse files Browse the repository at this point in the history
* Load client keys from GCS

* s/loadtest/test-client/

* Updated deployed service config
  • Loading branch information
lizan authored Jul 12, 2017
1 parent acff249 commit 3f9f7a5
Show file tree
Hide file tree
Showing 23 changed files with 48 additions and 67 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ CMakeLists.txt
/bazel-*

test/src/github.com

client/custom/esp-test-client-secret-jwk.json
client/custom/esp-test-client-secret-x509.json
test/echo/esp-echo-client-secret-jwk.json
12 changes: 0 additions & 12 deletions client/custom/esp-test-client-secret-jwk.json

This file was deleted.

7 changes: 0 additions & 7 deletions client/custom/esp-test-client-secret-x509.json

This file was deleted.

6 changes: 3 additions & 3 deletions client/custom/gen-auth-token.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ BUILD_AUTH_TOKEN_GEN=1

. ${ROOT}/script/all-utilities || { echo 'Cannot load Bash utilities'; exit 1; }

# By default, use jwk key. Can be switched to x509 or symmetric key.
SECRET_FILE="${ROOT}/client/custom/esp-test-client-secret-jwk.json"

# By default audience is service name, use -a to change it to your service
# name or other allowed audiences (check service swagger configuration).
AUDIENCE="bookstore-esp-echo.cloudendpointsapis.com"
Expand All @@ -62,6 +59,9 @@ while getopts a:g:s:? arg; do
esac
done

# By default, use jwk key. Can be switched to x509 or symmetric key.
SECRET_FILE="${SECRET_FILE:-$(get_test_client_key ${ROOT}/client/custom/esp-test-client-secret-jwk.json)}"

if [[ ! -x ${AUTH_TOKEN_GEN} ]]; then
[[ ${BUILD_AUTH_TOKEN_GEN} -ne 0 ]] \
|| error_exit "Cannot find ${AUTH_TOKEN_GEN}"
Expand Down
4 changes: 2 additions & 2 deletions doc/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ Open `${ESP}/src/nginx/conf/bookstore.json` and replace the (initially empty)
"providers": [
{
"id": "test-auth-provider",
"issuer": "loadtest@esp-test-client.iam.gserviceaccount.com",
"jwksUri": "https://www.googleapis.com/service_accounts/v1/jwk/loadtest@esp-test-client.iam.gserviceaccount.com"
"issuer": "test-client@esp-test-client.iam.gserviceaccount.com",
"jwksUri": "https://www.googleapis.com/service_accounts/v1/jwk/test-client@esp-test-client.iam.gserviceaccount.com"
}
],
"rules": [
Expand Down
11 changes: 10 additions & 1 deletion script/all-utilities
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,22 @@ function retry() {
# Download api Keys from Cloud storage and source the file.
function set_api_keys() {
local api_key_directory="$(mktemp -d)"
gsutil cp gs://client-secret-files/api_keys \
$GSUTIL cp gs://client-secret-files/api_keys \
"${api_key_directory}/api_keys" \
|| error_exit "Failed to download API key file."

source "${api_key_directory}/api_keys"
}

# Download test-client keys from Cloud storage
function get_test_client_key() {
local key_path=$1
[[ -e $key_path ]] || $GSUTIL \
cp gs://client-secret-files/esp-test-client-434d3cb34a1c.json $key_path
echo -n $key_path
return 0
}

# Creates a simple Json Status file
function create_status_file() {
local OPTIND OPTARG ARG
Expand Down
4 changes: 2 additions & 2 deletions script/linux-start-local-test
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ NGINX_ARGS=(-p "${PREFIX}" -c "${NGINX_CONFIG}" -g "pid ${PREFIX}/.nginx.pid;")

echo 'Constructing test data.'
JWT_TOKEN="$("${ROOT}/client/custom/gen-auth-token.sh" \
-s "${ROOT}/test/echo/esp-echo-client-secret-jwk.json" \
-a "${SERVICE_NAME}")"
-s "$(get_test_client_key ${ROOT}/test/echo/esp-echo-client-secret-jwk.json)" \
-a "${SERVICE_NAME}")"
POST_FILE="${ROOT}/test/data/8k.json"
HOST='http://127.0.0.1:8090'

Expand Down
4 changes: 2 additions & 2 deletions script/linux-test-vm-bookstore
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ BOOKSTORE_FAILURES=0
# "kid": "f525b853cbd035cc6b2910bb87752311d32091b8"
# }
# {
# "iss": "loadtest@esp-test-client.iam.gserviceaccount.com",
# "sub": "loadtest@esp-test-client.iam.gserviceaccount.com",
# "iss": "test-client@esp-test-client.iam.gserviceaccount.com",
# "sub": "test-client@esp-test-client.iam.gserviceaccount.com",
# "aud": ["test", "esp-load-test.appspot.com"],
# "iat": 1457109765,
# "exp": 2457113365
Expand Down
4 changes: 2 additions & 2 deletions script/linux-test-vm-echo
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ EXPECTED_RESPONSE=".*Method doesn't allow unregistered callers.*STATUS_CODE:401"

SERVICE_NAME="echo-dot-${PROJECT_ID}.appspot.com"
JWT_TOKEN="$("${ROOT}/client/custom/gen-auth-token.sh" \
-s "${ROOT}/test/echo/esp-echo-client-secret-jwk.json" \
-s "$(get_test_client_key ${ROOT}/test/echo/esp-echo-client-secret-jwk.json)" \
-a "${SERVICE_NAME}")"
POST_FILE="${ROOT}/test/echo/esp-echo-client-secret-x509.json"
POST_FILE="${ROOT}/test/echo/package.json"

echo "Start perf testing"
pushd "${ROOT}/test/client" > /dev/null
Expand Down
2 changes: 1 addition & 1 deletion test/bookstore/app_esp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ manual_scaling:
# Hard code the service name and config_id
endpoints_api_service:
name: "${MY_PROJECT_ID}.appspot.com"
config_id: "2017-05-25r0"
config_id: "2017-07-12r0"

beta_settings:
allow_ssh: true
Expand Down
4 changes: 2 additions & 2 deletions test/bookstore/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,8 @@
"authorizationUrl": "",
"flow": "implicit",
"type": "oauth2",
"x-google-issuer": "loadtest@esp-test-client.iam.gserviceaccount.com",
"x-google-jwks_uri": "https://www.googleapis.com/service_accounts/v1/jwk/loadtest@esp-test-client.iam.gserviceaccount.com"
"x-google-issuer": "test-client@esp-test-client.iam.gserviceaccount.com",
"x-google-jwks_uri": "https://www.googleapis.com/service_accounts/v1/jwk/test-client@esp-test-client.iam.gserviceaccount.com"
},
"test_symmetric": {
"authorizationUrl": "",
Expand Down
4 changes: 2 additions & 2 deletions test/bookstore/swagger_template.json
Original file line number Diff line number Diff line change
Expand Up @@ -607,8 +607,8 @@
"authorizationUrl": "",
"flow": "implicit",
"type": "oauth2",
"x-google-issuer": "loadtest@esp-test-client.iam.gserviceaccount.com",
"x-google-jwks_uri": "https://www.googleapis.com/service_accounts/v1/jwk/loadtest@esp-test-client.iam.gserviceaccount.com"
"x-google-issuer": "test-client@esp-test-client.iam.gserviceaccount.com",
"x-google-jwks_uri": "https://www.googleapis.com/service_accounts/v1/jwk/test-client@esp-test-client.iam.gserviceaccount.com"
},
"test_symmetric": {
"authorizationUrl": "",
Expand Down
8 changes: 4 additions & 4 deletions test/data/35k.json
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@
},
{
"id": "test_jwk",
"issuer": "loadtest@esp-test-client.iam.gserviceaccount.com",
"jwksUri": "https://www.googleapis.com/service_accounts/v1/jwk/loadtest@esp-test-client.iam.gserviceaccount.com"
"issuer": "test-client@esp-test-client.iam.gserviceaccount.com",
"jwksUri": "https://www.googleapis.com/service_accounts/v1/jwk/test-client@esp-test-client.iam.gserviceaccount.com"
},
{
"id": "test_symmetric",
Expand Down Expand Up @@ -1082,8 +1082,8 @@
},
{
"id": "test_jwk",
"issuer": "loadtest@esp-test-client.iam.gserviceaccount.com",
"jwksUri": "https://www.googleapis.com/service_accounts/v1/jwk/loadtest@esp-test-client.iam.gserviceaccount.com"
"issuer": "test-client@esp-test-client.iam.gserviceaccount.com",
"jwksUri": "https://www.googleapis.com/service_accounts/v1/jwk/test-client@esp-test-client.iam.gserviceaccount.com"
},
{
"id": "test_symmetric",
Expand Down
4 changes: 2 additions & 2 deletions test/data/8k.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@
"providers": [
{
"id": "test_jwk",
"issuer": "loadtest@esp-test-client.iam.gserviceaccount.com",
"jwksUri": "https://www.googleapis.com/service_accounts/v1/jwk/loadtest@esp-test-client.iam.gserviceaccount.com"
"issuer": "test-client@esp-test-client.iam.gserviceaccount.com",
"jwksUri": "https://www.googleapis.com/service_accounts/v1/jwk/test-client@esp-test-client.iam.gserviceaccount.com"
},
{
"id": "test_symmetric",
Expand Down
2 changes: 1 addition & 1 deletion test/echo/app_esp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ manual_scaling:
# Hard code the service name and config_id
endpoints_api_service:
name: "echo-dot-${MY_PROJECT_ID}.appspot.com"
config_id: "2017-05-26r0"
config_id: "2017-07-12r0"

beta_settings:
allow_ssh: true
Expand Down
4 changes: 2 additions & 2 deletions test/echo/echo.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"type": "oauth2",
"authorizationUrl": "",
"flow": "implicit",
"x-google-issuer": "loadtest@esp-test-client.iam.gserviceaccount.com",
"x-google-jwks_uri": "https://www.googleapis.com/service_accounts/v1/jwk/loadtest@esp-test-client.iam.gserviceaccount.com"
"x-google-issuer": "test-client@esp-test-client.iam.gserviceaccount.com",
"x-google-jwks_uri": "https://www.googleapis.com/service_accounts/v1/jwk/test-client@esp-test-client.iam.gserviceaccount.com"
},
"test_x509": {
"type": "oauth2",
Expand Down
12 changes: 0 additions & 12 deletions test/echo/esp-echo-client-secret-jwk.json

This file was deleted.

2 changes: 1 addition & 1 deletion test/echo/esp-echo-client-secret-x509.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private_key_id": "33a681b36b8983913b05f8d5eab165c60694b6fc",
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDSgktXIdXYafwC\nF+yVbrT9Khnqy92eF3Ib7hpAT4INirSIj0lMgkwpntPk6xYvzTZK32iwoqkv5chS\nnKA9E0iTTAkicsIFMXwru75x+w3s9CmPsKfSC+jW1126HkJEB4wRkUKzBYOrZIWe\nkwC7X0vgDWCwkKzfKXSqlUmm73NUB9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SObdeay4bD46ITJMCgYBF\nISh28KQcAbZ18IFNl7MKwq8FDz0Hcf/O3f+CKoI6XsRLv/eA9SdN1BEAmCrlLw2K\nNYwr1eLr7TV2HihaLx50JeqHEFchmO8ZMpvU+gOy1k9tG4UWo8vjX09FIjXg0dZc\nxfHzKOFo4pfmdmdDTBXatCLenRywANFq0qwHTgz/KwKBgQDq3ZyXVGmqpdndSxVe\nE8W2JNVvUMFnsWuW9py0XqyaZV3i4eBQdaUQ24Dojkc7nJ2aLvtVIa5X02C9HPdu\ngKbMjlwt+7ord0WiysX1OzYP6YuJJpeDtqHJQB8dZvfeOZf11RXuQEpN0NrCm8Yb\nI9AhDqa+2sl6kOtAlrlsRzF4CQ==\n-----END PRIVATE KEY-----\n",
"client_email": "loadtest@esp-test-client.iam.gserviceaccount.com",
"client_email": "test-client@esp-test-client.iam.gserviceaccount.com",
"client_id": "101525312337747968935",
"type": "service_account"
}
1 change: 0 additions & 1 deletion test/echo/local.conf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ http {
# cp service.json.temp service.json and modify ${PROJECT}
api service.json;
consumer_project_id esp_echo;
servicecontrol_secret esp-echo-client-secret-x509.json;
}
# End Endpoints v2 Support

Expand Down
4 changes: 2 additions & 2 deletions test/echo/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@
"authorizationUrl": "",
"flow": "implicit",
"type": "oauth2",
"x-google-issuer": "loadtest@esp-test-client.iam.gserviceaccount.com",
"x-google-jwks_uri": "https://www.googleapis.com/service_accounts/v1/jwk/loadtest@esp-test-client.iam.gserviceaccount.com",
"x-google-issuer": "test-client@esp-test-client.iam.gserviceaccount.com",
"x-google-jwks_uri": "https://www.googleapis.com/service_accounts/v1/jwk/test-client@esp-test-client.iam.gserviceaccount.com",
"x-google-audiences": "echo-${MY_PROJECT_ID}.appspot.com"
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/grpc/grpc-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ authentication:
- provider_id: test_jwk
providers:
- id: test_jwk
issuer: loadtest@esp-test-client.iam.gserviceaccount.com
jwks_uri: https://www.googleapis.com/service_accounts/v1/jwk/loadtest@esp-test-client.iam.gserviceaccount.com
issuer: test-client@esp-test-client.iam.gserviceaccount.com
jwks_uri: https://www.googleapis.com/service_accounts/v1/jwk/test-client@esp-test-client.iam.gserviceaccount.com
usage:
rules:
- selector: test.grpc.Test.Echo
Expand Down
4 changes: 2 additions & 2 deletions test/grpc/local/service.json
Original file line number Diff line number Diff line change
Expand Up @@ -1102,8 +1102,8 @@
"providers": [
{
"id": "test_jwk",
"issuer": "loadtest@esp-test-client.iam.gserviceaccount.com",
"jwksUri": "https://www.googleapis.com/service_accounts/v1/jwk/loadtest@esp-test-client.iam.gserviceaccount.com"
"issuer": "test-client@esp-test-client.iam.gserviceaccount.com",
"jwksUri": "https://www.googleapis.com/service_accounts/v1/jwk/test-client@esp-test-client.iam.gserviceaccount.com"
}
]
},
Expand Down
4 changes: 2 additions & 2 deletions tools/src/deploy/example/bookstore_swagger_template.json
Original file line number Diff line number Diff line change
Expand Up @@ -561,8 +561,8 @@
"authorizationUrl": "",
"flow": "implicit",
"type": "oauth2",
"x-google-issuer": "loadtest@esp-test-client.iam.gserviceaccount.com",
"x-google-jwks_uri": "https://www.googleapis.com/service_accounts/v1/jwk/loadtest@esp-test-client.iam.gserviceaccount.com"
"x-google-issuer": "test-client@esp-test-client.iam.gserviceaccount.com",
"x-google-jwks_uri": "https://www.googleapis.com/service_accounts/v1/jwk/test-client@esp-test-client.iam.gserviceaccount.com"
},
"test_symmetric": {
"authorizationUrl": "",
Expand Down

0 comments on commit 3f9f7a5

Please sign in to comment.