2222from botocore .config import Config
2323from botocore .errorfactory import ClientError
2424from cryptography .fernet import Fernet
25- from joserfc .jwk import KeySet , RSAKey
25+ from joserfc .jwk import KeySet
2626from pydantic import (
27- AliasChoices ,
2827 AnyUrl ,
2928 BeforeValidator ,
3029 Field ,
@@ -81,19 +80,8 @@ def _maybe_load_keys_from_file(value: Any) -> Any:
8180 raise ValueError ("Only file:// URLs are supported" )
8281 if url .path is None :
8382 raise ValueError ("No path specified" )
84- value = Path (url .path ).read_text ()
85-
86- if isinstance (value , str ) and value .strip ().startswith ("-----BEGIN" ):
87- return json .dumps (
88- KeySet (
89- keys = [
90- RSAKey .import_key (
91- value , # type: ignore
92- parameters = {"key_ops" : ["sign" , "verify" ], "alg" : "RS256" }, # type: ignore
93- )
94- ]
95- ).as_dict (private = True )
96- )
83+ return Path (url .path ).read_text ()
84+
9785 return value
9886
9987
@@ -151,9 +139,7 @@ def create(cls) -> Self:
151139class AuthSettings (ServiceSettingsBase ):
152140 """Settings for the authentication service."""
153141
154- model_config = SettingsConfigDict (
155- env_prefix = "DIRACX_SERVICE_AUTH_" , validate_by_name = True
156- )
142+ model_config = SettingsConfigDict (env_prefix = "DIRACX_SERVICE_AUTH_" )
157143
158144 dirac_client_id : str = "myDIRACClientID"
159145 # TODO: This should be taken dynamically
@@ -166,13 +152,7 @@ class AuthSettings(ServiceSettingsBase):
166152 state_key : FernetKey
167153
168154 token_issuer : str
169- token_keystore : TokenSigningKeyStore = Field (
170- validation_alias = AliasChoices (
171- "token_keystore" ,
172- "DIRACX_SERVICE_AUTH_TOKEN_KEYSTORE" ,
173- "DIRACX_SERVICE_AUTH_TOKEN_KEY" ,
174- )
175- )
155+ token_keystore : TokenSigningKeyStore
176156 token_allowed_algorithms : list [str ] = ["RS256" , "EdDSA" ] # noqa: S105
177157 access_token_expire_minutes : int = 20
178158 refresh_token_expire_minutes : int = 60
0 commit comments