Add authenticated endpoint.

This commit is contained in:
Tom Alexander
2024-10-15 23:03:52 -04:00
parent f9d3c551f0
commit 9ea4952327
14 changed files with 501 additions and 29 deletions

22
scripts/get_jwks.bash Executable file
View File

@@ -0,0 +1,22 @@
#!/usr/bin/env bash
#
# Key the JWKS
set -euo pipefail
IFS=$'\n\t'
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
function main() {
local gateway_address
gateway_address=$(tf output -raw gateway_address)
curl "https://$gateway_address/.well-known/jwks.json"
}
function tf() {
terraform -chdir="$DIR/../terraform" "${@}"
}
main "${@}"

View File

@@ -0,0 +1,24 @@
#!/usr/bin/env bash
#
# Hit an endpoint that requires a valid JWT.
set -euo pipefail
IFS=$'\n\t'
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
function main() {
local jwt
jwt=$(cd "$DIR"/../api_server && poetry run python -m api_server.local_generate_long_lived_token)
local gateway_address
gateway_address=$(tf output -raw gateway_address)
curl -H "Authorization: Bearer $jwt" "https://$gateway_address/some_protected_endpoint"
}
function tf() {
terraform -chdir="$DIR/../terraform" "${@}"
}
main "${@}"