Skip to content

Commit b7793aa

Browse files
authored
Merge pull request #137 from python-ellar/authenticatation_docs
Authentication Docs
2 parents 596b37d + 0c9d58d commit b7793aa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+3398
-358
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
with:
1717
python-version: 3.8
1818
- name: Install Flit
19-
run: pip install flit
19+
run: pip install flit ellar_jwt
2020
- name: Install Dependencies
2121
run: flit install --symlink
2222
- name: Test

.github/workflows/test_full.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
with:
2020
python-version: ${{ matrix.python-version }}
2121
- name: Install Flit
22-
run: pip install flit
22+
run: pip install flit ellar_jwt
2323
- name: Install Dependencies
2424
run: flit install --symlink
2525
- name: Test

docs/img/auth_image.png

36.3 KB
Loading

docs/overview/guards.md

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,10 @@ When request execution for `/guarded-route`, `guarded_route` guard definition wi
106106
### **Global-scope**
107107
Global guards are used across the whole application, for every controller and every route function but individual controller or route function `@UseGuards` definition can override `global` scoped guards.
108108

109-
Global guards are applied at the `global_guards` parameter of the `AppFactory` creation level as shown below:
110-
```python
111-
# project_name/server.py
109+
Global guards can be applied at application level using `use_global_guards` as shown below:
110+
111+
```python title='project_name/server.py' linenums='1'
112+
112113
import os
113114

114115
from ellar.common.constants import ELLAR_CONFIG_MODULE
@@ -120,9 +121,32 @@ application = AppFactory.create_from_app_module(
120121
ApplicationModule,
121122
config_module=os.environ.get(
122123
ELLAR_CONFIG_MODULE, "dialerai.config:DevelopmentConfig"
123-
),
124-
global_guards=[RoleGuard]
124+
)
125+
)
126+
application.use_global_guards(RoleGuard, MoreGuards, ...)
127+
```
128+
Global Guards can also be applied through Dependency Injection. For instance, in `project_name/car/module.py`, we can
129+
register `RoleGuard` in the module `providers` parameter as a Global guards. See illustration below:
130+
131+
```python title='project_name/car/module.py' linenums='1'
132+
from ellar.common import Module, GlobalGuard
133+
from ellar.core import ModuleBase
134+
from ellar.di import Container, ProviderConfig
135+
136+
from .services import CarRepository
137+
from .controllers import CarController
138+
from .guards import RoleGuard
139+
140+
@Module(
141+
controllers=[CarController],
142+
providers=[CarRepository, ProviderConfig(GlobalGuard, use_class=RoleGuard)]
125143
)
144+
class CarModule(ModuleBase):
145+
def register_providers(self, container: Container) -> None:
146+
# for more complicated provider registrations
147+
# container.register_instance(...)
148+
pass
149+
126150
```
127151

128152
## **Rounding up RoleGuard**

docs/release-notes.md

Lines changed: 333 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)