Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: authorization #8

Merged
merged 33 commits into from
Nov 15, 2024
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
d834ed2
authz docs start
v-rocheleau Oct 11, 2024
b388fe1
feat: injectable tds authz middleware plugin
v-rocheleau Oct 16, 2024
38b851f
feat(authz): exempt docs and openapi from authz
v-rocheleau Oct 16, 2024
71e6d02
rm readme line
v-rocheleau Oct 16, 2024
3e82140
docs: authz plugin
v-rocheleau Oct 16, 2024
24d30aa
rm unused imports
v-rocheleau Oct 16, 2024
6c71652
feat(authz): plugin dependencies for routers and fastapi app
v-rocheleau Oct 16, 2024
c65d88a
chore(authz): example api key authz plugin
v-rocheleau Oct 16, 2024
a6c8377
typing and comments
v-rocheleau Oct 16, 2024
a351ecc
chore: authz docs split
v-rocheleau Oct 17, 2024
4fd27ee
init resource scoping for bento authz
v-rocheleau Oct 21, 2024
d73a196
debug service info for bento integration
v-rocheleau Oct 21, 2024
9ed9838
lint
v-rocheleau Oct 21, 2024
f163627
debug log and todo
v-rocheleau Oct 21, 2024
e18b8c9
perf: authz dep chain with injectable resource
v-rocheleau Oct 21, 2024
f1db249
feat: authz plugin extra settings
v-rocheleau Oct 23, 2024
479a846
lint
v-rocheleau Oct 23, 2024
9e780ee
authz plugin deps
v-rocheleau Oct 23, 2024
cc8bbe2
feat: authz plugin extra dependencies
v-rocheleau Oct 23, 2024
897158e
chore: add authz external dependency example
v-rocheleau Oct 28, 2024
f9f9533
Merge branch 'main' into feat/authz
v-rocheleau Oct 28, 2024
33d5fd7
docs: authz implementation methods tables
v-rocheleau Oct 31, 2024
cbf98b3
chore: authz docs and examples
v-rocheleau Nov 5, 2024
d87947c
docs: authz plugin diagram
v-rocheleau Nov 6, 2024
01c68dc
Merge branch 'main' into feat/authz
v-rocheleau Nov 6, 2024
34f886c
perf: authz plugin conditional load
v-rocheleau Nov 6, 2024
76372ac
address comments
v-rocheleau Nov 7, 2024
7670cdb
chore: re organise authz plugin examples
v-rocheleau Nov 11, 2024
d3cf72e
rewording and comments
v-rocheleau Nov 12, 2024
f3972c2
address comments
v-rocheleau Nov 14, 2024
f982a31
chore: linting with ruff
v-rocheleau Nov 14, 2024
733d1ca
lint
v-rocheleau Nov 14, 2024
bfb9ac0
chore: replace black with ruff formater
v-rocheleau Nov 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
perf: authz plugin conditional load
  • Loading branch information
v-rocheleau committed Nov 6, 2024
commit 34f886c892575b1535748377faa29a7777d16d5d
21 changes: 11 additions & 10 deletions transcriptomics_data_service/authz/plugin.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
import importlib.util

from fastapi import Request
from types import ModuleType

from transcriptomics_data_service.authz.middleware_base import BaseAuthzMiddleware
from transcriptomics_data_service.config import get_config
from transcriptomics_data_service.logger import get_logger

__all__ = ["authz_plugin"]

config = get_config()

def import_module_from_path(path):
spec = importlib.util.spec_from_file_location("authz_plugin", path)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
return module

def import_module_from_path(path) -> None | ModuleType:
if config.bento_authz_enabled:
spec = importlib.util.spec_from_file_location("authz_plugin", path)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
return module.authz_middleware
else:
return None

AUTHZ_MODULE_PATH = "/tds/lib/authz.module.py"
authz_plugin_module = import_module_from_path(AUTHZ_MODULE_PATH)

# Get the concrete authz middleware from the provided plugin module
authz_plugin: BaseAuthzMiddleware = authz_plugin_module.authz_middleware
authz_plugin = import_module_from_path("/tds/lib/authz.module.py")
v-rocheleau marked this conversation as resolved.
Show resolved Hide resolved