Skip to content

Commit 5398067

Browse files
authored
docs: updates WebAuthn documentation for Python SDK
2 parents 9f7b423 + 548e82e commit 5398067

File tree

24 files changed

+956
-458
lines changed

24 files changed

+956
-458
lines changed

docs/additional-verification/mfa/introduction.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ skip_llms_txt: true
66
description: >-
77
Implement multi-factor authentication with email, SMS, or TOTP, and customize
88
user authentication preferences.
9-
page_type: overview
9+
page_type: overview
1010
recipe: mfa
1111
category: multi-factor-authentication
1212
---
@@ -16,8 +16,8 @@ category: multi-factor-authentication
1616

1717
## Overview
1818

19-
Multi-factor authentication (MFA) is a security process that requires users to verify their identity through multiple forms of credentials before gaining access to a system.
20-
**SuperTokens** allows you to integrate MFA in your application using either Email/SMS One-Time Password (OTP) or Time-based One-Time Password (TOTP).
19+
Multi-factor authentication (MFA) is a security process that requires users to verify their identity through multiple forms of credentials before gaining access to a system.
20+
**SuperTokens** allows you to integrate MFA in your application using Email/SMS One-Time Password (OTP), or Time-based One-Time Password (TOTP).
2121

2222
## Prerequisites
2323

docs/additional-verification/mfa/protect-routes.mdx

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ async def like_comment(request: HttpRequest):
367367

368368
The same modification can be done for `getSession` as well.
369369

370-
### Check MFA claim manually
370+
### Check MFA claim manually
371371

372372
To account for a more complex logic when you check the MFA claim (other than checking if `v` is `true`), look over the next code snippet.
373373

@@ -869,15 +869,16 @@ At the moment this feature is not supported through the Go SDK.
869869

870870
```python
871871
from fastapi import Depends
872-
from supertokens_python.recipe.session.framework.fastapi import verify_session
873-
from supertokens_python.recipe.session.exceptions import (
874-
raise_invalid_claims_exception,
875-
ClaimValidationError,
876-
)
877-
from supertokens_python.recipe.session import SessionContainer
872+
878873
from supertokens_python.recipe.multifactorauth.multi_factor_auth_claim import (
879874
MultiFactorAuthClaim,
880875
)
876+
from supertokens_python.recipe.session import SessionContainer
877+
from supertokens_python.recipe.session.exceptions import (
878+
ClaimValidationError,
879+
raise_invalid_claims_exception,
880+
)
881+
from supertokens_python.recipe.session.framework.fastapi import verify_session
881882

882883

883884
@app.post("/update-blog") # type: ignore
@@ -915,10 +916,16 @@ async def update_blog_api(session: SessionContainer = Depends(verify_session()))
915916

916917
```python
917918
from flask import Flask, g
918-
from supertokens_python.recipe.session.framework.flask import verify_session
919+
920+
from supertokens_python.recipe.multifactorauth.multi_factor_auth_claim import (
921+
MultiFactorAuthClaim,
922+
)
919923
from supertokens_python.recipe.session import SessionContainer
920-
from supertokens_python.recipe.session.exceptions import raise_invalid_claims_exception, ClaimValidationError
921-
from supertokens_python.recipe.multifactorauth.multi_factor_auth_claim import MultiFactorAuthClaim
924+
from supertokens_python.recipe.session.exceptions import (
925+
ClaimValidationError,
926+
raise_invalid_claims_exception,
927+
)
928+
from supertokens_python.recipe.session.framework.flask import verify_session
922929

923930
app = Flask(__name__)
924931

@@ -952,21 +959,24 @@ def check_mfa_api():
952959
<PythonFrameworksCard.Content value="django">
953960

954961
```python
962+
from typing import cast
963+
955964
from django.http import HttpRequest
956-
from supertokens_python.recipe.session.framework.django.asyncio import verify_session
965+
966+
from supertokens_python.recipe.multifactorauth.multi_factor_auth_claim import (
967+
MultiFactorAuthClaim,
968+
)
957969
from supertokens_python.recipe.session import SessionContainer
958970
from supertokens_python.recipe.session.exceptions import (
959-
raise_invalid_claims_exception,
960971
ClaimValidationError,
972+
raise_invalid_claims_exception,
961973
)
962-
from supertokens_python.recipe.multifactorauth.multi_factor_auth_claim import (
963-
MultiFactorAuthClaim,
964-
)
974+
from supertokens_python.recipe.session.framework.django.asyncio import verify_session
965975

966976

967977
@verify_session()
968978
async def get_user_info_api(request: HttpRequest):
969-
session: SessionContainer = request.supertokens # type: ignore
979+
session: SessionContainer = cast(SessionContainer, request.supertokens) # type: ignore
970980
# highlight-start
971981
mfa_claim_value = await session.get_claim_value(MultiFactorAuthClaim)
972982
if mfa_claim_value is None:

docs/additional-verification/mfa/step-up-auth.mdx

Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -420,17 +420,19 @@ At the moment this feature is not supported through the Go SDK.
420420
<PythonFrameworksCard.Content value="fastapi">
421421

422422
```python
423+
import time
424+
423425
from fastapi import Depends
424-
from supertokens_python.recipe.session.framework.fastapi import verify_session
425-
from supertokens_python.recipe.session.exceptions import (
426-
raise_invalid_claims_exception,
427-
ClaimValidationError,
428-
)
429-
from supertokens_python.recipe.session import SessionContainer
426+
430427
from supertokens_python.recipe.multifactorauth.multi_factor_auth_claim import (
431428
MultiFactorAuthClaim,
432429
)
433-
import time
430+
from supertokens_python.recipe.session import SessionContainer
431+
from supertokens_python.recipe.session.exceptions import (
432+
ClaimValidationError,
433+
raise_invalid_claims_exception,
434+
)
435+
from supertokens_python.recipe.session.framework.fastapi import verify_session
434436

