#!/bin/bash # OAuth Provider Configuration Generator # This script helps you generate a valid JSON configuration for OAuth providers set -e # Provider definitions as JSON # To add a new provider, add an entry to this JSON array PROVIDERS_JSON='[ { "type": "Keycloak", "fields": [ {"name": "baseUrl", "prompt": "Base URL (e.g., '\''https://sso.example.com'\'')"}, {"name": "realm", "prompt": "Realm (e.g., '\''my-realm'\'')"}, {"name": "clientID", "prompt": "Client ID"}, {"name": "clientSecret", "prompt": "Client Secret"} ] } ]' # Reads common provider-agnostic configuration read_general_config() { read -p "Name (unique identifier, e.g., 'SSO'): " name read -p "Display Name (e.g., 'Company SSO'): " display_name # Escape for JSON and export for caller name=$(printf '%s' "$name" | jq -Rs .) display_name=$(printf '%s' "$display_name" | jq -Rs .) echo "$name|$display_name" } # Reads provider-specific configuration based on JSON field definitions # $1: JSON array of fields read_provider_config() { local fields_json="$1" local json_fields="" local field_count=$(echo "$fields_json" | jq 'length') for ((i=0; i