mirror of
https://github.com/Novartis/cellxgene-gateway.git
synced 2026-10-09 12:08:11 +08:00
#42 add support for is_authorized hook
This commit is contained in:
@@ -214,7 +214,10 @@ def do_view(path, source_name=None):
|
|||||||
match.status == CacheEntryStatus.loaded
|
match.status == CacheEntryStatus.loaded
|
||||||
or match.status == CacheEntryStatus.loading
|
or match.status == CacheEntryStatus.loading
|
||||||
):
|
):
|
||||||
return match.serve_content(path)
|
if source.is_authorized(match.key.descriptor):
|
||||||
|
return match.serve_content(path)
|
||||||
|
else:
|
||||||
|
raise CellxgeneException("User not authorized to access this data", 403)
|
||||||
elif match.status == CacheEntryStatus.error:
|
elif match.status == CacheEntryStatus.error:
|
||||||
raise ProcessException.from_cache_entry(match)
|
raise ProcessException.from_cache_entry(match)
|
||||||
|
|
||||||
|
|||||||
@@ -121,6 +121,9 @@ class FileItemSource(ItemSource):
|
|||||||
if self.is_h5ad_file(full_path):
|
if self.is_h5ad_file(full_path):
|
||||||
return self.shallowitem_from_descriptor(descriptor)
|
return self.shallowitem_from_descriptor(descriptor)
|
||||||
|
|
||||||
|
def is_authorized(self, descriptor):
|
||||||
|
return True
|
||||||
|
|
||||||
def lookup(self, indescriptor: str) -> LookupResult:
|
def lookup(self, indescriptor: str) -> LookupResult:
|
||||||
descriptor = indescriptor.strip("/")
|
descriptor = indescriptor.strip("/")
|
||||||
if descriptor.endswith(self.annotation_file_suffix):
|
if descriptor.endswith(self.annotation_file_suffix):
|
||||||
|
|||||||
@@ -40,6 +40,10 @@ class ItemSource(ABC):
|
|||||||
def update(self, item: Item) -> None:
|
def update(self, item: Item) -> None:
|
||||||
raise Exception('"update" unimplemented')
|
raise Exception('"update" unimplemented')
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def is_authorized(self, descriptor: str) -> bool:
|
||||||
|
raise Exception('"is_authorized" unimplemented')
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def lookup(self, descriptor: str) -> LookupResult:
|
def lookup(self, descriptor: str) -> LookupResult:
|
||||||
raise Exception('"lookup" unimplemented')
|
raise Exception('"lookup" unimplemented')
|
||||||
|
|||||||
@@ -113,6 +113,9 @@ class S3ItemSource(ItemSource):
|
|||||||
def update(self, item: S3Item) -> None:
|
def update(self, item: S3Item) -> None:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def is_authorized(self, descriptor):
|
||||||
|
return True
|
||||||
|
|
||||||
def lookup_item(self, descriptor):
|
def lookup_item(self, descriptor):
|
||||||
full_path = self.url(descriptor)
|
full_path = self.url(descriptor)
|
||||||
if self.is_h5ad_url(full_path):
|
if self.is_h5ad_url(full_path):
|
||||||
|
|||||||
@@ -75,7 +75,9 @@
|
|||||||
const el = $(this);
|
const el = $(this);
|
||||||
const ts = el.text();
|
const ts = el.text();
|
||||||
const dt = new Date(parseInt(ts * 1000));
|
const dt = new Date(parseInt(ts * 1000));
|
||||||
el.html(`${dt.toISOString()}<br>(${ts})`);
|
el.prepend(`${dt.toISOString()}<br>(`);
|
||||||
|
el.append(')');
|
||||||
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user