generated from CDCgov/template
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Simplified load-etor-org-settings script to only run in local env * Using preferred gradlew commands instead of prime ones. Also added env variable for RS_HOME * Moved common functions to /scripts/utils.sh and importing scripts using absolute path * Extract env variables to a shared .env file, updated docs, renamed some of the envars. Also working of having absolute paths so the scripts could run from anywhere * Fixed .env loading and some cleanup * Renamed reset.sh => setup.sh * Consolidated RS setup scripts into one * Moved rs/setup.sh to setup-rs.sh and removed rs/ folder * Updated RS setup instructions in readme to: - Use new setup-rs.sh script - Add alternate ways to build and run RS - Fixed RS docs URL - Clean up and simplify * Moved files to reorganize and simplify file structure * Updated paths * Reverted moving hurl files * Moved and renamed function scripts * Moved and renamed more scripts + added to readme * Moved function to common.sh * Removed unused hurl/readme.md * Fixed .env file reference * Added to readme and added user message to find instructions * Added context to instruction * Added setup script for env vars * Changed relative path to hurl files for absolute paths * Fixed typos and cleanup * Removed setup script not working as intended * Readme update * Fixed issues after running shellcheck * Removed dead code and renamed readme section * Reverted adding double quotes as it introduces a bug * Added missing export of env vars that are required to create vault credentials * Fixed typo * Renamed client => sender, cleanup * Refactored to extract common code + fix bug * Updated readme + cleanup * Refactored to extract more common code and changed to use global variables for consistency and fto simplify * Refactored scripts to include epic.sh * Refactored to simplify + cleanup * Cleanup * Renamed epic => ucsd * Renamed epic => ucsd
- Loading branch information
1 parent
bc34bac
commit 421ae5b
Showing
19 changed files
with
219 additions
and
262 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
# curl --header 'Content-Type: application/x-www-form-urlencoded' --data 'scope=flexion.*.report' --data 'client_assertion=$(jwt encode --exp=+5min --jti $(uuidgen) --alg RS256 -k $client -i $client -s $client -a $host --no-iat -S @/path/to/ucsd-epic-private-key.pem) --data 'client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer' --data 'grant_type=client_credentials' 'http://localhost:7071/api/token' | ||
# curl --header 'Content-Type: application/x-www-form-urlencoded' --data 'scope=flexion.*.report' --data 'client_assertion=$(jwt encode --exp=+5min --jti $(uuidgen) --alg RS256 -k $sender -i $sender -s $sender -a $host --no-iat -S @/path/to/ucsd-epic-private-key.pem) --data 'client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer' --data 'grant_type=client_credentials' 'http://localhost:7071/api/token' | ||
POST {{url}}/api/token | ||
Content-Type: application/x-www-form-urlencoded | ||
[FormParams] | ||
scope: {{client-id}}.*.report | ||
scope: {{sender-org}}.*.report | ||
client_assertion: {{jwt}} | ||
client_assertion_type: urn:ietf:params:oauth:client-assertion-type:jwt-bearer | ||
grant_type: client_credentials |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
POST {{url}}/v1/auth/token | ||
Content-Type: application/x-www-form-urlencoded | ||
[FormParams] | ||
scope: {{client}} | ||
scope: {{sender}} | ||
client_assertion: {{jwt}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#!/bin/bash | ||
|
||
show_usage() { | ||
local script_name=$1 | ||
|
||
cat <<EOF | ||
Usage: ./$script_name <ENDPOINT_NAME> [OPTIONS] | ||
ENDPOINT_NAME: | ||
The name of the endpoint to call (required) | ||
Options: | ||
-e <ENVIRONMENT> Environment: local|staging (Default: $ENVIRONMENT) | ||
-f <REL_PATH> Path to the message file to submit (Required for submission endpoints) | ||
-r <ROOT_PATH> Root path to the message files (Default: $ROOT_PATH) | ||
-t <CONTENT_TYPE> Content type for the message file (Default: $CONTENT_TYPE) | ||
-k <KEY_PATH> Path to the sender private key (Required for non-local environments) | ||
-s <SENDER> Sender ID used for authentication (Default: $SENDER) | ||
-u <URL> URL root for the API endpoint (Default: auto-detected) | ||
-i <SUBMISSION_ID> Submission ID (Required for query endpoints) | ||
-v Verbose mode | ||
-h Display this help and exit | ||
EOF | ||
} | ||
|
||
parse_args() { | ||
local type=$1 | ||
shift | ||
|
||
[ "$1" = "-h" ] || [ "$1" = "--help" ] && return 1 | ||
[ $# -eq 0 ] && fail "Missing required argument <ENDPOINT_NAME>" | ||
|
||
HURL_FILE_PATH="$CDCTI_HOME/scripts/hurl/$type/$1.hurl" | ||
shift | ||
|
||
while getopts ':e:f:r:t:k:s:u:i:v' opt; do | ||
case "$opt" in | ||
e) ENVIRONMENT="$OPTARG" ;; | ||
f) REL_PATH="$OPTARG" ;; | ||
r) ROOT_PATH="$OPTARG" ;; | ||
t) CONTENT_TYPE="$OPTARG" ;; | ||
k) SENDER_PRIVATE_KEY="$OPTARG" ;; | ||
s) SENDER="$OPTARG" ;; | ||
u) URL="$OPTARG" ;; | ||
i) SUBMISSION_ID="$OPTARG" ;; | ||
v) VERBOSE="--verbose" ;; | ||
?) fail "Invalid option -$OPTARG" ;; | ||
esac | ||
done | ||
|
||
parse_sender_string "$SENDER" | ||
|
||
if [ -z "$SENDER_PRIVATE_KEY" ] && [ "$ENVIRONMENT" = "local" ] && [ -f "$DEFAULT_SENDER_PRIVATE_KEY_PATH" ] && [ "$SENDER_ORG" = "$DEFAULT_SENDER_PRIVATE_KEY_ORG" ]; then | ||
SENDER_PRIVATE_KEY="$DEFAULT_SENDER_PRIVATE_KEY_PATH" | ||
elif [ -z "$SENDER_PRIVATE_KEY" ] && [ "$ENVIRONMENT" != "local" ]; then | ||
fail "Sender private key (-k) is required for non-local environments" | ||
fi | ||
|
||
[ ! -f "$SENDER_PRIVATE_KEY" ] && fail "Sender private key file not found: $SENDER_PRIVATE_KEY" | ||
|
||
shift "$((OPTIND - 1))" | ||
REMAINING_ARGS="$*" | ||
} | ||
|
||
handle_api_request() { | ||
local api_type=$1 | ||
shift | ||
|
||
local host jwt_token | ||
[ -z "$URL" ] && URL=$(get_api_url "$ENVIRONMENT" "$api_type") | ||
host=$(extract_host_from_url "$URL") | ||
jwt_token=$(generate_jwt "$SENDER" "$host" "$SENDER_PRIVATE_KEY") | ||
|
||
local vars=( | ||
--variable fpath=$REL_PATH | ||
--file-root $ROOT_PATH | ||
--variable url=$URL | ||
--variable jwt=$jwt_token | ||
--variable content-type=$CONTENT_TYPE | ||
) | ||
|
||
if [ "$api_type" = "rs" ]; then | ||
vars+=( | ||
--variable sender-org=$SENDER_ORG | ||
--variable sender-name=$SENDER_NAME | ||
) | ||
else | ||
vars+=(--variable sender=$SENDER) | ||
fi | ||
|
||
if [ -n "$SUBMISSION_ID" ]; then vars+=(--variable submissionid="$SUBMISSION_ID"); fi | ||
if [ -n "$VERBOSE" ]; then vars+=("$VERBOSE"); fi | ||
|
||
hurl "${vars[@]}" "$HURL_FILE_PATH" ${REMAINING_ARGS:+$REMAINING_ARGS} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.