Skip to content

Commit 43de3c2

Browse files
committed
return to public fields to make pydantic happy
1 parent edd1586 commit 43de3c2

3 files changed

Lines changed: 16 additions & 15 deletions

File tree

src/corbado_python_sdk/corbado_sdk.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ def sessions(self) -> SessionService:
7070
"""
7171
if not self._sessions:
7272
self._sessions = SessionService(
73-
_issuer=self.config.issuer,
74-
_jwks_uri=self.config.frontend_api + "/.well-known/jwks",
73+
issuer=self.config.issuer,
74+
jwks_uri=self.config.frontend_api + "/.well-known/jwks",
7575
project_id=self.config.project_id,
7676
)
7777

src/corbado_python_sdk/services/implementation/session_service.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,20 @@ class SessionService(BaseModel):
2525
2626
Attributes:
2727
model_config (ConfigDict): Configuration dictionary for the model.
28+
issuer (str): Issuer of the session tokens.
29+
jwks_uri (str): URI of the JSON Web Key Set (JWKS) endpoint.
2830
last_session_token_validation_result (str): Result of the last short session validation.
29-
project_id (str): Corbado Project Id.
30-
_issuer (str): Issuer of the session tokens.
31-
_jwks_uri (str): URI of the JSON Web Key Set (JWKS) endpoint.
3231
_jwk_client (PyJWKClient): JSON Web Key (JWK) client for handling JWKS.
32+
project_id (str): Corbado Project Id.
3333
"""
3434

3535
model_config = ConfigDict(arbitrary_types_allowed=True, validate_assignment=True)
3636

3737
# Fields
38+
issuer: Annotated[str, StringConstraints(strip_whitespace=True, min_length=1)]
39+
jwks_uri: Annotated[str, StringConstraints(strip_whitespace=True, min_length=1)]
3840
last_session_token_validation_result: str = ""
3941
project_id: str
40-
_issuer: Annotated[str, StringConstraints(strip_whitespace=True, min_length=1)]
41-
_jwks_uri: Annotated[str, StringConstraints(strip_whitespace=True, min_length=1)]
4242
_jwk_client: PyJWKClient
4343

4444
# Constructor
@@ -49,14 +49,16 @@ def __init__(self, **kwargs) -> None: # type: ignore
4949
Args:
5050
**kwargs: Additional keyword arguments to initialize the SessionService.
5151
These keyword arguments should include values for the attributes defined in the class,
52-
such as 'issuer', '_jwks_uri' and 'last_session_token_validation_result',
52+
such as 'issuer', 'jwks_uri', 'last_session_token_validation_result',
53+
'cache_keys',cache_jwk_set and 'session_token_cookie_length'.
5354
5455
Raises:
5556
Any errors raised during the initialization process.
57+
5658
"""
5759
super().__init__(**kwargs)
5860
self._jwk_client = PyJWKClient(
59-
uri=self._jwks_uri,
61+
uri=self.jwks_uri,
6062
lifespan=DEFAULT_SESSION_TOKEN_LENGTH,
6163
)
6264

@@ -140,7 +142,7 @@ def _set_issuer_mismatch_error(self, token_issuer: str) -> None:
140142
Args:
141143
token_issuer (str): Token issuer.
142144
"""
143-
self.last_session_token_validation_result = f"Mismatch in issuer (configured: {self._issuer}, JWT: {token_issuer})"
145+
self.last_session_token_validation_result = f"Mismatch in issuer (configured: {self.issuer}, JWT: {token_issuer})"
144146

145147
def _set_validation_error(self, error: Exception) -> None:
146148
"""Set validation error.
@@ -164,8 +166,7 @@ def _validate_issuer(self, token_issuer: str, session_token: str) -> None:
164166
"""
165167
if not token_issuer:
166168
raise TokenValidationException(
167-
error_type=ValidationErrorType.CODE_JWT_ISSUER_EMPTY,
168-
message=f"Issuer is empty. Session token: {session_token}"
169+
error_type=ValidationErrorType.CODE_JWT_ISSUER_EMPTY, message=f"Issuer is empty. Session token: {session_token}"
169170
)
170171

171172
# Check for old Frontend API (without .cloud.)
@@ -179,8 +180,8 @@ def _validate_issuer(self, token_issuer: str, session_token: str) -> None:
179180
return
180181

181182
# Check against the configured issuer (e.g., a custom domain or CNAME)
182-
if token_issuer != self._issuer:
183+
if token_issuer != self.issuer:
183184
raise TokenValidationException(
184185
error_type=ValidationErrorType.CODE_JWT_ISSUER_MISSMATCH,
185-
message=f"Issuer mismatch (configured via FrontendAPI: '{self._issuer}', JWT issuer: '{token_issuer}')",
186+
message=f"Issuer mismatch (configured via FrontendAPI: '{self.issuer}', JWT issuer: '{token_issuer}')",
186187
)

tests/unit/test_session_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,4 +276,4 @@ def test_set_cname_expect_issuer_changed(self):
276276

277277
sdk = CorbadoSDK(config=config)
278278
sessions: SessionService = sdk.sessions
279-
self.assertEqual("https://" + test_cname, sessions._issuer)
279+
self.assertEqual("https://" + test_cname, sessions.issuer)

0 commit comments

Comments
 (0)