Skip to content

Commit aac8ad2

Browse files
committed
feat(broker): implement skip_scope_on_auth to bypass strict provider scope validation
1 parent 195a649 commit aac8ad2

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

nexus-broker/pkg/handlers/consent.go

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,31 @@ func (h *ConsentHandler) buildAuthURL(providerAuthURL, clientID, state, codeChal
255255
return "", err
256256
}
257257

258+
skipScopeOnAuth := false
259+
if providerParams != nil {
260+
var paramsMap map[string]interface{}
261+
if err := json.Unmarshal(*providerParams, &paramsMap); err == nil {
262+
if skip, ok := paramsMap["skip_scope_on_auth"].(bool); ok {
263+
skipScopeOnAuth = skip
264+
}
265+
}
266+
}
267+
258268
q := u.Query()
259269
q.Set("client_id", clientID)
260270
q.Set("redirect_uri", baseURL+redirectPath)
261271
q.Set("response_type", "code")
262-
q.Set("scope", strings.Join(scopes, " "))
272+
273+
if !skipScopeOnAuth {
274+
if len(scopes) > 0 {
275+
q.Set("scope", strings.Join(scopes, " "))
276+
} else {
277+
// Backwards compatibility or provider defaults might expect an empty scope parameter,
278+
// but we only set it if not explicitly skipping.
279+
q.Set("scope", "")
280+
}
281+
}
282+
263283
q.Set("state", state)
264284
q.Set("code_challenge", codeChallenge)
265285
q.Set("code_challenge_method", "S256")

0 commit comments

Comments
 (0)