Pin Vercel OAuth callback team parameter name
The Vercel connector reads the team from the camelCase teamId callback parameter, unlike the snake_case params most providers use. Nothing guarded the name, so a regression back to team_id would silently drop the team on every Vercel connect and leave the source resolving no users. Extract the read into vercelCallbackTeamID and pin the exact parameter name with a test, since the surrounding handler needs a live connector registry and database to exercise directly. Signed-off-by: Aurélien Sibiril <81782+aureliensibiril@users.noreply.github.com>
This commit is contained in:
@@ -372,7 +372,7 @@ func handleConnectorComplete(
|
||||
// sent — fall back to /v2/user.id as a synthetic TeamID; the v3
|
||||
// members endpoint accepts personal-account UIDs.
|
||||
if connectorProvider == coredata.ConnectorProviderVercel {
|
||||
teamID := query.Get("teamId")
|
||||
teamID := vercelCallbackTeamID(query)
|
||||
if teamID == "" {
|
||||
if oauth2Conn, ok := connection.(*connector.OAuth2Connection); ok && oauth2Conn.AccessToken != "" {
|
||||
if uid, err := connector.FetchVercelUserID(r.Context(), oauth2Conn.AccessToken); err == nil {
|
||||
@@ -476,6 +476,14 @@ func handleConnectorOAuth2Error(
|
||||
safeRedirect.Redirect(w, r, parsedURL.String(), "/", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
// vercelCallbackTeamID returns the team identifier Vercel surfaces on the
|
||||
// OAuth callback. Vercel uses the camelCase `teamId` query parameter (not the
|
||||
// snake_case `team_id` most other params use); the name is pinned by a test so
|
||||
// it cannot silently regress and leave every Vercel source without a team.
|
||||
func vercelCallbackTeamID(query url.Values) string {
|
||||
return query.Get("teamId")
|
||||
}
|
||||
|
||||
// isValidPagerDutySubdomain reports whether s is a single DNS label
|
||||
// (RFC 1035 §2.3.1). PagerDuty subdomains are tenant identifiers that
|
||||
// will be embedded in API URLs; the OAuth callback is the only place
|
||||
|
||||
Reference in New Issue
Block a user