Skip to content

Commit 13ba9b9

Browse files
committed
Merge branch '0.11' into fix/session-claims
2 parents 5bb1860 + 698cc96 commit 13ba9b9

File tree

9 files changed

+49
-43
lines changed

9 files changed

+49
-43
lines changed

CHANGELOG.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [unreleased]
88

9-
### Added
10-
- Support for FDI 1.15
11-
12-
### Breaking changes
13-
- Removes support for FDI <= 1.14
14-
159
## [0.11.0] - 2022-09-14
1610

1711
### Changes
@@ -20,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2014

2115
### Added
2216

17+
- Support for FDI 1.15
2318
- Added support for session claims with related interfaces and classes.
2419
- Added `on_invalid_claim` optional error handler to send InvalidClaim error responses.
2520
- Added `INVALID_CLAIMS` (`InvalidClaimError`) to `SessionErrors`.
@@ -34,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3429
- Adds default userContext for verifySession calls that contains the request object.
3530

3631
### Breaking Changes
32+
- Removes support for FDI <= 1.14
3733
- Changed `sign_in_up` third party recipe function to accept just the email as `str` (removed `email_verified: bool`).
3834
- The frontend SDK should be updated to a version supporting session claims!
3935
- supertokens-auth-react: >= 0.25.0

html/supertokens_python/recipe/session/api/implementation.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,17 @@ <h1 class="title">Module <code>supertokens_python.recipe.session.api.implementat
4141
# under the License.
4242
from __future__ import annotations
4343

44-
from typing import TYPE_CHECKING, Union, List, Callable, Optional
44+
from typing import TYPE_CHECKING, Callable, List, Optional, Union
4545

4646
from supertokens_python.normalised_url_path import NormalisedURLPath
4747
from supertokens_python.recipe.session.interfaces import (
4848
APIInterface,
49-
SignOutOkayResponse,
5049
SessionClaimValidator,
50+
SignOutOkayResponse,
5151
)
5252
from supertokens_python.types import MaybeAwaitable
5353
from supertokens_python.utils import normalise_http_method
54+
5455
from ..utils import get_required_claim_validators
5556

5657
if TYPE_CHECKING:

html/supertokens_python/recipe/session/interfaces.html

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,21 @@ <h1 class="title">Module <code>supertokens_python.recipe.session.interfaces</cod
4545
from typing import (
4646
TYPE_CHECKING,
4747
Any,
48+
Callable,
4849
Dict,
4950
Generic,
5051
List,
52+
Optional,
5153
TypeVar,
5254
Union,
53-
Callable,
54-
Optional,
5555
)
5656

5757
from supertokens_python.async_to_sync_wrapper import sync
58-
from supertokens_python.types import APIResponse, MaybeAwaitable
58+
from supertokens_python.types import APIResponse, GeneralErrorResponse, MaybeAwaitable
59+
60+
from ...utils import resolve
5961
from .exceptions import ClaimValidationError
6062
from .utils import SessionConfig
61-
from ...utils import resolve
6263

6364
if TYPE_CHECKING:
6465
from supertokens_python.framework import BaseRequest, BaseResponse
@@ -347,7 +348,7 @@ <h1 class="title">Module <code>supertokens_python.recipe.session.interfaces</cod
347348
session: Optional[SessionContainer],
348349
api_options: APIOptions,
349350
user_context: Dict[str, Any],
350-
) -&gt; SignOutOkayResponse:
351+
) -&gt; Union[SignOutOkayResponse, GeneralErrorResponse]:
351352
pass
352353

353354
@abstractmethod
@@ -696,7 +697,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
696697
session: Optional[SessionContainer],
697698
api_options: APIOptions,
698699
user_context: Dict[str, Any],
699-
) -&gt; SignOutOkayResponse:
700+
) -&gt; Union[SignOutOkayResponse, GeneralErrorResponse]:
700701
pass
701702

