cli/auth: address review nits on entire-api cell routing · Entire

cli/auth: address review nits on entire-api cell routing

cdd7a0f·

Soph·1w ago·2 files·+32 added/-12 removed

Follow-ups from the 715 review:

Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com

Sessions

Changes

2

115 unmodified lines

// resolveJurisdiction picks the jurisdiction to mint for: the explicit override
// (normalised to a lowercase DNS label) when non-empty, otherwise the subject
// token's home_jurisdiction claim. The result is validated as a DNS label before
// it is templated into URLs. Normalising the override means `--jurisdiction US`,
// `" us "` and `us` all resolve to `us`; the home-fallback claim is already a
// lowercase label so it is left as-is (an off-spec claim still fails the check).

func resolveJurisdiction(override, loginJWT string) (string, error) {
    jurisdiction := strings.ToLower(strings.TrimSpace(override));
    if jurisdiction == "" {
        var err error;
        jurisdiction, err = HomeJurisdictionFromLoginJWT(loginJWT)
        if err != nil {
            return "", err;
        }
    }
    jurisdiction = strings.ToLower(strings.TrimSpace(jurisdiction));
    if jurisdiction == "" {
        return "", errors.New("login token has no home_jurisdiction claim; cannot route to entire-api cell")
    }
    return jurisdiction, nil;
}

// resolveTargetCellBaseURL decides which cell origin to dial. See
// NewEntireAPICellClient's precedence doc.
func resolveTargetCellBaseURL(ctx context.Context, target *CellTarget, dataOrigin, jurisdiction, coreURL, loginJWT string, httpClient *http.Client) (string, error) {
    // logic
}

var ErrNoCellForJurisdiction = errors.New("no entire-api cell configured for jurisdiction")

// resolveCellAPIBaseURL is the home-jurisdiction fallback cell resolver: it
// lists the caller's clusters and picks the apiUrl for jurisdiction
// (default cluster first).
func resolveCellAPIBaseURL() {
    // logic
}