Skip to content

Commit 7eadb6e

Browse files
authored
Merge pull request #38 from Authress/regenerate-models
Regenerate models to populate tenant token configuration
2 parents 96a1764 + 53b7eca commit 7eadb6e

7 files changed

+168
-38
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ This is the changelog for [Authress SDK](readme.md).
1717
* Prevent unnecessary extra trailing slashes in domain name.
1818
* Add support for the `generateUserLoginUrl` from the ServiceClientTokenProvider.
1919
* [Breaking] Removed client_id from ClientAccessKey.py model, because it does not contain a clientId when fetching client data.
20+
* Add support for `tokenConfiguration` at the tenant level.
2021

2122
## 2.0 ##
2223
* Add support for users and groups at the statement level of access records.

authress/__init__.py

+10-26
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,11 @@
55

66
from __future__ import absolute_import
77

8-
# import apis into sdk package
9-
from authress.api.access_records_api import AccessRecordsApi
10-
from authress.api.accounts_api import AccountsApi
11-
from authress.api.resource_permissions_api import ResourcePermissionsApi
12-
from authress.api.service_clients_api import ServiceClientsApi
13-
from authress.api.user_permissions_api import UserPermissionsApi
148
# import AuthressClient
159
from authress.authress_client import AuthressClient
1610
from authress.http_client import HttpClient
1711
from authress.rest import ApiException
18-
# import models into sdk package
19-
from authress.models.access_record import AccessRecord
20-
from authress.models.access_record_account import AccessRecordAccount
21-
from authress.models.access_record_collection import AccessRecordCollection
22-
from authress.models.account import Account
23-
from authress.models.account_collection import AccountCollection
24-
from authress.models.claim_request import ClaimRequest
25-
from authress.models.client import Client
26-
from authress.models.client_access_key import ClientAccessKey
27-
from authress.models.client_collection import ClientCollection
28-
from authress.models.client_options import ClientOptions
29-
from authress.models.identity import Identity
30-
from authress.models.identity_collection import IdentityCollection
31-
from authress.models.identity_request import IdentityRequest
32-
from authress.models.permission_object import PermissionObject
33-
from authress.models.resource_permission import ResourcePermission
34-
35-
36-
12+
3713
# import apis into sdk package
3814
from authress.api.access_records_api import AccessRecordsApi
3915
from authress.api.accounts_api import AccountsApi
@@ -70,16 +46,21 @@
7046
from authress.models.account_collection import AccountCollection
7147
from authress.models.account_links import AccountLinks
7248
from authress.models.application_delegation import ApplicationDelegation
49+
from authress.models.authentication_token_configuration import AuthenticationTokenConfiguration
7350
from authress.models.claim_request import ClaimRequest
7451
from authress.models.client import Client
7552
from authress.models.client_access_key import ClientAccessKey
7653
from authress.models.client_collection import ClientCollection
7754
from authress.models.client_options import ClientOptions
55+
from authress.models.client_rate_limit import ClientRateLimit
7856
from authress.models.collection_links import CollectionLinks
7957
from authress.models.connection import Connection
8058
from authress.models.connection_collection import ConnectionCollection
59+
from authress.models.connection_conditions import ConnectionConditions
8160
from authress.models.connection_data import ConnectionData
8261
from authress.models.connection_default_connection_properties import ConnectionDefaultConnectionProperties
62+
from authress.models.connection_linking_configuration import ConnectionLinkingConfiguration
63+
from authress.models.connection_user_data_configuration import ConnectionUserDataConfiguration
8364
from authress.models.extension import Extension
8465
from authress.models.extension_application import ExtensionApplication
8566
from authress.models.extension_client import ExtensionClient
@@ -90,6 +71,7 @@
9071
from authress.models.identity_collection import IdentityCollection
9172
from authress.models.identity_request import IdentityRequest
9273
from authress.models.invite import Invite
74+
from authress.models.invite_statement import InviteStatement
9375
from authress.models.link import Link
9476
from authress.models.linked_group import LinkedGroup
9577
from authress.models.links import Links
@@ -113,6 +95,8 @@
11395
from authress.models.tenant_collection import TenantCollection
11496
from authress.models.tenant_connection import TenantConnection
11597
from authress.models.tenant_data import TenantData
98+
from authress.models.tenant_domain import TenantDomain
99+
from authress.models.tenant_user import TenantUser
116100
from authress.models.token_request import TokenRequest
117101
from authress.models.user import User
118102
from authress.models.user_connection_credentials import UserConnectionCredentials
@@ -121,4 +105,4 @@
121105
from authress.models.user_resources_collection import UserResourcesCollection
122106
from authress.models.user_role import UserRole
123107
from authress.models.user_role_collection import UserRoleCollection
124-
from authress.models.user_token import UserToken
108+
from authress.models.user_token import UserToken
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# coding: utf-8
2+
3+
"""
4+
Authress
5+
6+
<p> <h2>Introduction</h2> <p>Welcome to the Authress Authorization API. <br>The Authress REST API provides the operations and resources necessary to create records, assign permissions, and verify any user in your platform.</p> <p><ul> <li>Manage multitenant platforms and create user tenants for SSO connections.</li> <li>Create records to assign roles and resources to grant access for users.</li> <li>Check user access control by calling the authorization API at the right time.</li> <li>Configure service clients to securely access services in your platform.</li> </ul></p> <p>For more in-depth scenarios check out the <a href=\"https://authress.io/knowledge-base\" target=\"_blank\">Authress knowledge base</a>.</p> </p>
7+
8+
The version of the OpenAPI document: v1
9+
10+
Generated by OpenAPI Generator (https://openapi-generator.tech)
11+
12+
Do not edit the class manually.
13+
""" # noqa: E501
14+
15+
16+
from __future__ import annotations
17+
import pprint
18+
import re # noqa: F401
19+
import json
20+
21+
22+
from typing import Optional
23+
from pydantic import BaseModel, Field, constr, validator
24+
25+
try:
26+
from pydantic.v1 import BaseModel, Field, constr, validator
27+
except ImportError:
28+
from pydantic import BaseModel, Field, constr, validator
29+
30+
class AuthenticationTokenConfiguration(BaseModel):
31+
"""
32+
AuthenticationTokenConfiguration
33+
"""
34+
access_token_duration: Optional[constr(strict=True)] = Field(default='PT24H', alias="accessTokenDuration", description="How long should Authress generated access tokens (JWTs) last for in minutes. This controls how often tokens expiry (*exp*). The default is 24 hours. The minimum is one minute and the max is twenty-four hours.")
35+
session_duration: Optional[constr(strict=True)] = Field(default='P30D', alias="sessionDuration", description="How long should user authentication sessions last for in minutes. This controls how often users are forced to log in again. User sessions are optimized to provide the best user experience for your application. The default is 90 days. The minimum is one minute and the max is 90 days.")
36+
__properties = ["accessTokenDuration", "sessionDuration"]
37+
38+
@validator('access_token_duration')
39+
def access_token_duration_validate_regular_expression(cls, value):
40+
"""Validates the regular expression"""
41+
if value is None:
42+
return value
43+
44+
if not re.match(r"^P(?!$)(\d+Y)?(\d+M)?(\d+W)?(\d+D)?(T(?=\d+[HMS])(\d+H)?(\d+M)?(\d+S)?)?$", value):
45+
raise ValueError(r"must validate the regular expression /^P(?!$)(\d+Y)?(\d+M)?(\d+W)?(\d+D)?(T(?=\d+[HMS])(\d+H)?(\d+M)?(\d+S)?)?$/")
46+
return value
47+
48+
@validator('session_duration')
49+
def session_duration_validate_regular_expression(cls, value):
50+
"""Validates the regular expression"""
51+
if value is None:
52+
return value
53+
54+
if not re.match(r"^P(?!$)(\d+Y)?(\d+M)?(\d+W)?(\d+D)?(T(?=\d+[HMS])(\d+H)?(\d+M)?(\d+S)?)?$", value):
55+
raise ValueError(r"must validate the regular expression /^P(?!$)(\d+Y)?(\d+M)?(\d+W)?(\d+D)?(T(?=\d+[HMS])(\d+H)?(\d+M)?(\d+S)?)?$/")
56+
return value
57+
58+
class Config:
59+
"""Pydantic configuration"""
60+
allow_population_by_field_name = True
61+
validate_assignment = True
62+
63+
def to_str(self) -> str:
64+
"""Returns the string representation of the model using alias"""
65+
return pprint.pformat(self.dict(by_alias=True))
66+
67+
def to_json(self) -> str:
68+
"""Returns the JSON representation of the model using alias"""
69+
return json.dumps(self.to_dict())
70+
71+
@classmethod
72+
def from_json(cls, json_str: str) -> AuthenticationTokenConfiguration:
73+
"""Create an instance of AuthenticationTokenConfiguration from a JSON string"""
74+
return cls.from_dict(json.loads(json_str))
75+
76+
def to_dict(self):
77+
"""Returns the dictionary representation of the model using alias"""
78+
_dict = self.dict(by_alias=True,
79+
exclude={
80+
},
81+
exclude_none=True)
82+
# set to None if access_token_duration (nullable) is None
83+
# and __fields_set__ contains the field
84+
if self.access_token_duration is None and "access_token_duration" in self.__fields_set__:
85+
_dict['accessTokenDuration'] = None
86+
87+
# set to None if session_duration (nullable) is None
88+
# and __fields_set__ contains the field
89+
if self.session_duration is None and "session_duration" in self.__fields_set__:
90+
_dict['sessionDuration'] = None
91+
92+
return _dict
93+
94+
@classmethod
95+
def from_dict(cls, obj: dict) -> AuthenticationTokenConfiguration:
96+
"""Create an instance of AuthenticationTokenConfiguration from a dict"""
97+
if obj is None:
98+
return None
99+
100+
if not isinstance(obj, dict):
101+
return AuthenticationTokenConfiguration.parse_obj(obj)
102+
103+
_obj = AuthenticationTokenConfiguration.parse_obj({
104+
"access_token_duration": obj.get("accessTokenDuration") if obj.get("accessTokenDuration") is not None else 'PT24H',
105+
"session_duration": obj.get("sessionDuration") if obj.get("sessionDuration") is not None else 'P30D'
106+
})
107+
return _obj
108+
109+