702703
@abstractmethod
@@ -742,7 +743,7 @@ <h3>Methods</h3>
742743
</details>
743744
</dd>
744745
<dt id="supertokens_python.recipe.session.interfaces.APIInterface.signout_post"><code class="name flex">
745-
<span>async def <span class="ident">signout_post</span></span>(<span>self, session: Optional[<a title="supertokens_python.recipe.session.interfaces.SessionContainer" href="#supertokens_python.recipe.session.interfaces.SessionContainer">SessionContainer</a>], api_options: <a title="supertokens_python.recipe.session.interfaces.APIOptions" href="#supertokens_python.recipe.session.interfaces.APIOptions">APIOptions</a>, user_context: Dict[str, Any]) ‑> <a title="supertokens_python.recipe.session.interfaces.SignOutOkayResponse" href="#supertokens_python.recipe.session.interfaces.SignOutOkayResponse">SignOutOkayResponse</a></span>
746+
<span>async def <span class="ident">signout_post</span></span>(<span>self, session: Optional[<a title="supertokens_python.recipe.session.interfaces.SessionContainer" href="#supertokens_python.recipe.session.interfaces.SessionContainer">SessionContainer</a>], api_options: <a title="supertokens_python.recipe.session.interfaces.APIOptions" href="#supertokens_python.recipe.session.interfaces.APIOptions">APIOptions</a>, user_context: Dict[str, Any]) ‑> Union[<a title="supertokens_python.recipe.session.interfaces.SignOutOkayResponse" href="#supertokens_python.recipe.session.interfaces.SignOutOkayResponse">SignOutOkayResponse</a><a title="supertokens_python.types.GeneralErrorResponse" href="../../types.html#supertokens_python.types.GeneralErrorResponse">GeneralErrorResponse</a>]</span>
746747
</code></dt>
747748
<dd>
748749
<div class="desc"></div>
@@ -756,7 +757,7 @@ <h3>Methods</h3>
756757
session: Optional[SessionContainer],
757758
api_options: APIOptions,
758759
user_context: Dict[str, Any],
759-
) -&gt; SignOutOkayResponse:
760+
) -&gt; Union[SignOutOkayResponse, GeneralErrorResponse]:
760761
pass</code></pre>
761762
</details>
762763
</dd>

html/supertokens_python/recipe/session/recipe.html

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ <h1 class="title">Module <code>supertokens_python.recipe.session.recipe</code></
4747
from supertokens_python.framework.response import BaseResponse
4848
from typing_extensions import Literal
4949

50+
from supertokens_python.utils import default_user_context
51+
5052
from .api import handle_refresh_api, handle_signout_api
5153
from .cookie_and_header import get_cors_allowed_headers
5254
from .exceptions import (
@@ -367,14 +369,16 @@ <h1 class="title">Module <code>supertokens_python.recipe.session.recipe</code></
367369
],
368370
user_context: Dict[str, Any],
369371
):
372+
_ = user_context
373+
370374
return await self.api_implementation.verify_session(
371375
APIOptions(
372376
request, None, self.recipe_id, self.config, self.recipe_implementation
373377
),
374378
anti_csrf_check,
375379
session_required,
376380
override_global_claim_validators,
377-
user_context,
381+
user_context=default_user_context(request),
378382
)</code></pre>
379383
</details>
380384
</section>
@@ -675,14 +679,16 @@ <h2 class="section-title" id="header-classes">Classes</h2>
675679
],
676680
user_context: Dict[str, Any],
677681
):
682+
_ = user_context
683+
678684
return await self.api_implementation.verify_session(
679685
APIOptions(
680686
request, None, self.recipe_id, self.config, self.recipe_implementation
681687
),
682688
anti_csrf_check,
683689
session_required,
684690
override_global_claim_validators,
685-
user_context,
691+
user_context=default_user_context(request),
686692
)</code></pre>
687693
</details>
688694
<h3>Ancestors</h3>
@@ -1014,14 +1020,16 @@ <h3>Methods</h3>
10141020
],
10151021
user_context: Dict[str, Any],
10161022
):
1023+
_ = user_context
1024+
10171025
return await self.api_implementation.verify_session(
10181026
APIOptions(
10191027
request, None, self.recipe_id, self.config, self.recipe_implementation
10201028
),
10211029
anti_csrf_check,
10221030
session_required,
10231031
override_global_claim_validators,
1024-
user_context,
1032+
user_context=default_user_context(request),
10251033
)</code></pre>
10261034
</details>
10271035
</dd>

