-
Notifications
You must be signed in to change notification settings - Fork 106
Rotating Public API Key Using Task
This wiki will show you how to use the update_public_api_key
task to rotate public API keys.
cf login -a api.fr.cloud.gov --sso
Other spaces may cause permissions issues.
cf target -s dev
cf oauth-token > token.txt
NOTE: This token will work for about four minutes before requiring another one. Also make sure the file is in the same directory that you are running the next command.
cf run-task api --command "python cli.py update_public_api_key prod fec-creds-prod '$(< token.txt)'" --name update_public_api_key
Finally, Re-stage the application using Circleci, deactivate the old key in API Umbrella, and update the fec-accounts wiki: https://github.com/fecgov/fec-accounts/wiki/API-public-and-private-key-information.
The task requires that you pass in the space
, service instance
, and your bearer token
.
-
space
: [Required] the space that you want to update -
service_instance
: [Required] the user provided service you want to update -
token
: [Required] your cf oath token generated above
You can also optionally pass in first_rate_limit
, first_rate_limit_duration
, second_rate_limit
, and second_rate_limit_duration
if you would like to use a different rate limit than the default.
-
first_rate_limit
: [Optional] the limit of the first rate limit on the new key -
first_rate_limit_duration
[Optional] the duration of the first rate limit on the new key -
second_rate_limit
[Optional] the limit of the second rate limit on the new key -
second_rate_limit_duration
[Optional] the duration of the second rate limit on the new key
cf run-task api --command "python cli.py update_public_api_key <space> <service_instance> '$(< token.txt)' <first_rate_limit> <first_rate_limit_duration> <second_rate_limit> <second_rate_limit_duration>" --name update_public_api_key
cf run-task api --command "python cli.py update_public_api_key dev fec-creds-dev '$(< token.txt)'" --name update_public_api_key