Skip to content

Ways to configure validations/restrictions for http:// urls #412

Answered by vincentsarago
jfbourgon asked this question in Q&A
Discussion options

You must be logged in to vote

@jfbourgon I'm not sure to understand. if you want to filter what input dataset url a user can use within the TiTiler application you could simply use a custom path_dependency dependency.

from titiler.core.factory import TilerFactory
from titiler.core.errors import DEFAULT_STATUS_CODES, add_exception_handlers

from fastapi import FastAPI


white_list = [
    "https://mydata.io/",
    "https://yourdata.io/",
]

# Custom Path dependency which can `decode` a base64 url
def DatasetPathParams(
    url: str = Query(..., description="Dataset URL"),
) -> str:
    """Create dataset path from args"""
    if not any([url.startswith(x) for x in white_list]):
        raise HTTPException(status_code=404, 

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jfbourgon
Comment options

Answer selected by vincentsarago
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants