Skip to content

Commit 16049ed

Browse files
feat: [SCIM] Configurable token expiration duration
1 parent d335a93 commit 16049ed

7 files changed

Lines changed: 120 additions & 6 deletions

File tree

src/gitpod/resources/organizations/scim_configurations.py

Lines changed: 72 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def create(
6161
organization_id: str,
6262
sso_configuration_id: str,
6363
name: Optional[str] | Omit = omit,
64+
token_expires_in: Optional[str] | Omit = omit,
6465
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
6566
# The extra values given here take precedence over values defined on the client or passed to this method.
6667
extra_headers: Headers | None = None,
@@ -81,13 +82,24 @@ def create(
8182
8283
- Create basic SCIM configuration:
8384
84-
Creates a SCIM configuration linked to an SSO provider.
85+
Creates a SCIM configuration linked to an SSO provider with default 1 year
86+
token expiration.
8587
8688
```yaml
8789
organizationId: "b0e12f6c-4c67-429d-a4a6-d9838b5da047"
8890
ssoConfigurationId: "d2c94c27-3b76-4a42-b88c-95a85e392c68"
8991
```
9092
93+
- Create SCIM configuration with custom token expiration:
94+
95+
Creates a SCIM configuration with a 90-day token expiration.
96+
97+
```yaml
98+
organizationId: "b0e12f6c-4c67-429d-a4a6-d9838b5da047"
99+
ssoConfigurationId: "d2c94c27-3b76-4a42-b88c-95a85e392c68"
100+
tokenExpiresIn: "7776000s"
101+
```
102+
91103
Args:
92104
organization_id: organization_id is the ID of the organization to create the SCIM configuration
93105
for
@@ -97,6 +109,9 @@ def create(
97109
98110
name: name is a human-readable name for the SCIM configuration
99111
112+
token_expires_in: token_expires_in is the duration until the token expires. Defaults to 1 year.
113+
Minimum 1 day, maximum 2 years.
114+
100115
extra_headers: Send extra headers
101116
102117
extra_query: Add additional query parameters to the request
@@ -112,6 +127,7 @@ def create(
112127
"organization_id": organization_id,
113128
"sso_configuration_id": sso_configuration_id,
114129
"name": name,
130+
"token_expires_in": token_expires_in,
115131
},
116132
scim_configuration_create_params.ScimConfigurationCreateParams,
117133
),
@@ -373,6 +389,7 @@ def regenerate_token(
373389
self,
374390
*,
375391
scim_configuration_id: str,
392+
token_expires_in: Optional[str] | Omit = omit,
376393
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
377394
# The extra values given here take precedence over values defined on the client or passed to this method.
378395
extra_headers: Headers | None = None,
@@ -393,16 +410,29 @@ def regenerate_token(
393410
394411
- Regenerate token:
395412
396-
Creates a new bearer token, invalidating the old one.
413+
Creates a new bearer token with the same expiration duration as the previous
414+
token.
397415
398416
```yaml
399417
scimConfigurationId: "d2c94c27-3b76-4a42-b88c-95a85e392c68"
400418
```
401419
420+
- Regenerate token with new expiration:
421+
422+
Creates a new bearer token with a custom 180-day expiration.
423+
424+
```yaml
425+
scimConfigurationId: "d2c94c27-3b76-4a42-b88c-95a85e392c68"
426+
tokenExpiresIn: "15552000s"
427+
```
428+
402429
Args:
403430
scim_configuration_id: scim_configuration_id is the ID of the SCIM configuration to regenerate token
404431
for
405432
433+
token_expires_in: token_expires_in is the duration until the new token expires. If not specified,
434+
uses the same duration as the previous token.
435+
406436
extra_headers: Send extra headers
407437
408438
extra_query: Add additional query parameters to the request
@@ -414,7 +444,10 @@ def regenerate_token(
414444
return self._post(
415445
"/gitpod.v1.OrganizationService/RegenerateSCIMToken",
416446
body=maybe_transform(
417-
{"scim_configuration_id": scim_configuration_id},
447+
{
448+
"scim_configuration_id": scim_configuration_id,
449+
"token_expires_in": token_expires_in,
450+
},
418451
scim_configuration_regenerate_token_params.ScimConfigurationRegenerateTokenParams,
419452
),
420453
options=make_request_options(
@@ -450,6 +483,7 @@ async def create(
450483
organization_id: str,
451484
sso_configuration_id: str,
452485
name: Optional[str] | Omit = omit,
486+
token_expires_in: Optional[str] | Omit = omit,
453487
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
454488
# The extra values given here take precedence over values defined on the client or passed to this method.
455489
extra_headers: Headers | None = None,
@@ -470,13 +504,24 @@ async def create(
470504
471505
- Create basic SCIM configuration:
472506
473-
Creates a SCIM configuration linked to an SSO provider.
507+
Creates a SCIM configuration linked to an SSO provider with default 1 year
508+
token expiration.
474509
475510
```yaml
476511
organizationId: "b0e12f6c-4c67-429d-a4a6-d9838b5da047"
477512
ssoConfigurationId: "d2c94c27-3b76-4a42-b88c-95a85e392c68"
478513
```
479514
515+
- Create SCIM configuration with custom token expiration:
516+
517+
Creates a SCIM configuration with a 90-day token expiration.
518+
519+
```yaml
520+
organizationId: "b0e12f6c-4c67-429d-a4a6-d9838b5da047"
521+
ssoConfigurationId: "d2c94c27-3b76-4a42-b88c-95a85e392c68"
522+
tokenExpiresIn: "7776000s"
523+
```
524+
480525
Args:
481526
organization_id: organization_id is the ID of the organization to create the SCIM configuration
482527
for
@@ -486,6 +531,9 @@ async def create(
486531
487532
name: name is a human-readable name for the SCIM configuration
488533
534+
token_expires_in: token_expires_in is the duration until the token expires. Defaults to 1 year.
535+
Minimum 1 day, maximum 2 years.
536+
489537
extra_headers: Send extra headers
490538
491539
extra_query: Add additional query parameters to the request
@@ -501,6 +549,7 @@ async def create(
501549
"organization_id": organization_id,
502550
"sso_configuration_id": sso_configuration_id,
503551
"name": name,
552+
"token_expires_in": token_expires_in,
504553
},
505554
scim_configuration_create_params.ScimConfigurationCreateParams,
506555
),
@@ -762,6 +811,7 @@ async def regenerate_token(
762811
self,
763812
*,
764813
scim_configuration_id: str,
814+
token_expires_in: Optional[str] | Omit = omit,
765815
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
766816
# The extra values given here take precedence over values defined on the client or passed to this method.
767817
extra_headers: Headers | None = None,
@@ -782,16 +832,29 @@ async def regenerate_token(
782832
783833
- Regenerate token:
784834
785-
Creates a new bearer token, invalidating the old one.
835+
Creates a new bearer token with the same expiration duration as the previous
836+
token.
786837
787838
```yaml
788839
scimConfigurationId: "d2c94c27-3b76-4a42-b88c-95a85e392c68"
789840
```
790841
842+
- Regenerate token with new expiration:
843+
844+
Creates a new bearer token with a custom 180-day expiration.
845+
846+
```yaml
847+
scimConfigurationId: "d2c94c27-3b76-4a42-b88c-95a85e392c68"
848+
tokenExpiresIn: "15552000s"
849+
```
850+
791851
Args:
792852
scim_configuration_id: scim_configuration_id is the ID of the SCIM configuration to regenerate token
793853
for
794854
855+
token_expires_in: token_expires_in is the duration until the new token expires. If not specified,
856+
uses the same duration as the previous token.
857+
795858
extra_headers: Send extra headers
796859
797860
extra_query: Add additional query parameters to the request
@@ -803,7 +866,10 @@ async def regenerate_token(
803866
return await self._post(
804867
"/gitpod.v1.OrganizationService/RegenerateSCIMToken",
805868
body=await async_maybe_transform(
806-
{"scim_configuration_id": scim_configuration_id},
869+
{
870+
"scim_configuration_id": scim_configuration_id,
871+
"token_expires_in": token_expires_in,
872+
},
807873
scim_configuration_regenerate_token_params.ScimConfigurationRegenerateTokenParams,
808874
),
809875
options=make_request_options(

src/gitpod/types/organizations/scim_configuration.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ class ScimConfiguration(BaseModel):
2424
organization_id is the ID of the organization this SCIM configuration belongs to
2525
"""
2626

27+
token_expires_at: datetime = FieldInfo(alias="tokenExpiresAt")
28+
"""token_expires_at is when the current SCIM token expires"""
29+
2730
updated_at: datetime = FieldInfo(alias="updatedAt")
2831
"""updated_at is when the SCIM configuration was last updated"""
2932

src/gitpod/types/organizations/scim_configuration_create_params.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,9 @@ class ScimConfigurationCreateParams(TypedDict, total=False):
2525

2626
name: Optional[str]
2727
"""name is a human-readable name for the SCIM configuration"""
28+
29+
token_expires_in: Annotated[Optional[str], PropertyInfo(alias="tokenExpiresIn")]
30+
"""token_expires_in is the duration until the token expires. Defaults to 1 year.
31+
32+
Minimum 1 day, maximum 2 years.
33+
"""

src/gitpod/types/organizations/scim_configuration_create_response.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3+
from datetime import datetime
4+
35
from pydantic import Field as FieldInfo
46

57
from ..._models import BaseModel
@@ -17,3 +19,6 @@ class ScimConfigurationCreateResponse(BaseModel):
1719

1820
scim_configuration: ScimConfiguration = FieldInfo(alias="scimConfiguration")
1921
"""scim_configuration is the created SCIM configuration"""
22+
23+
token_expires_at: datetime = FieldInfo(alias="tokenExpiresAt")
24+
"""token_expires_at is when the token will expire"""

src/gitpod/types/organizations/scim_configuration_regenerate_token_params.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import annotations
44

5+
from typing import Optional
56
from typing_extensions import Required, Annotated, TypedDict
67

78
from ..._utils import PropertyInfo
@@ -15,3 +16,9 @@ class ScimConfigurationRegenerateTokenParams(TypedDict, total=False):
1516
scim_configuration_id is the ID of the SCIM configuration to regenerate token
1617
for
1718
"""
19+
20+
token_expires_in: Annotated[Optional[str], PropertyInfo(alias="tokenExpiresIn")]
21+
"""
22+
token_expires_in is the duration until the new token expires. If not specified,
23+
uses the same duration as the previous token.
24+
"""

src/gitpod/types/organizations/scim_configuration_regenerate_token_response.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3+
from datetime import datetime
4+
5+
from pydantic import Field as FieldInfo
6+
37
from ..._models import BaseModel
48

59
__all__ = ["ScimConfigurationRegenerateTokenResponse"]
@@ -11,3 +15,6 @@ class ScimConfigurationRegenerateTokenResponse(BaseModel):
1115
token is the new bearer token for SCIM API authentication. This invalidates the
1216
previous token - store it securely.
1317
"""
18+
19+
token_expires_at: datetime = FieldInfo(alias="tokenExpiresAt")
20+
"""token_expires_at is when the new token will expire"""

tests/api_resources/organizations/test_scim_configurations.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def test_method_create_with_all_params(self, client: Gitpod) -> None:
4040
organization_id="b0e12f6c-4c67-429d-a4a6-d9838b5da047",
4141
sso_configuration_id="d2c94c27-3b76-4a42-b88c-95a85e392c68",
4242
name="name",
43+
token_expires_in="+9125115.360s",
4344
)
4445
assert_matches_type(ScimConfigurationCreateResponse, scim_configuration, path=["response"])
4546

@@ -233,6 +234,15 @@ def test_method_regenerate_token(self, client: Gitpod) -> None:
233234
)
234235
assert_matches_type(ScimConfigurationRegenerateTokenResponse, scim_configuration, path=["response"])
235236

237+
@pytest.mark.skip(reason="Prism tests are disabled")
238+
@parametrize
239+
def test_method_regenerate_token_with_all_params(self, client: Gitpod) -> None:
240+
scim_configuration = client.organizations.scim_configurations.regenerate_token(
241+
scim_configuration_id="d2c94c27-3b76-4a42-b88c-95a85e392c68",
242+
token_expires_in="+9125115.360s",
243+
)
244+
assert_matches_type(ScimConfigurationRegenerateTokenResponse, scim_configuration, path=["response"])
245+
236246
@pytest.mark.skip(reason="Prism tests are disabled")
237247
@parametrize
238248
def test_raw_response_regenerate_token(self, client: Gitpod) -> None:
@@ -281,6 +291,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncGitpod) ->
281291
organization_id="b0e12f6c-4c67-429d-a4a6-d9838b5da047",
282292
sso_configuration_id="d2c94c27-3b76-4a42-b88c-95a85e392c68",
283293
name="name",
294+
token_expires_in="+9125115.360s",
284295
)
285296
assert_matches_type(ScimConfigurationCreateResponse, scim_configuration, path=["response"])
286297

@@ -474,6 +485,15 @@ async def test_method_regenerate_token(self, async_client: AsyncGitpod) -> None:
474485
)
475486
assert_matches_type(ScimConfigurationRegenerateTokenResponse, scim_configuration, path=["response"])
476487

488+
@pytest.mark.skip(reason="Prism tests are disabled")
489+
@parametrize
490+
async def test_method_regenerate_token_with_all_params(self, async_client: AsyncGitpod) -> None:
491+
scim_configuration = await async_client.organizations.scim_configurations.regenerate_token(
492+
scim_configuration_id="d2c94c27-3b76-4a42-b88c-95a85e392c68",
493+
token_expires_in="+9125115.360s",
494+
)
495+
assert_matches_type(ScimConfigurationRegenerateTokenResponse, scim_configuration, path=["response"])
496+
477497
@pytest.mark.skip(reason="Prism tests are disabled")
478498
@parametrize
479499
async def test_raw_response_regenerate_token(self, async_client: AsyncGitpod) -> None:

0 commit comments

Comments
 (0)