Skip to content

Commit

Permalink
add TenantService to example
Browse files Browse the repository at this point in the history
  • Loading branch information
byewokko committed Nov 7, 2024
1 parent 25e872f commit 2dfb4b5
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions examples/web-auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,17 @@ def __init__(self):
self.ApiService = ApiService(self)
self.ApiService.initialize_web(self.WebContainer)

# Initialize authorization
# Initialize multitenancy and authorization
self.TenantService = asab.web.tenant.TenantService(self)
self.AuthService = asab.web.auth.AuthService(self)

# Add routes
self.WebContainer.WebApp.router.add_get("/", self.info)
self.WebContainer.WebApp.router.add_get("/note", self.list_notes)
self.WebContainer.WebApp.router.add_post("/note", self.create_note)
self.WebContainer.WebApp.router.add_get("/note/{note_id}", self.read_note)
self.WebContainer.WebApp.router.add_put("/note/{note_id}", self.edit_note)
self.WebContainer.WebApp.router.add_delete("/note/{note_id}", self.delete_note)
self.WebContainer.WebApp.router.add_get("/{tenant}/note", self.list_notes)
self.WebContainer.WebApp.router.add_post("/{tenant}/note", self.create_note)
self.WebContainer.WebApp.router.add_get("/{tenant}/note/{note_id}", self.read_note)
self.WebContainer.WebApp.router.add_put("/{tenant}/note/{note_id}", self.edit_note)
self.WebContainer.WebApp.router.add_delete("/{tenant}/note/{note_id}", self.delete_note)

# Notes storage
self.Notes: typing.Dict[str, typing.Dict[str, typing.Dict[str, str]]] = {
Expand All @@ -84,6 +85,7 @@ def __init__(self):


@asab.web.auth.noauth
@asab.web.tenant.allow_no_tenant
async def info(self, request):
"""
Show application info.
Expand Down

0 comments on commit 2dfb4b5

Please sign in to comment.