authress/models/tenant.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from pydantic.v1 import BaseModel, Field, conlist, constr, validator
2525
except ImportError:
2626
from pydantic import BaseModel, Field, conlist, constr, validator
27+
from authress.models.authentication_token_configuration import AuthenticationTokenConfiguration
2728
from authress.models.tenant_connection import TenantConnection
2829
from authress.models.tenant_data import TenantData
2930
from authress.models.tenant_domain import TenantDomain
@@ -37,8 +38,9 @@ class Tenant(BaseModel):
3738
data: Optional[TenantData] = None
3839
domains: Optional[conlist(TenantDomain, max_items=10, min_items=0)] = Field(default=None, description="The associated user email domains that are mapped to this tenant. When a user starts the authentication process, if they are using SSO, Authress will use their specified email address to identify which Authress Tenant to log the user in with.")
3940
connection: Optional[TenantConnection] = None
41+
token_configuration: Optional[AuthenticationTokenConfiguration] = Field(default=None, alias="tokenConfiguration")
4042
created_time: Optional[datetime] = Field(default=None, alias="createdTime")
41-
__properties = ["tenantId", "tenantLookupIdentifier", "data", "domains", "connection", "createdTime"]
43+
__properties = ["tenantId", "tenantLookupIdentifier", "data", "domains", "connection", "tokenConfiguration", "createdTime"]
4244

4345
@validator('tenant_id')
4446
def tenant_id_validate_regular_expression(cls, value):
@@ -62,6 +64,7 @@ def tenant_lookup_identifier_validate_regular_expression(cls, value):
6264

6365
class Config:
6466
"""Pydantic configuration"""
67+
extra = 'forbid'
6568
allow_population_by_field_name = True
6669
validate_assignment = True
6770

@@ -98,6 +101,9 @@ def to_dict(self):
98101
# override the default output from pydantic by calling `to_dict()` of connection
99102
if self.connection:
100103
_dict['connection'] = self.connection.to_dict()
104+
# override the default output from pydantic by calling `to_dict()` of token_configuration
105+
if self.token_configuration:
106+
_dict['tokenConfiguration'] = self.token_configuration.to_dict()
101107
# set to None if tenant_id (nullable) is None
102108
# and __fields_set__ contains the field
103109
if self.tenant_id is None and "tenant_id" in self.__fields_set__:
@@ -135,6 +141,7 @@ def from_dict(cls, obj: dict) -> Tenant:
135141
"data": TenantData.from_dict(obj.get("data")) if obj.get("data") is not None else None,
136142
"domains": [TenantDomain.from_dict(_item) for _item in obj.get("domains")] if obj.get("domains") is not None else None,
137143
"connection": TenantConnection.from_dict(obj.get("connection")) if obj.get("connection") is not None else None,
144+
"token_configuration": AuthenticationTokenConfiguration.from_dict(obj.get("tokenConfiguration")) if obj.get("tokenConfiguration") is not None else None,
138145
"created_time": obj.get("createdTime")
139146
})
140147
return _obj

