File tree Expand file tree Collapse file tree 9 files changed +39
-21
lines changed
iceberg_rest_s3_delegated Expand file tree Collapse file tree 9 files changed +39
-21
lines changed Original file line number Diff line number Diff line change 66from typing import TYPE_CHECKING
77
88from cryptography .fernet import Fernet
9- from pydantic import SecretStr
109
1110if TYPE_CHECKING :
1211 from syncmaster .scheduler .settings import SchedulerAppSettings
@@ -23,11 +22,6 @@ def decrypt_auth_data(
2322 return json .loads (decrypted )
2423
2524
26- def _json_default (value ):
27- if isinstance (value , SecretStr ):
28- return value .get_secret_value ()
29-
30-
3125def encrypt_auth_data (
3226 value : dict ,
3327 settings : WorkerAppSettings | SchedulerAppSettings | ServerAppSettings ,
@@ -37,7 +31,6 @@ def encrypt_auth_data(
3731 value ,
3832 ensure_ascii = False ,
3933 sort_keys = True ,
40- default = _json_default ,
4134 )
4235 encrypted = encryptor .encrypt (serialized .encode ("utf-8" ))
4336 return encrypted .decode ("utf-8" )
Original file line number Diff line number Diff line change 22# SPDX-License-Identifier: Apache-2.0
33from typing import Literal
44
5- from pydantic import BaseModel , Field , SecretStr
5+ from pydantic import Field , SecretStr
66
7+ from syncmaster .schemas .v1 .auth .mixins import SecretDumpMixin
78
8- class ReadBasicAuthSchema (BaseModel ):
9+
10+ class ReadBasicAuthSchema (SecretDumpMixin ):
911 type : Literal ["basic" ] = Field (description = "Auth type" )
1012 user : str
1113
Original file line number Diff line number Diff line change 22# SPDX-License-Identifier: Apache-2.0
33from typing import Literal
44
5- from pydantic import BaseModel , Field , SecretStr
5+ from pydantic import Field , SecretStr
66
7+ from syncmaster .schemas .v1 .auth .mixins import SecretDumpMixin
78
8- class ReadIcebergRESTCatalogBearerAuthSchema (BaseModel ):
9+
10+ class ReadIcebergRESTCatalogBearerAuthSchema (SecretDumpMixin ):
911 type : Literal ["iceberg_rest_bearer" ] = Field (description = "Auth type" )
1012
1113
Original file line number Diff line number Diff line change 22# SPDX-License-Identifier: Apache-2.0
33from typing import Literal
44
5- from pydantic import BaseModel , Field , SecretStr
5+ from pydantic import Field , SecretStr
66
7+ from syncmaster .schemas .v1 .auth .mixins import SecretDumpMixin
78from syncmaster .schemas .v1 .types import URL
89
910
10- class ReadIcebergRESTCatalogOAuth2ClientCredentialsAuthSchema (BaseModel ):
11+ class ReadIcebergRESTCatalogOAuth2ClientCredentialsAuthSchema (SecretDumpMixin ):
1112 type : Literal ["iceberg_rest_oauth2_client_credentials" ] = Field (description = "Auth type" )
1213 rest_catalog_oauth2_client_id : str
1314 rest_catalog_oauth2_scopes : list [str ] = Field (default_factory = list )
Original file line number Diff line number Diff line change 22# SPDX-License-Identifier: Apache-2.0
33from typing import Literal
44
5- from pydantic import BaseModel , Field , SecretStr
5+ from pydantic import Field , SecretStr
66
7+ from syncmaster .schemas .v1 .auth .mixins import SecretDumpMixin
78
8- class ReadIcebergRESTCatalogBearerS3BasicAuthSchema (BaseModel ):
9+
10+ class ReadIcebergRESTCatalogBearerS3BasicAuthSchema (SecretDumpMixin ):
911 type : Literal ["iceberg_rest_bearer_s3_basic" ] = Field (description = "Auth type" )
1012 s3_access_key : str
1113
Original file line number Diff line number Diff line change 22# SPDX-License-Identifier: Apache-2.0
33from typing import Literal
44
5- from pydantic import BaseModel , Field , SecretStr
5+ from pydantic import Field , SecretStr
66
7+ from syncmaster .schemas .v1 .auth .mixins import SecretDumpMixin
78
8- class ReadIcebergRESTCatalogOAuth2ClientCredentialsS3BasicAuthSchema (BaseModel ):
9+
10+ class ReadIcebergRESTCatalogOAuth2ClientCredentialsS3BasicAuthSchema (SecretDumpMixin ):
911 type : Literal ["iceberg_rest_oauth2_client_credentials_s3_basic" ] = Field (description = "Auth type" )
1012 rest_catalog_oauth2_client_id : str
1113 rest_catalog_oauth2_scopes : list [str ] = Field (default_factory = list )
Original file line number Diff line number Diff line change 1+ # SPDX-FileCopyrightText: 2023-2024 MTS PJSC
2+ # SPDX-License-Identifier: Apache-2.0
3+ from pydantic import BaseModel , SecretStr , field_serializer
4+
5+
6+ class SecretDumpMixin (BaseModel ):
7+
8+ @field_serializer ("*" , when_used = "json" )
9+ def dump_secrets (self , value ):
10+ if isinstance (value , SecretStr ):
11+ return value .get_secret_value ()
12+ return value
Original file line number Diff line number Diff line change 22# SPDX-License-Identifier: Apache-2.0
33from typing import Literal
44
5- from pydantic import BaseModel , Field , SecretStr
5+ from pydantic import Field , SecretStr
66
7+ from syncmaster .schemas .v1 .auth .mixins import SecretDumpMixin
78
8- class ReadS3AuthSchema (BaseModel ):
9+
10+ class ReadS3AuthSchema (SecretDumpMixin ):
911 type : Literal ["s3" ] = Field (description = "Auth type" )
1012 access_key : str
1113
Original file line number Diff line number Diff line change 22# SPDX-License-Identifier: Apache-2.0
33from typing import Literal
44
5- from pydantic import BaseModel , Field , SecretStr
5+ from pydantic import Field , SecretStr
66
7+ from syncmaster .schemas .v1 .auth .mixins import SecretDumpMixin
78
8- class ReadSambaAuthSchema (BaseModel ):
9+
10+ class ReadSambaAuthSchema (SecretDumpMixin ):
911 type : Literal ["samba" ] = Field (description = "Auth type" )
1012 user : str
1113 auth_type : Literal ["NTLMv1" , "NTLMv2" ] = "NTLMv2"
You can’t perform that action at this time.
0 commit comments