Allow provider selection for gateway OAuth reads and logins (#59819)

## Why

Gateway OAuth reads and logins previously used only the current provider, preventing clients from authorizing another configured provider without changing the default.

## What changed

- Add optional `modelProvider` params to `account/gatewayOAuth/read` and `account/gatewayOAuth/login`, preserving current-provider behavior for omitted or null params and selectors.
- Validate explicit providers against current managed policy without changing the default or any thread's provider.
- Retain readiness state across providers and send `account/gatewayOAuth/changed` notifications for every configured provider sharing the changed credential.
- Update protocol schemas, TypeScript types, Python models, and documentation.

## Testing

Add coverage for non-default provider login, retained readiness when alternating providers, notifications for shared credentials without starting login, and legacy TypeScript request compatibility.

GitOrigin-RevId: cfd472c322b821fe36b8c133a8de774f4ba48534
This commit is contained in:
Abhinav
2026-11-06 04:02:11 +00:00
committed by copyberry
parent a142c90e26
commit aece559654
22 changed files with 561 additions and 71 deletions
+42 -2
View File
@@ -1678,6 +1678,32 @@
],
"type": "object"
},
"GatewayOAuthLoginParams": {
"description": "Authorize a configured provider without changing the default or any thread's provider.",
"properties": {
"modelProvider": {
"description": "Defaults to the current provider when omitted.",
"type": [
"string",
"null"
]
}
},
"type": "object"
},
"GatewayOAuthReadParams": {
"description": "Read credential readiness for a configured provider without starting browser login.",
"properties": {
"modelProvider": {
"description": "Defaults to the current provider when omitted.",
"type": [
"string",
"null"
]
}
},
"type": "object"
},
"GcpProviderId": {
"enum": [
"gcp"
@@ -8185,7 +8211,14 @@
"type": "string"
},
"params": {
"type": "null"
"anyOf": [
{
"$ref": "#/definitions/GatewayOAuthReadParams"
},
{
"type": "null"
}
]
}
},
"required": [
@@ -8208,7 +8241,14 @@
"type": "string"
},
"params": {
"type": "null"
"anyOf": [
{
"$ref": "#/definitions/GatewayOAuthLoginParams"
},
{
"type": "null"
}
]
}
},
"required": [
@@ -1850,7 +1850,14 @@
"type": "string"
},
"params": {
"type": "null"
"anyOf": [
{
"$ref": "#/definitions/v2/GatewayOAuthReadParams"
},
{
"type": "null"
}
]
}
},
"required": [
@@ -1873,7 +1880,14 @@
"type": "string"
},
"params": {
"type": "null"
"anyOf": [
{
"$ref": "#/definitions/v2/GatewayOAuthLoginParams"
},
{
"type": "null"
}
]
}
},
"required": [
@@ -13177,11 +13191,37 @@
"title": "GatewayOAuthChangedNotification",
"type": "object"
},
"GatewayOAuthLoginParams": {
"description": "Authorize a configured provider without changing the default or any thread's provider.",
"properties": {
"modelProvider": {
"description": "Defaults to the current provider when omitted.",
"type": [
"string",
"null"
]
}
},
"type": "object"
},
"GatewayOAuthLoginResponse": {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "GatewayOAuthLoginResponse",
"type": "object"
},
"GatewayOAuthReadParams": {
"description": "Read credential readiness for a configured provider without starting browser login.",
"properties": {
"modelProvider": {
"description": "Defaults to the current provider when omitted.",
"type": [
"string",
"null"
]
}
},
"type": "object"
},
"GatewayOAuthReadResponse": {
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Current effective gateway policy and credential readiness; never contains credentials.",
@@ -16886,6 +16926,30 @@
],
"type": "string"
},
"NullableGatewayOAuthLoginParams": {
"$schema": "http://json-schema.org/draft-07/schema#",
"anyOf": [
{
"$ref": "#/definitions/v2/GatewayOAuthLoginParams"
},
{
"type": "null"
}
],
"title": "Nullable_GatewayOAuthLoginParams"
},
"NullableGatewayOAuthReadParams": {
"$schema": "http://json-schema.org/draft-07/schema#",
"anyOf": [
{
"$ref": "#/definitions/v2/GatewayOAuthReadParams"
},
{
"type": "null"
}
],
"title": "Nullable_GatewayOAuthReadParams"
},
"NullableGetAccountRateLimitsParams": {
"$schema": "http://json-schema.org/draft-07/schema#",
"anyOf": [
@@ -3594,7 +3594,14 @@
"type": "string"
},
"params": {
"type": "null"
"anyOf": [
{
"$ref": "#/definitions/GatewayOAuthReadParams"
},
{
"type": "null"
}
]
}
},
"required": [
@@ -3617,7 +3624,14 @@
"type": "string"
},
"params": {
"type": "null"
"anyOf": [
{
"$ref": "#/definitions/GatewayOAuthLoginParams"
},
{
"type": "null"
}
]
}
},
"required": [
@@ -9069,11 +9083,37 @@
"title": "GatewayOAuthChangedNotification",
"type": "object"
},
"GatewayOAuthLoginParams": {
"description": "Authorize a configured provider without changing the default or any thread's provider.",
"properties": {
"modelProvider": {
"description": "Defaults to the current provider when omitted.",
"type": [
"string",
"null"
]
}
},
"type": "object"
},
"GatewayOAuthLoginResponse": {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "GatewayOAuthLoginResponse",
"type": "object"
},
"GatewayOAuthReadParams": {
"description": "Read credential readiness for a configured provider without starting browser login.",
"properties": {
"modelProvider": {
"description": "Defaults to the current provider when omitted.",
"type": [
"string",
"null"
]
}
},
"type": "object"
},
"GatewayOAuthReadResponse": {
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Current effective gateway policy and credential readiness; never contains credentials.",
@@ -12847,6 +12887,30 @@
],
"type": "string"
},
"NullableGatewayOAuthLoginParams": {
"$schema": "http://json-schema.org/draft-07/schema#",
"anyOf": [
{
"$ref": "#/definitions/GatewayOAuthLoginParams"
},
{
"type": "null"
}
],
"title": "Nullable_GatewayOAuthLoginParams"
},
"NullableGatewayOAuthReadParams": {
"$schema": "http://json-schema.org/draft-07/schema#",
"anyOf": [
{
"$ref": "#/definitions/GatewayOAuthReadParams"
},
{
"type": "null"
}
],
"title": "Nullable_GatewayOAuthReadParams"
},
"NullableGetAccountRateLimitsParams": {
"$schema": "http://json-schema.org/draft-07/schema#",
"anyOf": [
@@ -0,0 +1,27 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"anyOf": [
{
"$ref": "#/definitions/GatewayOAuthLoginParams"
},
{
"type": "null"
}
],
"definitions": {
"GatewayOAuthLoginParams": {
"description": "Authorize a configured provider without changing the default or any thread's provider.",
"properties": {
"modelProvider": {
"description": "Defaults to the current provider when omitted.",
"type": [
"string",
"null"
]
}
},
"type": "object"
}
},
"title": "Nullable_GatewayOAuthLoginParams"
}
@@ -0,0 +1,27 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"anyOf": [
{
"$ref": "#/definitions/GatewayOAuthReadParams"
},
{
"type": "null"
}
],
"definitions": {
"GatewayOAuthReadParams": {
"description": "Read credential readiness for a configured provider without starting browser login.",
"properties": {
"modelProvider": {
"description": "Defaults to the current provider when omitted.",
"type": [
"string",
"null"
]
}
},
"type": "object"
}
},
"title": "Nullable_GatewayOAuthReadParams"
}
File diff suppressed because one or more lines are too long
@@ -0,0 +1,12 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
/**
* Authorize a configured provider without changing the default or any thread's provider.
*/
export type GatewayOAuthLoginParams = {
/**
* Defaults to the current provider when omitted.
*/
modelProvider?: string | null, };
@@ -0,0 +1,12 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
/**
* Read credential readiness for a configured provider without starting browser login.
*/
export type GatewayOAuthReadParams = {
/**
* Defaults to the current provider when omitted.
*/
modelProvider?: string | null, };
@@ -208,7 +208,9 @@ export type { FsWriteFileResponse } from "./FsWriteFileResponse";
export type { GatewayAuth } from "./GatewayAuth";
export type { GatewayOAuthCancelResponse } from "./GatewayOAuthCancelResponse";
export type { GatewayOAuthChangedNotification } from "./GatewayOAuthChangedNotification";
export type { GatewayOAuthLoginParams } from "./GatewayOAuthLoginParams";
export type { GatewayOAuthLoginResponse } from "./GatewayOAuthLoginResponse";
export type { GatewayOAuthReadParams } from "./GatewayOAuthReadParams";
export type { GatewayOAuthReadResponse } from "./GatewayOAuthReadResponse";
export type { GatewayOAuthStatus } from "./GatewayOAuthStatus";
export type { GcpProviderId } from "./GcpProviderId";