435437

436438
@app.post("/update-blog") # type: ignore
@@ -462,12 +464,19 @@ async def update_blog_api(session: SessionContainer = Depends(verify_session()))
462464
<PythonFrameworksCard.Content value="flask">
463465

464466
```python
467+
import time
468+
465469
from flask import Flask, g
466-
from supertokens_python.recipe.session.framework.flask import verify_session
470+
471+
from supertokens_python.recipe.multifactorauth.multi_factor_auth_claim import (
472+
MultiFactorAuthClaim,
473+
)
467474
from supertokens_python.recipe.session import SessionContainer
468-
from supertokens_python.recipe.session.exceptions import raise_invalid_claims_exception, ClaimValidationError
469-
from supertokens_python.recipe.multifactorauth.multi_factor_auth_claim import MultiFactorAuthClaim
470-
import time
475+
from supertokens_python.recipe.session.exceptions import (
476+
ClaimValidationError,
477+
raise_invalid_claims_exception,
478+
)
479+
from supertokens_python.recipe.session.framework.flask import verify_session
471480

472481
app = Flask(__name__)
473482

@@ -502,22 +511,25 @@ def check_mfa_api():
502511
<PythonFrameworksCard.Content value="django">
503512

504513
```python
514+
import time
515+
from typing import cast
516+
505517
from django.http import HttpRequest
506-
from supertokens_python.recipe.session.framework.django.asyncio import verify_session
518+
519+
from supertokens_python.recipe.multifactorauth.multi_factor_auth_claim import (
520+
MultiFactorAuthClaim,
521+
)
507522
from supertokens_python.recipe.session import SessionContainer
508523
from supertokens_python.recipe.session.exceptions import (
509-
raise_invalid_claims_exception,
510524
ClaimValidationError,
525+
raise_invalid_claims_exception,
511526
)
512-
from supertokens_python.recipe.multifactorauth.multi_factor_auth_claim import (
513-
MultiFactorAuthClaim,
514-
)
515-
import time
527+
from supertokens_python.recipe.session.framework.django.asyncio import verify_session
516528

517529

518530
@verify_session()
519531
async def get_user_info_api(request: HttpRequest):
520-
session: SessionContainer = request.supertokens # type: ignore
532+
session: SessionContainer = cast(SessionContainer, request.supertokens) # type: ignore
521533
# highlight-start
522534
mfa_claim_value = await session.get_claim_value(MultiFactorAuthClaim)
523535
assert mfa_claim_value is not None
@@ -639,20 +651,24 @@ At the moment this feature is not supported through the Go SDK.
639651
<BackendTabs.TabItem value="python">
640652

641653
```python
642-
from supertokens_python import init, InputAppInfo, SupertokensConfig
654+
import time
655+
from typing import Any, Awaitable, Callable, Dict, List
656+
657+
from supertokens_python import InputAppInfo, SupertokensConfig, init
643658
from supertokens_python.recipe import multifactorauth
644-
from supertokens_python.recipe.multifactorauth.types import FactorIds, OverrideConfig
645659
from supertokens_python.recipe.multifactorauth.interfaces import RecipeInterface
646-
from typing import Dict, Any, Callable, Awaitable, List
647-
from supertokens_python.recipe.session import SessionContainer
648-
from supertokens_python.recipe.multifactorauth.types import MFARequirementList
649660
from supertokens_python.recipe.multifactorauth.multi_factor_auth_claim import (
650661
MultiFactorAuthClaim,
651662
)
652-
import time
663+
from supertokens_python.recipe.multifactorauth.types import (
664+
FactorIds,
665+
MFARequirementList,
666+
OverrideConfig,
667+
)
668+
from supertokens_python.recipe.session import SessionContainer
653669
from supertokens_python.recipe.session.exceptions import (
654-
raise_invalid_claims_exception,
655670
ClaimValidationError,
671+
raise_invalid_claims_exception,
656672
)
657673

658674

0 commit comments

Comments
 (0)