Skip to content

Commit 9a0655e

Browse files
feat: Add health check and auto-reauth controls for managed auth connections
1 parent 4f16fb0 commit 9a0655e

6 files changed

Lines changed: 140 additions & 1 deletion

File tree

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 112
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel/kernel-b7a19ff1fbd93322c8cffcd0b397ce2536ca8bff91594e0081bd030d4bec879f.yml
3-
openapi_spec_hash: 490520e6f0a8b1ebc89e9c0add46082d
3+
openapi_spec_hash: 9dd204b37a357b19032aea9eb4496645
44
config_hash: 08d55086449943a8fec212b870061a3f

src/kernel/resources/auth/connections.py

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,10 @@ def create(
6262
domain: str,
6363
profile_name: str,
6464
allowed_domains: SequenceNotStr[str] | Omit = omit,
65+
auto_reauth: bool | Omit = omit,
6566
credential: connection_create_params.Credential | Omit = omit,
6667
health_check_interval: int | Omit = omit,
68+
health_checks: bool | Omit = omit,
6769
login_url: str | Omit = omit,
6870
proxy: connection_create_params.Proxy | Omit = omit,
6971
record_session: bool | Omit = omit,
@@ -105,6 +107,15 @@ def create(
105107
- OneLogin: \\**.onelogin.com
106108
- Ping Identity: _.pingone.com, _.pingidentity.com
107109
110+
auto_reauth: Whether to permit automatic re-authentication when a scheduled health check
111+
detects an expired session. This is an opt-in flag only — it does not check
112+
whether re-auth is actually feasible. Even when true, re-auth only runs when the
113+
system has what it needs to perform it (for example, saved credentials for the
114+
required login fields), and only after a scheduled health check detects an
115+
expired session — so this flag has no effect when `health_checks` is false. When
116+
false, expired sessions are marked as `NEEDS_AUTH` instead of attempting
117+
re-auth. Defaults to true.
118+
108119
credential:
109120
Reference to credentials for the auth connection. Use one of:
110121
@@ -118,6 +129,11 @@ def create(
118129
depends on your plan: Enterprise: 300 (5 minutes), Startup: 1200 (20 minutes),
119130
Hobbyist: 3600 (1 hour).
120131
132+
health_checks: Whether to enable periodic health checks. When false, the system will not
133+
automatically verify authentication status, and `auto_reauth` has no effect on
134+
the automatic flow (since re-auth is only triggered by a failed scheduled health
135+
check). Defaults to true.
136+
121137
login_url: Optional login page URL to skip discovery
122138
123139
proxy: Proxy selection. Provide either id or name. The proxy must belong to the
@@ -144,8 +160,10 @@ def create(
144160
"domain": domain,
145161
"profile_name": profile_name,
146162
"allowed_domains": allowed_domains,
163+
"auto_reauth": auto_reauth,
147164
"credential": credential,
148165
"health_check_interval": health_check_interval,
166+
"health_checks": health_checks,
149167
"login_url": login_url,
150168
"proxy": proxy,
151169
"record_session": record_session,
@@ -199,8 +217,10 @@ def update(
199217
id: str,
200218
*,
201219
allowed_domains: SequenceNotStr[str] | Omit = omit,
220+
auto_reauth: bool | Omit = omit,
202221
credential: connection_update_params.Credential | Omit = omit,
203222
health_check_interval: int | Omit = omit,
223+
health_checks: bool | Omit = omit,
204224
login_url: str | Omit = omit,
205225
proxy: connection_update_params.Proxy | Omit = omit,
206226
record_session: bool | Omit = omit,
@@ -220,6 +240,14 @@ def update(
220240
Args:
221241
allowed_domains: Additional domains valid for this auth flow (replaces existing list)
222242
243+
auto_reauth: Whether automatic re-authentication is permitted for this connection. This is an
244+
opt-in flag only — it does not check whether re-auth is actually feasible. Even
245+
when true, re-auth only runs when the system has what it needs to perform it
246+
(for example, saved credentials for the required login fields), and only after a
247+
scheduled health check detects an expired session — so this flag has no effect
248+
when `health_checks` is false. When false, expired sessions detected by a health
249+
check are marked as `NEEDS_AUTH` instead of attempting re-auth.
250+
223251
credential:
224252
Reference to credentials for the auth connection. Use one of:
225253
@@ -229,6 +257,11 @@ def update(
229257
230258
health_check_interval: Interval in seconds between automatic health checks
231259
260+
health_checks: Whether periodic health checks are enabled. When set to false, the system will
261+
not automatically verify authentication status, and `auto_reauth` has no effect
262+
on the automatic flow (since re-auth is only triggered by a failed scheduled
263+
health check).
264+
232265
login_url: Login page URL. Set to empty string to clear.
233266
234267
proxy: Proxy selection. Provide either id or name. The proxy must belong to the
@@ -253,8 +286,10 @@ def update(
253286
body=maybe_transform(
254287
{
255288
"allowed_domains": allowed_domains,
289+
"auto_reauth": auto_reauth,
256290
"credential": credential,
257291
"health_check_interval": health_check_interval,
292+
"health_checks": health_checks,
258293
"login_url": login_url,
259294
"proxy": proxy,
260295
"record_session": record_session,
@@ -544,8 +579,10 @@ async def create(
544579
domain: str,
545580
profile_name: str,
546581
allowed_domains: SequenceNotStr[str] | Omit = omit,
582+
auto_reauth: bool | Omit = omit,
547583
credential: connection_create_params.Credential | Omit = omit,
548584
health_check_interval: int | Omit = omit,
585+
health_checks: bool | Omit = omit,
549586
login_url: str | Omit = omit,
550587
proxy: connection_create_params.Proxy | Omit = omit,
551588
record_session: bool | Omit = omit,
@@ -587,6 +624,15 @@ async def create(
587624
- OneLogin: \\**.onelogin.com
588625
- Ping Identity: _.pingone.com, _.pingidentity.com
589626
627+
auto_reauth: Whether to permit automatic re-authentication when a scheduled health check
628+
detects an expired session. This is an opt-in flag only — it does not check
629+
whether re-auth is actually feasible. Even when true, re-auth only runs when the
630+
system has what it needs to perform it (for example, saved credentials for the
631+
required login fields), and only after a scheduled health check detects an
632+
expired session — so this flag has no effect when `health_checks` is false. When
633+
false, expired sessions are marked as `NEEDS_AUTH` instead of attempting
634+
re-auth. Defaults to true.
635+
590636
credential:
591637
Reference to credentials for the auth connection. Use one of:
592638
@@ -600,6 +646,11 @@ async def create(
600646
depends on your plan: Enterprise: 300 (5 minutes), Startup: 1200 (20 minutes),
601647
Hobbyist: 3600 (1 hour).
602648
649+
health_checks: Whether to enable periodic health checks. When false, the system will not
650+
automatically verify authentication status, and `auto_reauth` has no effect on
651+
the automatic flow (since re-auth is only triggered by a failed scheduled health
652+
check). Defaults to true.
653+
603654
login_url: Optional login page URL to skip discovery
604655
605656
proxy: Proxy selection. Provide either id or name. The proxy must belong to the
@@ -626,8 +677,10 @@ async def create(
626677
"domain": domain,
627678
"profile_name": profile_name,
628679
"allowed_domains": allowed_domains,
680+
"auto_reauth": auto_reauth,
629681
"credential": credential,
630682
"health_check_interval": health_check_interval,
683+
"health_checks": health_checks,
631684
"login_url": login_url,
632685
"proxy": proxy,
633686
"record_session": record_session,
@@ -681,8 +734,10 @@ async def update(
681734
id: str,
682735
*,
683736
allowed_domains: SequenceNotStr[str] | Omit = omit,
737+
auto_reauth: bool | Omit = omit,
684738
credential: connection_update_params.Credential | Omit = omit,
685739
health_check_interval: int | Omit = omit,
740+
health_checks: bool | Omit = omit,
686741
login_url: str | Omit = omit,
687742
proxy: connection_update_params.Proxy | Omit = omit,
688743
record_session: bool | Omit = omit,
@@ -702,6 +757,14 @@ async def update(
702757
Args:
703758
allowed_domains: Additional domains valid for this auth flow (replaces existing list)
704759
760+
auto_reauth: Whether automatic re-authentication is permitted for this connection. This is an
761+
opt-in flag only — it does not check whether re-auth is actually feasible. Even
762+
when true, re-auth only runs when the system has what it needs to perform it
763+
(for example, saved credentials for the required login fields), and only after a
764+
scheduled health check detects an expired session — so this flag has no effect
765+
when `health_checks` is false. When false, expired sessions detected by a health
766+
check are marked as `NEEDS_AUTH` instead of attempting re-auth.
767+
705768
credential:
706769
Reference to credentials for the auth connection. Use one of:
707770
@@ -711,6 +774,11 @@ async def update(
711774
712775
health_check_interval: Interval in seconds between automatic health checks
713776
777+
health_checks: Whether periodic health checks are enabled. When set to false, the system will
778+
not automatically verify authentication status, and `auto_reauth` has no effect
779+
on the automatic flow (since re-auth is only triggered by a failed scheduled
780+
health check).
781+
714782
login_url: Login page URL. Set to empty string to clear.
715783
716784
proxy: Proxy selection. Provide either id or name. The proxy must belong to the
@@ -735,8 +803,10 @@ async def update(
735803
body=await async_maybe_transform(
736804
{
737805
"allowed_domains": allowed_domains,
806+
"auto_reauth": auto_reauth,
738807
"credential": credential,
739808
"health_check_interval": health_check_interval,
809+
"health_checks": health_checks,
740810
"login_url": login_url,
741811
"proxy": proxy,
742812
"record_session": record_session,

src/kernel/types/auth/connection_create_params.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@ class ConnectionCreateParams(TypedDict, total=False):
4040
- Ping Identity: _.pingone.com, _.pingidentity.com
4141
"""
4242

43+
auto_reauth: bool
44+
"""
45+
Whether to permit automatic re-authentication when a scheduled health check
46+
detects an expired session. This is an opt-in flag only — it does not check
47+
whether re-auth is actually feasible. Even when true, re-auth only runs when the
48+
system has what it needs to perform it (for example, saved credentials for the
49+
required login fields), and only after a scheduled health check detects an
50+
expired session — so this flag has no effect when `health_checks` is false. When
51+
false, expired sessions are marked as `NEEDS_AUTH` instead of attempting
52+
re-auth. Defaults to true.
53+
"""
54+
4355
credential: Credential
4456
"""Reference to credentials for the auth connection. Use one of:
4557
@@ -57,6 +69,14 @@ class ConnectionCreateParams(TypedDict, total=False):
5769
Startup: 1200 (20 minutes), Hobbyist: 3600 (1 hour).
5870
"""
5971

72+
health_checks: bool
73+
"""Whether to enable periodic health checks.
74+
75+
When false, the system will not automatically verify authentication status, and
76+
`auto_reauth` has no effect on the automatic flow (since re-auth is only
77+
triggered by a failed scheduled health check). Defaults to true.
78+
"""
79+
6080
login_url: str
6181
"""Optional login page URL to skip discovery"""
6282

src/kernel/types/auth/connection_update_params.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@ class ConnectionUpdateParams(TypedDict, total=False):
1313
allowed_domains: SequenceNotStr[str]
1414
"""Additional domains valid for this auth flow (replaces existing list)"""
1515

16+
auto_reauth: bool
17+
"""Whether automatic re-authentication is permitted for this connection.
18+
19+
This is an opt-in flag only — it does not check whether re-auth is actually
20+
feasible. Even when true, re-auth only runs when the system has what it needs to
21+
perform it (for example, saved credentials for the required login fields), and
22+
only after a scheduled health check detects an expired session — so this flag
23+
has no effect when `health_checks` is false. When false, expired sessions
24+
detected by a health check are marked as `NEEDS_AUTH` instead of attempting
25+
re-auth.
26+
"""
27+
1628
credential: Credential
1729
"""Reference to credentials for the auth connection. Use one of:
1830
@@ -24,6 +36,14 @@ class ConnectionUpdateParams(TypedDict, total=False):
2436
health_check_interval: int
2537
"""Interval in seconds between automatic health checks"""
2638

39+
health_checks: bool
40+
"""Whether periodic health checks are enabled.
41+
42+
When set to false, the system will not automatically verify authentication
43+
status, and `auto_reauth` has no effect on the automatic flow (since re-auth is
44+
only triggered by a failed scheduled health check).
45+
"""
46+
2747
login_url: str
2848
"""Login page URL. Set to empty string to clear."""
2949

src/kernel/types/auth/managed_auth.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,18 @@ class ManagedAuth(BaseModel):
166166
- Ping Identity: _.pingone.com, _.pingidentity.com
167167
"""
168168

169+
auto_reauth: Optional[bool] = None
170+
"""Whether automatic re-authentication is permitted for this connection.
171+
172+
This is an opt-in flag only — it does not check whether re-auth is actually
173+
feasible. Even when true, re-auth only runs when the system has what it needs to
174+
perform it (for example, saved credentials for the required login fields), and
175+
only after a scheduled health check detects an expired session — so this flag
176+
has no effect when `health_checks` is false. When false, expired sessions
177+
detected by a health check are marked as `NEEDS_AUTH` instead of attempting
178+
re-auth.
179+
"""
180+
169181
browser_session_id: Optional[str] = None
170182
"""
171183
ID of the underlying browser session driving the current flow (present when flow
@@ -236,6 +248,15 @@ class ManagedAuth(BaseModel):
236248
Startup: 1200 (20 minutes), Hobbyist: 3600 (1 hour).
237249
"""
238250

251+
health_checks: Optional[bool] = None
252+
"""Whether periodic health checks are enabled for this connection.
253+
254+
When false, the system will not automatically verify authentication status, and
255+
`auto_reauth` has no effect on the automatic flow (since re-auth is only
256+
triggered by a failed scheduled health check). Manually triggering a health
257+
check via the API still works regardless of this setting.
258+
"""
259+
239260
hosted_url: Optional[str] = None
240261
"""URL to redirect user to for hosted login (present when flow in progress)"""
241262

tests/api_resources/auth/test_connections.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,15 @@ def test_method_create_with_all_params(self, client: Kernel) -> None:
3838
domain="netflix.com",
3939
profile_name="user-123",
4040
allowed_domains=["login.netflix.com", "auth.netflix.com"],
41+
auto_reauth=True,
4142
credential={
4243
"auto": True,
4344
"name": "my-netflix-creds",
4445
"path": "Personal/Netflix",
4546
"provider": "my-1p",
4647
},
4748
health_check_interval=3600,
49+
health_checks=True,
4850
login_url="https://netflix.com/login",
4951
proxy={
5052
"id": "id",
@@ -139,13 +141,15 @@ def test_method_update_with_all_params(self, client: Kernel) -> None:
139141
connection = client.auth.connections.update(
140142
id="id",
141143
allowed_domains=["login.netflix.com", "auth.netflix.com"],
144+
auto_reauth=True,
142145
credential={
143146
"auto": True,
144147
"name": "my-netflix-creds",
145148
"path": "Personal/Netflix",
146149
"provider": "my-1p",
147150
},
148151
health_check_interval=3600,
152+
health_checks=True,
149153
login_url="https://netflix.com/login",
150154
proxy={
151155
"id": "id",
@@ -447,13 +451,15 @@ async def test_method_create_with_all_params(self, async_client: AsyncKernel) ->
447451
domain="netflix.com",
448452
profile_name="user-123",
449453
allowed_domains=["login.netflix.com", "auth.netflix.com"],
454+
auto_reauth=True,
450455
credential={
451456
"auto": True,
452457
"name": "my-netflix-creds",
453458
"path": "Personal/Netflix",
454459
"provider": "my-1p",
455460
},
456461
health_check_interval=3600,
462+
health_checks=True,
457463
login_url="https://netflix.com/login",
458464
proxy={
459465
"id": "id",
@@ -548,13 +554,15 @@ async def test_method_update_with_all_params(self, async_client: AsyncKernel) ->
548554
connection = await async_client.auth.connections.update(
549555
id="id",
550556
allowed_domains=["login.netflix.com", "auth.netflix.com"],
557+
auto_reauth=True,
551558
credential={
552559
"auto": True,
553560
"name": "my-netflix-creds",
554561
"path": "Personal/Netflix",
555562
"provider": "my-1p",
556563
},
557564
health_check_interval=3600,
565+
health_checks=True,
558566
login_url="https://netflix.com/login",
559567
proxy={
560568
"id": "id",

0 commit comments

Comments
 (0)