Skip to content

Commit c9a6c75

Browse files
feat(api): type can_reauth_reason as an enum on ManagedAuth
1 parent bfd4043 commit c9a6c75

2 files changed

Lines changed: 56 additions & 7 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 113
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel/kernel-a9c7e806132001dbfbd4e8ae6c7d0935e503f457d63385fc800c862e3d064375.yml
3-
openapi_spec_hash: b048dcb0c5401bc0a301c3d30cb8ecba
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel/kernel-2118a79fa452fad5922776130ea4877059e9568b603ef146171b7bb6a0f8458a.yml
3+
openapi_spec_hash: 686e8c5855ed88b2944b9d9ec21d22ce
44
config_hash: 37661d89120558d34b6cc184292632f2

src/kernel/types/auth/managed_auth.py

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,61 @@ class ManagedAuth(BaseModel):
187187

188188
can_reauth: Optional[bool] = None
189189
"""
190-
Whether automatic re-authentication is possible (has credential, selectors, and
191-
login_url)
190+
Whether Kernel can automatically re-authenticate this connection when the
191+
session expires. Requires a prior successful login plus either a Kernel
192+
credential or an external credential reference. See `can_reauth_reason` for the
193+
specific outcome.
194+
"""
195+
196+
can_reauth_reason: Optional[
197+
Literal[
198+
"external_credential",
199+
"cua_has_credential",
200+
"has_credential",
201+
"viable_plans_found",
202+
"no_requirements_recorded",
203+
"requirements_satisfiable",
204+
"no_prior_successful_login",
205+
"no_credential",
206+
"no_viable_plans",
207+
"viable_plans_require_external_action",
208+
"requires_external_action",
209+
"requires_totp_without_secret",
210+
"requires_sms_code",
211+
"requires_email_code",
212+
]
213+
] = None
214+
"""
215+
Machine-readable reason for the current value of `can_reauth`. Affirmative
216+
values (re-auth is possible):
217+
218+
- `external_credential` — an external credential provider is attached
219+
- `cua_has_credential` — CUA flow with a stored credential
220+
- `has_credential` — Kernel credential is attached (optimistic; plan viability
221+
not checked)
222+
- `viable_plans_found` — at least one stored login plan can be replayed
223+
- `no_requirements_recorded` — no recorded credential requirements to fail
224+
against
225+
- `requirements_satisfiable` — recorded requirements can be met by the attached
226+
credential
227+
228+
Negative values (a human must complete the login flow):
229+
230+
- `no_prior_successful_login` — connection has never completed a successful
231+
login
232+
- `no_credential` — no Kernel or external credential attached
233+
- `no_viable_plans` — credential attached but no replayable login plan exists
234+
yet
235+
- `viable_plans_require_external_action` — stored plans need an external step
236+
(email link, push, etc.)
237+
- `requires_external_action` — recorded requirements include an external step
238+
- `requires_totp_without_secret` — flow needs a TOTP code but no TOTP secret is
239+
stored
240+
- `requires_sms_code` — flow needs an SMS code that cannot be received
241+
automatically
242+
- `requires_email_code` — flow needs an email code that cannot be received
243+
automatically
192244
"""
193-
194-
can_reauth_reason: Optional[str] = None
195-
"""Reason why automatic re-authentication is or is not possible"""
196245

197246
credential: Optional[Credential] = None
198247
"""Reference to credentials for the auth connection. Use one of:

0 commit comments

Comments
 (0)