Allow anonymous public asset downloads and adopt OSM Liberty style for MapLibre demo.
CI / test (push) Successful in 4s
CI / test (push) Successful in 4s
Public asset links now work without bearer auth while private assets remain protected, and the demo ships with the local osm-liberty-gl-style assets for consistent tile rendering. Made-with: Cursor
This commit is contained in:
@@ -141,6 +141,17 @@ func (a *API) authUser(r *http.Request) (string, error) {
|
||||
return a.service.AuthenticateSession(token)
|
||||
}
|
||||
|
||||
func (a *API) authUserOptional(r *http.Request) (string, error) {
|
||||
if strings.TrimSpace(r.Header.Get("Authorization")) == "" {
|
||||
return "", nil
|
||||
}
|
||||
token, err := bearerToken(r)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return a.service.AuthenticateSession(token)
|
||||
}
|
||||
|
||||
func (a *API) health(w http.ResponseWriter, _ *http.Request) {
|
||||
writeJSON(w, http.StatusOK, map[string]string{"status": "ok", "time": time.Now().UTC().Format(time.RFC3339)})
|
||||
}
|
||||
@@ -475,7 +486,7 @@ func (a *API) uploadAsset(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func (a *API) downloadAsset(w http.ResponseWriter, r *http.Request) {
|
||||
user, err := a.authUser(r)
|
||||
user, err := a.authUserOptional(r)
|
||||
if err != nil {
|
||||
writeErr(w, err)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user