-
Notifications
You must be signed in to change notification settings - Fork 7
309 task add email application setup step in thunder #312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
maneeshaxyz
merged 5 commits into
LSFLK:main
from
Aravinda-HWK:309-task-add-email-application-setup-step-in-thunder
Mar 29, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
038a618
Add email application setup step in Thunder script
Aravinda-HWK 6f8a659
Fix formatting of redirect URIs in SPA application setup
Aravinda-HWK 5d19350
Add OAUTHBEARER token validation configuration to raven.yaml generation
Aravinda-HWK 9057c31
Refactor blob_storage section update in delivery.yaml for improved clβ¦
Aravinda-HWK 7a3e615
Refactor JSON extraction functions in 02-sample-resources.sh for imprβ¦
Aravinda-HWK File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 +1,162 @@ | ||
| echo "Overwriting the default sample resources creation script with empty content..." | ||
| set -e | ||
|
|
||
| # Source common functions from the same directory as this script | ||
| SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]:-$0}")" | ||
| source "${SCRIPT_DIR}/common.sh" | ||
|
|
||
| # Load .env values when available (useful for local execution). | ||
| ENV_FILE="${SCRIPT_DIR}/.env" | ||
| if [[ -f "$ENV_FILE" ]]; then | ||
| set -a | ||
| source "$ENV_FILE" | ||
| set +a | ||
| fi | ||
|
|
||
| # Default SPA parameters (can be overridden via env vars). | ||
| SPA_APP_NAME="${THUNDER_SPA_APP_NAME:-Email App}" | ||
| SPA_APP_DESCRIPTION="${THUNDER_SPA_APP_DESCRIPTION:-Application for email client to use OAuth2 authentication}" | ||
| SPA_CLIENT_ID="${THUNDER_SPA_CLIENT_ID:-EMAIL_APP}" | ||
| SPA_ALLOWED_USER_TYPE="${THUNDER_SPA_ALLOWED_USER_TYPE:-Person}" | ||
|
|
||
| log_info "Creating single-page application resource..." | ||
| echo "" | ||
|
|
||
| # ============================================================================ | ||
| # Helpers | ||
| # ============================================================================ | ||
|
|
||
| extract_json_value() { | ||
| local JSON_STRING="$1" | ||
| local KEY="$2" | ||
|
|
||
| echo "$JSON_STRING" | grep -o "\"${KEY}\":\"[^\"]*\"" | head -1 | cut -d'"' -f4 | ||
| } | ||
|
|
||
| create_spa_application() { | ||
| local APP_NAME="$1" | ||
| local APP_DESCRIPTION="$2" | ||
| local CLIENT_ID="$3" | ||
| local ALLOWED_USER_TYPE="$4" | ||
| local RESPONSE HTTP_CODE BODY | ||
| local APP_ID APP_CLIENT_ID | ||
|
|
||
| log_info "Creating ${APP_NAME} application..." | ||
|
|
||
| read -r -d '' APP_PAYLOAD <<JSON || true | ||
| { | ||
| "name": "${APP_NAME}", | ||
| "description": "${APP_DESCRIPTION}", | ||
| "is_registration_flow_enabled": false, | ||
| "logo_url": "https://ssl.gstatic.com/docs/common/profile/kiwi_lg.png", | ||
| "assertion": { | ||
| "validity_period": 3600 | ||
| }, | ||
| "certificate": { | ||
| "type": "NONE" | ||
| }, | ||
| "inbound_auth_config": [ | ||
| { | ||
| "type": "oauth2", | ||
| "config": { | ||
| "client_id": "${CLIENT_ID}", | ||
| "redirect_uris": [ | ||
| "http://localhost/" | ||
| ], | ||
| "grant_types": [ | ||
| "authorization_code", | ||
| "refresh_token" | ||
| ], | ||
| "response_types": [ | ||
| "code" | ||
| ], | ||
| "token_endpoint_auth_method": "none", | ||
| "pkce_required": true, | ||
| "public_client": true, | ||
| "token": { | ||
| "access_token": { | ||
| "validity_period": 3600, | ||
| "user_attributes": [ | ||
| "groups", | ||
| "roles", | ||
| "ouId", | ||
| "username" | ||
| ] | ||
| }, | ||
| "id_token": { | ||
| "validity_period": 3600, | ||
| "user_attributes": [ | ||
| "groups", | ||
| "roles", | ||
| "ouId", | ||
| "username" | ||
| ] | ||
| } | ||
| }, | ||
| "scopes": [ | ||
| "openid", | ||
| "profile", | ||
| "email", | ||
| "group", | ||
| "role" | ||
| ], | ||
| "user_info": { | ||
| "user_attributes": [ | ||
| "groups", | ||
| "roles", | ||
| "ouId", | ||
| "username" | ||
| ] | ||
| }, | ||
| "scope_claims": { | ||
| "group": [ | ||
| "groups" | ||
| ], | ||
| "role": [ | ||
| "roles" | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| ], | ||
| "allowed_user_types": [ | ||
| "${ALLOWED_USER_TYPE}" | ||
| ] | ||
| } | ||
| JSON | ||
|
|
||
| RESPONSE=$(thunder_api_call POST "/applications" "${APP_PAYLOAD}") | ||
| HTTP_CODE="${RESPONSE: -3}" | ||
| BODY="${RESPONSE%???}" | ||
|
|
||
| if [[ "$HTTP_CODE" == "201" ]] || [[ "$HTTP_CODE" == "200" ]] || [[ "$HTTP_CODE" == "202" ]]; then | ||
| log_success "${APP_NAME} application created successfully" | ||
| APP_ID=$(extract_json_value "$BODY" "id") | ||
| APP_CLIENT_ID=$(extract_json_value "$BODY" "client_id") | ||
| if [[ -n "$APP_ID" ]]; then | ||
| log_info "${APP_NAME} app ID: ${APP_ID}" | ||
| fi | ||
| if [[ -n "$APP_CLIENT_ID" ]]; then | ||
| log_info "${APP_NAME} client ID: ${APP_CLIENT_ID}" | ||
| fi | ||
| elif [[ "$HTTP_CODE" == "409" ]] || ([[ "$HTTP_CODE" == "400" ]] && [[ "$BODY" =~ (Application\ already\ exists|APP-1022) ]]); then | ||
| log_warning "${APP_NAME} application already exists, skipping" | ||
| else | ||
| log_error "Failed to create ${APP_NAME} application (HTTP $HTTP_CODE)" | ||
| echo "Response: $BODY" | ||
| exit 1 | ||
| fi | ||
| } | ||
|
|
||
| # ============================================================================ | ||
| # Create Single SPA Application | ||
| # ============================================================================ | ||
|
|
||
| create_spa_application "$SPA_APP_NAME" "$SPA_APP_DESCRIPTION" "$SPA_CLIENT_ID" "$SPA_ALLOWED_USER_TYPE" | ||
|
|
||
| echo "" | ||
| log_success "Single-page application setup completed successfully!" | ||
| log_info "App name: ${SPA_APP_NAME}" | ||
| log_info "App client ID: ${SPA_CLIENT_ID}" | ||
| log_info "Allowed user type: ${SPA_ALLOWED_USER_TYPE}" | ||
| log_info "Redirect URIs: http://localhost/" | ||
| echo "" |
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.