supertokens_python/recipe/session/api/implementation.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,17 @@
1313
# under the License.
1414
from __future__ import annotations
1515

16-
from typing import TYPE_CHECKING, Union, List, Callable, Optional
16+
from typing import TYPE_CHECKING, Callable, List, Optional, Union
1717

1818
from supertokens_python.normalised_url_path import NormalisedURLPath
1919
from supertokens_python.recipe.session.interfaces import (
2020
APIInterface,
21-
SignOutOkayResponse,
2221
SessionClaimValidator,
22+
SignOutOkayResponse,
2323
)
2424
from supertokens_python.types import MaybeAwaitable
2525
from supertokens_python.utils import normalise_http_method
26+
2627
from ..utils import get_required_claim_validators
2728

2829
if TYPE_CHECKING:

supertokens_python/recipe/session/interfaces.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,21 @@
1717
from typing import (
1818
TYPE_CHECKING,
1919
Any,
20+
Callable,
2021
Dict,
2122
Generic,
2223
List,
24+
Optional,
2325
TypeVar,
2426
Union,
25-
Callable,
26-
Optional,
2727
)
2828

2929
from supertokens_python.async_to_sync_wrapper import sync
30-
from supertokens_python.types import APIResponse, MaybeAwaitable
30+
from supertokens_python.types import APIResponse, GeneralErrorResponse, MaybeAwaitable
31+
32+
from ...utils import resolve
3133
from .exceptions import ClaimValidationError
3234
from .utils import SessionConfig
33-
from ...utils import resolve
3435

3536
if TYPE_CHECKING:
3637
from supertokens_python.framework import BaseRequest, BaseResponse
@@ -319,7 +320,7 @@ async def signout_post(
319320
session: Optional[SessionContainer],
320321
api_options: APIOptions,
321322
user_context: Dict[str, Any],
322-
) -> SignOutOkayResponse:
323+
) -> Union[SignOutOkayResponse, GeneralErrorResponse]:
323324
pass
324325

325326
@abstractmethod

tests/auth-react/django3x/mysite/utils.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import os
2-
from typing import Any, Dict, List, Union, Optional
2+
from typing import Any, Dict, List, Optional, Union
33

44
from dotenv import load_dotenv
55
from supertokens_python import InputAppInfo, Supertokens, SupertokensConfig, init
66
from supertokens_python.framework.request import BaseRequest
77
from supertokens_python.recipe import (
88
emailpassword,
9+
emailverification,
910
passwordless,
1011
session,
1112
thirdparty,
1213
thirdpartyemailpassword,
1314
thirdpartypasswordless,
14-
emailverification,
1515
)
1616
from supertokens_python.recipe.emailpassword import EmailPasswordRecipe
1717
from supertokens_python.recipe.emailpassword.interfaces import (
@@ -25,10 +25,7 @@
2525
InputFormField,
2626
User,
2727
)
28-
from supertokens_python.recipe.emailverification.types import User as EVUser
29-
from supertokens_python.recipe.emailverification import (
30-
EmailVerificationRecipe,
31-
)
28+
from supertokens_python.recipe.emailverification import EmailVerificationRecipe
3229
from supertokens_python.recipe.emailverification import (
3330
InputOverrideConfig as EVInputOverrideConfig,
3431
)
@@ -38,6 +35,7 @@
3835
from supertokens_python.recipe.emailverification.interfaces import (
3936
APIOptions as EVAPIOptions,
4037
)
38+
from supertokens_python.recipe.emailverification.types import User as EVUser
4139
from supertokens_python.recipe.jwt import JWTRecipe
4240
from supertokens_python.recipe.passwordless import (
4341
ContactEmailOnlyConfig,
@@ -51,7 +49,7 @@
5149
APIInterface as PasswordlessAPIInterface,
5250
)
5351
from supertokens_python.recipe.passwordless.interfaces import APIOptions as PAPIOptions
54-
from supertokens_python.recipe.session import SessionRecipe, SessionContainer
52+
from supertokens_python.recipe.session import SessionContainer, SessionRecipe
5553
from supertokens_python.recipe.session.interfaces import (
5654
APIInterface as SessionAPIInterface,
5755
)
@@ -86,7 +84,7 @@
8684
from supertokens_python.types import GeneralErrorResponse
8785
from typing_extensions import Literal
8886

