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
|
||||
|
||||
69
pkg/server/api/console/v1/resolver_test.go
Normal file
69
pkg/server/api/console/v1/resolver_test.go
Normal file
@@ -0,0 +1,69 @@
|
||||
// Copyright (c) 2026 Probo Inc <hello@probo.com>.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
package console_v1
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
// TestVercelCallbackTeamID pins the exact OAuth-callback query-parameter name
|
||||
// Vercel uses. It is camelCase `teamId`; a regression to the snake_case
|
||||
// `team_id` used by most other providers would silently drop the team on every
|
||||
// Vercel connect and leave the source resolving nobody.
|
||||
func TestVercelCallbackTeamID(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cases := []struct {
|
||||
name string
|
||||
query url.Values
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "camelCase teamId is read",
|
||||
query: url.Values{"teamId": {"team_abc123"}},
|
||||
want: "team_abc123",
|
||||
},
|
||||
{
|
||||
name: "snake_case team_id is ignored",
|
||||
query: url.Values{"team_id": {"team_abc123"}},
|
||||
want: "",
|
||||
},
|
||||
{
|
||||
name: "absent parameter yields empty",
|
||||
query: url.Values{},
|
||||
want: "",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
t.Run(
|
||||
tc.name,
|
||||
func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
assert.Equal(t, tc.want, vercelCallbackTeamID(tc.query))
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user