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

add titiler in map attributions #1030

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release Notes

## 0.19.1 (2024-11-14)

* Add `titiler` links in Map attributions

## 0.19.0 (2024-11-07)

### Misc
Expand Down
38 changes: 19 additions & 19 deletions src/titiler/application/titiler/application/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,27 +50,27 @@

api_settings = ApiSettings()

###############################################################################
# Setup a global API access key, if configured
api_key_query = APIKeyQuery(name="access_token", auto_error=False)

app_dependencies = []
if api_settings.global_access_token:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not related but I figured this was a better way to do it

###############################################################################
# Setup a global API access key, if configured
api_key_query = APIKeyQuery(name="access_token", auto_error=False)

def validate_access_token(access_token: str = Security(api_key_query)):
"""Validates API key access token, set as the `api_settings.global_access_token` value.
Returns True if no access token is required, or if the access token is valid.
Raises an HTTPException (401) if the access token is required but invalid/missing.
"""
if not access_token:
raise HTTPException(status_code=401, detail="Missing `access_token`")

# if access_token == `token` then OK
if access_token != api_settings.global_access_token:
raise HTTPException(status_code=401, detail="Invalid `access_token`")

def validate_access_token(access_token: str = Security(api_key_query)):
"""Validates API key access token, set as the `api_settings.global_access_token` value.
Returns True if no access token is required, or if the access token is valid.
Raises an HTTPException (401) if the access token is required but invalid/missing.
"""
if api_settings.global_access_token is None:
return True

if not access_token:
raise HTTPException(status_code=401, detail="Missing `access_token`")

# if access_token == `token` then OK
if access_token != api_settings.global_access_token:
raise HTTPException(status_code=401, detail="Invalid `access_token`")

return True
app_dependencies.append(Depends(validate_access_token))


###############################################################################
Expand All @@ -91,7 +91,7 @@ def validate_access_token(access_token: str = Security(api_key_query)):
""",
version=titiler_version,
root_path=api_settings.root_path,
dependencies=[Depends(validate_access_token)],
dependencies=app_dependencies,
)

###############################################################################
Expand Down

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/titiler/core/titiler/core/templates/map.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,12 @@
var map = L.map('map', {
crs: crs,
minZoom: {{ tms.minzoom }},
maxZoom: {{ tms.maxzoom }}
maxZoom: {{ tms.maxzoom }},
attributionControl: false
});

L.control.attribution({prefix: '<a href="https://leafletjs.com" target="_blank">Leaflet</a> | <a href="https://developmentseed.org/titiler" target="_blank">Titiler</a>'}).addTo(map)

const nullIsland = L.marker([0, 0]).addTo(map);
const madrid = L.marker([40, -3]).addTo(map);
const london = L.marker([51.50722, -0.1275]).addTo(map)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,10 @@
'basemap': {
type: 'raster',
tiles: [
'https://tile.openstreetmap.org/{z}/{x}/{y}.png'
'https://tile.openstreetmap.org/{z}/{x}/{y}.png'
],
tileSize: 256,
attribution: '<a href="http://www.openstreetmap.org/copyright">© OpenStreetMap</a>'
attribution: '<a href="https://developmentseed.org/titiler" target="_blank">Titiler</a> | <a href="http://www.openstreetmap.org/copyright">© OpenStreetMap</a>'
}
},
layers: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,10 @@
'basemap': {
type: 'raster',
tiles: [
'https://tile.openstreetmap.org/{z}/{x}/{y}.png'
'https://tile.openstreetmap.org/{z}/{x}/{y}.png'
],
tileSize: 256,
attribution: '<a href="http://www.openstreetmap.org/copyright">© OpenStreetMap</a>'
attribution: '<a href="https://developmentseed.org/titiler" target="_blank">Titiler</a> | <a href="http://www.openstreetmap.org/copyright">© OpenStreetMap</a>'
}
},
layers: [
Expand Down