-
Notifications
You must be signed in to change notification settings - Fork 7
284 task create bootstrap scripts for thunder #292
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
Changes from all commits
0fcdfa1
840c739
4fdf6e3
506494d
4fbaa87
6153a0a
95eca3e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| echo "Overwriting the default sample resources creation script with empty content..." |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -18,11 +18,11 @@ var ( | |||||
| thunderAuthMutex sync.RWMutex | ||||||
| ) | ||||||
|
|
||||||
| // getSampleAppIDFromThunderSetup extracts Sample App ID from thunder-setup container | ||||||
| func getSampleAppIDFromThunderSetup() (string, error) { | ||||||
| log.Printf(" β Extracting Sample App ID from thunder-setup container...") | ||||||
| // getDevelopAppIDFromThunderSetup extracts DEVELOP App ID from thunder-setup container | ||||||
| func getDevelopAppIDFromThunderSetup() (string, error) { | ||||||
| log.Printf(" β Extracting DEVELOP_APP_ID from thunder-setup container...") | ||||||
|
|
||||||
| // Execute: docker logs thunder-setup 2>&1 | grep 'Sample App ID:' | head -n1 | ||||||
| // Execute: docker logs thunder-setup 2>&1 | grep 'DEVELOP_APP_ID:' | head -n1 | ||||||
| cmd := exec.Command("docker", "logs", "thunder-setup") | ||||||
| output, err := cmd.CombinedOutput() | ||||||
| if err != nil { | ||||||
|
|
@@ -38,52 +38,54 @@ func getSampleAppIDFromThunderSetup() (string, error) { | |||||
| log.Printf(" β - Running inside a container without Docker socket") | ||||||
| } | ||||||
|
|
||||||
| // Search for "Sample App ID:" in logs (case-insensitive) | ||||||
| // Search for "DEVELOP_APP_ID:" in logs | ||||||
| // Log format: [INFO] DEVELOP_APP_ID: 019cdc47-3537-74ee-951e-3f50e48786ab | ||||||
| lines := strings.Split(string(output), "\n") | ||||||
| for _, line := range lines { | ||||||
| if strings.Contains(line, "Sample App ID:") { | ||||||
| // Look for line containing DEVELOP_APP_ID (case-insensitive) | ||||||
| if strings.Contains(line, "DEVELOP_APP_ID") || strings.Contains(line, "develop_app_id") { | ||||||
| // Extract UUID pattern: [a-f0-9-]{36} | ||||||
| re := regexp.MustCompile(`[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}`) | ||||||
| match := re.FindString(line) | ||||||
| if match != "" { | ||||||
| log.Printf(" β β Sample App ID extracted: %s", match) | ||||||
| log.Printf(" β β DEVELOP_APP_ID extracted: %s", match) | ||||||
| return match, nil | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| return "", fmt.Errorf("Sample App ID not found in thunder-setup logs") | ||||||
| return "", fmt.Errorf("DEVELOP_APP_ID not found in thunder-setup logs") | ||||||
| } | ||||||
|
|
||||||
| // Authenticate performs the full authentication flow with Thunder IDP | ||||||
| func Authenticate(host, port string, tokenRefreshSeconds int) (*Auth, error) { | ||||||
| log.Printf(" ββ Thunder Authentication βββββββββ") | ||||||
|
|
||||||
| // Step 1: Get Sample App ID | ||||||
| sampleAppID := os.Getenv("THUNDER_SAMPLE_APP_ID") | ||||||
| // Step 1: Get DEVELOP App ID | ||||||
| developAppID := os.Getenv("THUNDER_DEVELOP_APP_ID") | ||||||
|
|
||||||
| if sampleAppID != "" { | ||||||
| log.Printf(" β Using Sample App ID from environment variable") | ||||||
| log.Printf(" β Sample App ID: %s", sampleAppID) | ||||||
| if developAppID != "" { | ||||||
| log.Printf(" β Using DEVELOP App ID from environment variable") | ||||||
| log.Printf(" β DEVELOP_APP_ID: %s", developAppID) | ||||||
| } else { | ||||||
| log.Printf(" β THUNDER_SAMPLE_APP_ID not set") | ||||||
| log.Printf(" β THUNDER_DEVELOP_APP_ID not set") | ||||||
| log.Printf(" β Attempting to extract from thunder-setup container logs...") | ||||||
|
|
||||||
| var err error | ||||||
| sampleAppID, err = getSampleAppIDFromThunderSetup() | ||||||
| developAppID, err = getDevelopAppIDFromThunderSetup() | ||||||
| if err != nil { | ||||||
| log.Printf(" β β Failed to extract Sample App ID: %v", err) | ||||||
| log.Printf(" β β Failed to extract DEVELOP_APP_ID: %v", err) | ||||||
| log.Printf(" β") | ||||||
| log.Printf(" β Please ensure Thunder setup container has completed successfully") | ||||||
| log.Printf(" β") | ||||||
| log.Printf(" β To fix this issue:") | ||||||
| log.Printf(" β 1. Check thunder-setup logs: docker logs thunder-setup") | ||||||
| log.Printf(" β 2. Extract App ID manually and set environment:") | ||||||
| log.Printf(" β export THUNDER_SAMPLE_APP_ID=$(docker logs thunder-setup 2>&1 | grep 'Sample App ID:' | grep -o '[a-f0-9-]\\{36\\}')") | ||||||
| log.Printf(" β export THUNDER_DEVELOP_APP_ID=$(docker logs thunder-setup 2>&1 | grep 'DEVELOP_APP_ID:' | grep -o '[a-f0-9-]\\{36\\}')") | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The example command in the error log for manually extracting the
Suggested change
|
||||||
| log.Printf(" β 3. Or if running in Docker, mount the Docker socket:") | ||||||
| log.Printf(" β volumes: ['/var/run/docker.sock:/var/run/docker.sock']") | ||||||
| log.Printf(" ββββββββββββββββββββββββββββββββββββ") | ||||||
| return nil, fmt.Errorf("failed to get Sample App ID: %w", err) | ||||||
| return nil, fmt.Errorf("failed to get DEVELOP App ID: %w", err) | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -93,7 +95,7 @@ func Authenticate(host, port string, tokenRefreshSeconds int) (*Auth, error) { | |||||
| // Step 2: Start authentication flow | ||||||
| log.Printf(" β Starting authentication flow...") | ||||||
| flowPayload := map[string]interface{}{ | ||||||
| "applicationId": sampleAppID, | ||||||
| "applicationId": developAppID, | ||||||
| "flowType": "AUTHENTICATION", | ||||||
| } | ||||||
| flowData, err := json.Marshal(flowPayload) | ||||||
|
|
@@ -164,7 +166,7 @@ func Authenticate(host, port string, tokenRefreshSeconds int) (*Auth, error) { | |||||
| log.Printf(" ββββββββββββββββββββββββββββββββββββ") | ||||||
|
|
||||||
| auth := &Auth{ | ||||||
| SampleAppID: sampleAppID, | ||||||
| DevelopAppID: developAppID, | ||||||
| FlowID: flowResp.FlowID, | ||||||
| BearerToken: authResp.Assertion, | ||||||
| ExpiresAt: time.Now().Add(time.Duration(tokenRefreshSeconds) * time.Second), | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The regex used to extract the
DEVELOP_APP_IDis a bit loose ([a-f0-9-]\{36\}). For better robustness and consistency with the Go code in this PR, I recommend using a more specific UUID regex.