@@ -663,7 +663,7 @@ class JWTAuthentication(HttpBearerAuthenticationHandler):
663
663
664
664
Let us make ` JWTAuthentication ` Handler available for ellar to use as shown below
665
665
666
- ``` python title='server.py' linenums='1'
666
+ ``` python title='project_name. server.py' linenums='1'
667
667
import os
668
668
from ellar.common.constants import ELLAR_CONFIG_MODULE
669
669
from ellar.core.factory import AppFactory
@@ -693,7 +693,7 @@ Also, we need to remove `GlobalGuard` registration we did in `AuthModule`, so th
693
693
Next, we register a simple guard ` AuthenticationRequiredGuard ` globally to the application. ` AuthenticationRequiredGuard ` is a simply guard
694
694
that checks if a request has a valid user identity.
695
695
696
- ``` python title='server.py' linenums='1'
696
+ ``` python title='project_name. server.py' linenums='1'
697
697
import os
698
698
from ellar.common.constants import ELLAR_CONFIG_MODULE
699
699
from ellar.core.factory import AppFactory
@@ -707,12 +707,13 @@ application = AppFactory.create_from_app_module(
707
707
config_module = os.environ.get(
708
708
ELLAR_CONFIG_MODULE , " project_name.config:DevelopmentConfig"
709
709
),
710
- global_guards = [AuthenticatedRequiredGuard]
710
+ global_guards = [AuthenticatedRequiredGuard( ' JWTAuthentication ' ) ]
711
711
)
712
712
application.add_authentication_schemes(JWTAuthentication)
713
713
```
714
714
We need to refactor auth controller and mark refresh and sign_in function as public routes
715
- ``` python
715
+
716
+ ``` python title='auth.controller.py' linenums='1'
716
717
from ellar.common import Controller, ControllerBase, post, Body, get
717
718
from ellar.auth import SkipAuth
718
719
from ellar.openapi import ApiTags
0 commit comments