-
Notifications
You must be signed in to change notification settings - Fork 0
Add partner staging authorization script and guide #32
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
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,50 @@ | ||||||||||||||||||||||||
| #!/usr/bin/env bash | ||||||||||||||||||||||||
| # Authorize a Silverfin partner api_key against an isolated throwaway HOME, | ||||||||||||||||||||||||
| # then push the resulting config.json straight to a market repo's | ||||||||||||||||||||||||
| # PARTNER_CONFIG_JSON_<partner_id> GitHub secret. Cleans up after itself. | ||||||||||||||||||||||||
| # | ||||||||||||||||||||||||
| # Usage: | ||||||||||||||||||||||||
| # ./authorize-partner-secret.sh <partner_id> <market> [host] | ||||||||||||||||||||||||
| # | ||||||||||||||||||||||||
| # <market> is either a short code (nl, be, lu, uk) or a full "owner/repo". | ||||||||||||||||||||||||
| # | ||||||||||||||||||||||||
| # Examples: | ||||||||||||||||||||||||
| # ./authorize-partner-secret.sh 2 nl | ||||||||||||||||||||||||
| # ./authorize-partner-secret.sh 11 lu | ||||||||||||||||||||||||
| # ./authorize-partner-secret.sh 1 silverfin/be_market | ||||||||||||||||||||||||
| # | ||||||||||||||||||||||||
| # Prompts for the api_key with hidden input (never as an argv, so it never | ||||||||||||||||||||||||
| # lands in shell history). Re-run once per partner after each staging reset. | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| set -euo pipefail | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| declare -A MARKET_REPOS=( | ||||||||||||||||||||||||
| [nl]="silverfin/nl_market" | ||||||||||||||||||||||||
| [be]="silverfin/be_market" | ||||||||||||||||||||||||
| [lu]="silverfin/lu_market" | ||||||||||||||||||||||||
| [uk]="silverfin/uk_market" | ||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| PARTNER_ID="${1:?Usage: $0 <partner_id> <market> [host]}" | ||||||||||||||||||||||||
| MARKET="${2:?Usage: $0 <partner_id> <market> [host]}" | ||||||||||||||||||||||||
| HOST="${3:-https://bso-staging-beta.staging.getsilverfin.com}" | ||||||||||||||||||||||||
|
Comment on lines
+28
to
+30
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. π― Functional Correctness | π‘ Minor | β‘ Quick win Reject non-numeric partner IDs before authorization. The README defines Proposed fix PARTNER_ID="${1:?Usage: $0 <partner_id> <market> [host]}"
MARKET="${2:?Usage: $0 <partner_id> <market> [host]}"
HOST="${3:-https://bso-staging-beta.staging.getsilverfin.com}"
+
+if [[ ! "$PARTNER_ID" =~ ^[0-9]+$ ]]; then
+ printf '%s\n' "partner_id must be numeric" >&2
+ exit 2
+fiπ Committable suggestion
Suggested change
π€ Prompt for AI Agents |
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if [[ -n "${MARKET_REPOS[$MARKET]:-}" ]]; then | ||||||||||||||||||||||||
| REPO="${MARKET_REPOS[$MARKET]}" | ||||||||||||||||||||||||
| else | ||||||||||||||||||||||||
| REPO="$MARKET" | ||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| printf '%s' "API key for partner ${PARTNER_ID} (${REPO}): " | ||||||||||||||||||||||||
| read -rs API_KEY | ||||||||||||||||||||||||
| echo | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| TMP_HOME=$(mktemp -d) | ||||||||||||||||||||||||
| trap 'rm -rf "$TMP_HOME"' EXIT | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| HOME="$TMP_HOME" silverfin config --set-host "$HOST" | ||||||||||||||||||||||||
| HOME="$TMP_HOME" silverfin authorize-partner -i "$PARTNER_ID" -k "$API_KEY" -n "partner-${PARTNER_ID}" | ||||||||||||||||||||||||
|
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. π Security & Privacy | π Major | β‘ Quick win π§© Analysis chainπ Script executed: #!/bin/bash
set -euo pipefail
printf 'Inspecting relevant files...\n'
git ls-files scripts/authorize-partner-secret.sh README.md
printf '\n--- scripts/authorize-partner-secret.sh ---\n'
cat -n scripts/authorize-partner-secret.sh | sed -n '1,120p'
printf '\n--- README.md excerpt ---\n'
cat -n README.md | sed -n '300,330p'
printf '\n--- Searching for authorize-partner usage and supported input paths ---\n'
rg -n --hidden --no-messages 'authorize-partner|api_key|hidden input|stdin|env|secret' .Repository: silverfin/bso_github_actions Length of output: 24668 π Web query:
π‘ Result: The Silverfin CLI does not have a native "authorize-partner" command that accepts an API key via stdin or environment variables as a single automated step [1][2]. Authorization for the Silverfin CLI is handled through the Citations:
Avoid claiming the API key stays out of argv.
π Affects 2 files
π€ Prompt for AI Agents |
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| gh secret set "PARTNER_CONFIG_JSON_${PARTNER_ID}" --repo "$REPO" < "$TMP_HOME/.silverfin/config.json" | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| echo "Done: PARTNER_CONFIG_JSON_${PARTNER_ID} updated on ${REPO}." | ||||||||||||||||||||||||
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.
ποΈ Data Integrity & Integration | π‘ Minor | β‘ Quick win
Clarify the bootstrap exception to the βsole writerβ contract.
The README says the workflow is the sole writer, while this section says the script uploads the initial secret. State explicitly that this script bootstraps credentials and
run_sampler.ymlowns subsequent token-rotation writes.π€ Prompt for AI Agents