contributing.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ podman pull docker://openapitools/openapi-generator-online
2323
CID=$(podman run -d -p 8888:8080 openapitools/openapi-generator-online)
2424
sleep 10
2525

26-
# Execute an HTTP request to generate a Ruby client
26+
# Execute an HTTP request to generate the client
2727
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{"openAPIUrl": "https://api.authress.io/", "options": { "useSingleRequestParameter": true, "packageName": "authress", "packageVersion": "99.99.99" } }' 'http://localhost:8888/api/gen/clients/python-pydantic-v1'
2828

2929

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# AuthenticationTokenConfiguration
2+
3+
4+
## Properties
5+
Name | Type | Description | Notes
6+
------------ | ------------- | ------------- | -------------
7+
**access_token_duration** | **duration** | How long should Authress generated access tokens (JWTs) last for in minutes. This controls how often tokens expiry (*exp*). The default is 24 hours. The minimum is one minute and the max is twenty-four hours. | [optional] [default to 'PT24H']
8+
**session_duration** | **duration** | How long should user authentication sessions last for in minutes. This controls how often users are forced to log in again. User sessions are optimized to provide the best user experience for your application. The default is 90 days. The minimum is one minute and the max is 90 days. | [optional] [default to 'P30D']
9+
10+
## Example
11+
12+
```python
13+
from authress.models.authentication_token_configuration import AuthenticationTokenConfiguration
14+
15+
token_configuration = AuthenticationTokenConfiguration(
16+
access_token_duration="PT24H",
17+
session_duration="P30D"
18+
)
19+
20+
print token_configuration.to_json()
21+
```
22+
23+
[[API Models]](./README.md#documentation-for-models)[[API Endpoints]](./README.md#documentation-for-api-endpoints)[[Back to Repo]](../README.md)

docs/Tenant.md

+16-10
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,29 @@ Name | Type | Description | Notes
99
**data** | [**TenantData**](TenantData.md) | | [optional]
1010
**domains** | [**List[TenantDomain]**](TenantDomain.md) | The associated user email domains that are mapped to this tenant. When a user starts the authentication process, if they are using SSO, Authress will use their specified email address to identify which Authress Tenant to log the user in with. | [optional]
1111
**connection** | [**TenantConnection**](TenantConnection.md) | | [optional]
12+
**token_configuration** | [**AuthenticationTokenConfiguration**](AuthenticationTokenConfiguration.md) | | [optional]
1213
**created_time** | **datetime** | | [optional] [readonly]
1314

1415
## Example
1516

1617
```python
1718
from authress.models.tenant import Tenant
1819

19-
json = "{}"
20-
# create an instance of Tenant from a JSON string
21-
tenant_instance = Tenant.from_json(json)
22-
# print the JSON string representation of the object
23-
print Tenant.to_json()
24-
25-
# convert the object into a dict
26-
tenant_dict = tenant_instance.to_dict()
27-
# create an instance of Tenant from a dict
28-
tenant_from_dict = Tenant.from_dict(tenant_dict)
20+
tenant = Tenant(
21+
tenant_id="Tenant_ID-001",
22+
tenant_lookup_identifier="example.com",
23+
data=TenantData(name="Tenant for Customer Example 001"),
24+
domains=[
25+
TenantDomain(domain="example.com"), TenantDomain(domain="alternate.example.com")
26+
],
27+
connection=TenantConnection(
28+
connection_id="google"
29+
),
30+
token_configuration = AuthenticationTokenConfiguration(
31+
access_token_duration="PT24H",
32+
session_duration="P30D"
33+
)
34+
)
2935
```
3036
[[API Models]](./README.md#documentation-for-models)[[API Endpoints]](./README.md#documentation-for-api-endpoints)[[Back to Repo]](../README.md)
3137

0 commit comments

Comments
 (0)