89-
from .store import save_url_with_token, save_code
87+
from .store import save_code, save_url_with_token
9088

9189
load_dotenv()
9290

@@ -592,7 +590,7 @@ async def signout_post(
592590
"body", api_options.request
593591
)
594592
if is_general_error:
595-
raise Exception("general error from signout API")
593+
return GeneralErrorResponse("general error from signout API")
596594
return await original_signout_post(session, api_options, user_context)
597595

598596
original_implementation.signout_post = signout_post
@@ -853,7 +851,7 @@ async def authorisation_url_get(
853851
recipe_list = [
854852
session.init(override=session.InputOverrideConfig(apis=override_session_apis)),
855853
emailverification.init(
856-
mode="REQUIRED",
854+
mode="OPTIONAL",
857855
create_and_send_custom_email=ev_create_and_send_custom_email,
858856
override=EVInputOverrideConfig(apis=override_email_verification_apis),
859857
),

tests/auth-react/fastapi-server/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ async def signout_post(
661661
"body", api_options.request
662662
)
663663
if is_general_error:
664-
raise Exception("general error from signout API")
664+
return GeneralErrorResponse("general error from signout API")
665665
return await original_signout_post(session, api_options, user_context)
666666

667667
original_implementation.signout_post = signout_post
@@ -923,7 +923,7 @@ async def authorisation_url_get(
923923
userroles.init(),
924924
session.init(override=session.InputOverrideConfig(apis=override_session_apis)),
925925
emailverification.init(
926-
mode="REQUIRED",
926+
mode="OPTIONAL",
927927
create_and_send_custom_email=ev_create_and_send_custom_email,
928928
override=EVInputOverrideConfig(apis=override_email_verification_apis),
929929
),

tests/auth-react/flask-server/app.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# License for the specific language governing permissions and limitations
1313
# under the License.
1414
import os
15-
from typing import Any, Dict, List, Union, Optional
15+
from typing import Any, Dict, List, Optional, Union
1616

1717
from dotenv import load_dotenv
1818
from flask import Flask, g, jsonify, make_response, request
@@ -29,12 +29,12 @@
2929
from supertokens_python.framework.request import BaseRequest
3030
from supertokens_python.recipe import (
3131
emailpassword,
32+
emailverification,
3233
passwordless,
3334
session,
3435
thirdparty,
3536
thirdpartyemailpassword,
3637
thirdpartypasswordless,
37-
emailverification,
3838
)
3939
from supertokens_python.recipe.emailpassword import EmailPasswordRecipe
4040
from supertokens_python.recipe.emailpassword.interfaces import (
@@ -62,6 +62,7 @@
6262
from supertokens_python.recipe.emailverification.interfaces import (
6363
APIOptions as EVAPIOptions,
6464
)
65+
from supertokens_python.recipe.emailverification.types import User as EVUser
6566
from supertokens_python.recipe.jwt import JWTRecipe
6667
from supertokens_python.recipe.passwordless import (
6768
ContactEmailOnlyConfig,
@@ -117,7 +118,6 @@
117118
)
118119
from supertokens_python.types import GeneralErrorResponse
119120
from typing_extensions import Literal
120-
from supertokens_python.recipe.emailverification.types import User as EVUser
121121

122122
load_dotenv()
123123

@@ -625,7 +625,7 @@ async def signout_post(
625625
"body", api_options.request
626626
)
627627
if is_general_error:
628-
raise Exception("general error from signout API")
628+
return GeneralErrorResponse("general error from signout API")
629629
return await original_signout_post(session, api_options, user_context)
630630

631631
original_implementation.signout_post = signout_post
@@ -906,7 +906,7 @@ async def authorisation_url_get(
906906
recipe_list = [
907907
session.init(override=session.InputOverrideConfig(apis=override_session_apis)),
908908
emailverification.init(
909-
mode="REQUIRED",
909+
mode="OPTIONAL",
910910
create_and_send_custom_email=ev_create_and_send_custom_email,
911911
override=EVInputOverrideConfig(apis=override_email_verification_apis),
912912
),

0 commit comments

Comments
 (0)