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

Remove Mosaic Write operations #217

Closed
vincentsarago opened this issue Feb 10, 2021 · 0 comments · Fixed by #218
Closed

Remove Mosaic Write operations #217

vincentsarago opened this issue Feb 10, 2021 · 0 comments · Fixed by #218

Comments

@vincentsarago
Copy link
Member

By default we add / (POST) and / (PUT) to the mosaicjson endpoint to either create or update a mosaicjson document. The problem is that if you add this to a AWS deployment and do not set your IAM correctly, someone could create mosaic on you S3 bucket.

I don't think the default implementation is good and I think we should remove them (and add examples)

############################################################################
# /create
############################################################################
def create(self):
"""Register / (POST) Create endpoint."""
@self.router.post(
"", response_model=MosaicJSON, response_model_exclude_none=True
)
def create(body: CreateMosaicJSON):
"""Create a MosaicJSON"""
mosaic = MosaicJSON.from_urls(
body.files,
minzoom=body.minzoom,
maxzoom=body.maxzoom,
max_threads=body.max_threads,
)
src_path = self.path_dependency(body.url)
with rasterio.Env(**self.gdal_config):
with self.reader(
src_path.url, mosaic_def=mosaic, reader=self.dataset_reader
) as mosaic:
try:
mosaic.write(overwrite=body.overwrite)
except NotImplementedError:
raise BadRequestError(
f"{mosaic.__class__.__name__} does not support write operations"
)
return mosaic.mosaic_def
############################################################################
# /update
############################################################################
def update(self):
"""Register / (PUST) Update endpoint."""
@self.router.put(
"", response_model=MosaicJSON, response_model_exclude_none=True
)
def update_mosaicjson(body: UpdateMosaicJSON):
"""Update an existing MosaicJSON"""
src_path = self.path_dependency(body.url)
with rasterio.Env(**self.gdal_config):
with self.reader(src_path.url, reader=self.dataset_reader) as mosaic:
features = get_footprints(body.files, max_threads=body.max_threads)
try:
mosaic.update(features, add_first=body.add_first, quiet=True)
except NotImplementedError:
raise BadRequestError(
f"{mosaic.__class__.__name__} does not support update operations"
)
return mosaic.mosaic_def

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant