Skip to content

Commit 259c75b

Browse files
feat: Add health check and auto-reauth controls for managed auth connections
1 parent 6f9e3d9 commit 259c75b

3 files changed

Lines changed: 101 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/resources/auth/connections.ts

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,17 @@ export interface ManagedAuth {
250250
*/
251251
allowed_domains?: Array<string>;
252252

253+
/**
254+
* Whether automatic re-authentication is permitted for this connection. This is an
255+
* opt-in flag only — it does not check whether re-auth is actually feasible. Even
256+
* when true, re-auth only runs when the system has what it needs to perform it
257+
* (for example, saved credentials for the required login fields), and only after a
258+
* scheduled health check detects an expired session — so this flag has no effect
259+
* when `health_checks` is false. When false, expired sessions detected by a health
260+
* check are marked as `NEEDS_AUTH` instead of attempting re-auth.
261+
*/
262+
auto_reauth?: boolean;
263+
253264
/**
254265
* ID of the underlying browser session driving the current flow (present when flow
255266
* in progress). Use this to inspect or terminate the browser session via the
@@ -337,6 +348,15 @@ export interface ManagedAuth {
337348
*/
338349
health_check_interval?: number | null;
339350

351+
/**
352+
* Whether periodic health checks are enabled for this connection. When false, the
353+
* system will not automatically verify authentication status, and `auto_reauth`
354+
* has no effect on the automatic flow (since re-auth is only triggered by a failed
355+
* scheduled health check). Manually triggering a health check via the API still
356+
* works regardless of this setting.
357+
*/
358+
health_checks?: boolean;
359+
340360
/**
341361
* URL to redirect user to for hosted login (present when flow in progress)
342362
*/
@@ -591,6 +611,18 @@ export interface ManagedAuthCreateRequest {
591611
*/
592612
allowed_domains?: Array<string>;
593613

614+
/**
615+
* Whether to permit automatic re-authentication when a scheduled health check
616+
* detects an expired session. This is an opt-in flag only — it does not check
617+
* whether re-auth is actually feasible. Even when true, re-auth only runs when the
618+
* system has what it needs to perform it (for example, saved credentials for the
619+
* required login fields), and only after a scheduled health check detects an
620+
* expired session — so this flag has no effect when `health_checks` is false. When
621+
* false, expired sessions are marked as `NEEDS_AUTH` instead of attempting
622+
* re-auth. Defaults to true.
623+
*/
624+
auto_reauth?: boolean;
625+
594626
/**
595627
* Reference to credentials for the auth connection. Use one of:
596628
*
@@ -609,6 +641,14 @@ export interface ManagedAuthCreateRequest {
609641
*/
610642
health_check_interval?: number;
611643

644+
/**
645+
* Whether to enable periodic health checks. When false, the system will not
646+
* automatically verify authentication status, and `auto_reauth` has no effect on
647+
* the automatic flow (since re-auth is only triggered by a failed scheduled health
648+
* check). Defaults to true.
649+
*/
650+
health_checks?: boolean;
651+
612652
/**
613653
* Optional login page URL to skip discovery
614654
*/
@@ -689,6 +729,17 @@ export interface ManagedAuthUpdateRequest {
689729
*/
690730
allowed_domains?: Array<string>;
691731

732+
/**
733+
* Whether automatic re-authentication is permitted for this connection. This is an
734+
* opt-in flag only — it does not check whether re-auth is actually feasible. Even
735+
* when true, re-auth only runs when the system has what it needs to perform it
736+
* (for example, saved credentials for the required login fields), and only after a
737+
* scheduled health check detects an expired session — so this flag has no effect
738+
* when `health_checks` is false. When false, expired sessions detected by a health
739+
* check are marked as `NEEDS_AUTH` instead of attempting re-auth.
740+
*/
741+
auto_reauth?: boolean;
742+
692743
/**
693744
* Reference to credentials for the auth connection. Use one of:
694745
*
@@ -703,6 +754,14 @@ export interface ManagedAuthUpdateRequest {
703754
*/
704755
health_check_interval?: number;
705756

757+
/**
758+
* Whether periodic health checks are enabled. When set to false, the system will
759+
* not automatically verify authentication status, and `auto_reauth` has no effect
760+
* on the automatic flow (since re-auth is only triggered by a failed scheduled
761+
* health check).
762+
*/
763+
health_checks?: boolean;
764+
706765
/**
707766
* Login page URL. Set to empty string to clear.
708767
*/
@@ -1068,6 +1127,18 @@ export interface ConnectionCreateParams {
10681127
*/
10691128
allowed_domains?: Array<string>;
10701129

1130+
/**
1131+
* Whether to permit automatic re-authentication when a scheduled health check
1132+
* detects an expired session. This is an opt-in flag only — it does not check
1133+
* whether re-auth is actually feasible. Even when true, re-auth only runs when the
1134+
* system has what it needs to perform it (for example, saved credentials for the
1135+
* required login fields), and only after a scheduled health check detects an
1136+
* expired session — so this flag has no effect when `health_checks` is false. When
1137+
* false, expired sessions are marked as `NEEDS_AUTH` instead of attempting
1138+
* re-auth. Defaults to true.
1139+
*/
1140+
auto_reauth?: boolean;
1141+
10711142
/**
10721143
* Reference to credentials for the auth connection. Use one of:
10731144
*
@@ -1086,6 +1157,14 @@ export interface ConnectionCreateParams {
10861157
*/
10871158
health_check_interval?: number;
10881159

1160+
/**
1161+
* Whether to enable periodic health checks. When false, the system will not
1162+
* automatically verify authentication status, and `auto_reauth` has no effect on
1163+
* the automatic flow (since re-auth is only triggered by a failed scheduled health
1164+
* check). Defaults to true.
1165+
*/
1166+
health_checks?: boolean;
1167+
10891168
/**
10901169
* Optional login page URL to skip discovery
10911170
*/
@@ -1163,6 +1242,17 @@ export interface ConnectionUpdateParams {
11631242
*/
11641243
allowed_domains?: Array<string>;
11651244

1245+
/**
1246+
* Whether automatic re-authentication is permitted for this connection. This is an
1247+
* opt-in flag only — it does not check whether re-auth is actually feasible. Even
1248+
* when true, re-auth only runs when the system has what it needs to perform it
1249+
* (for example, saved credentials for the required login fields), and only after a
1250+
* scheduled health check detects an expired session — so this flag has no effect
1251+
* when `health_checks` is false. When false, expired sessions detected by a health
1252+
* check are marked as `NEEDS_AUTH` instead of attempting re-auth.
1253+
*/
1254+
auto_reauth?: boolean;
1255+
11661256
/**
11671257
* Reference to credentials for the auth connection. Use one of:
11681258
*
@@ -1177,6 +1267,14 @@ export interface ConnectionUpdateParams {
11771267
*/
11781268
health_check_interval?: number;
11791269

1270+
/**
1271+
* Whether periodic health checks are enabled. When set to false, the system will
1272+
* not automatically verify authentication status, and `auto_reauth` has no effect
1273+
* on the automatic flow (since re-auth is only triggered by a failed scheduled
1274+
* health check).
1275+
*/
1276+
health_checks?: boolean;
1277+
11801278
/**
11811279
* Login page URL. Set to empty string to clear.
11821280
*/

tests/api-resources/auth/connections.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@ describe('resource connections', () => {
2929
domain: 'netflix.com',
3030
profile_name: 'user-123',
3131
allowed_domains: ['login.netflix.com', 'auth.netflix.com'],
32+
auto_reauth: true,
3233
credential: {
3334
auto: true,
3435
name: 'my-netflix-creds',
3536
path: 'Personal/Netflix',
3637
provider: 'my-1p',
3738
},
3839
health_check_interval: 3600,
40+
health_checks: true,
3941
login_url: 'https://netflix.com/login',
4042
proxy: { id: 'id', name: 'name' },
4143
record_session: false,

0 commit comments

Comments
 (0)