-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #72 from bcgov-nr/feat/addCheckToken
feat: add broker JWT expiration check
- Loading branch information
Showing
4 changed files
with
54 additions
and
1 deletion.
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 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,37 @@ | ||
name: Check token expiration | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
url: | ||
description: "The Broker URL" | ||
default: https://broker.io.nrs.gov.bc.ca | ||
type: string | ||
secrets: | ||
token: | ||
description: "The Broker token" | ||
required: true | ||
|
||
jobs: | ||
check-jwt: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check token expiration | ||
shell: bash | ||
run: | | ||
RESPONSE_CODE=$(curl -o /dev/null -s -w "%{http_code}" -X 'GET' \ | ||
${{ inputs.url }}/v1/health/token-check \ | ||
-H 'accept: */*' \ | ||
-H 'Authorization: Bearer '"${{ secrets.token }}"'' \ | ||
) | ||
if [ "$RESPONSE_CODE" -eq 401 ]; then | ||
echo "Unauthorized (401)" | ||
exit 1 | ||
elif [ "$RESPONSE_CODE" -eq 403 ]; then | ||
echo "Invalid JWT: Block list has match" | ||
exit 1 | ||
else | ||
echo "Response code: $RESPONSE_CODE" | ||
fi |
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