Skip to content

Secure Map Service - #1277

Open
jakeymac wants to merge 88 commits into
mainfrom
secure-map-service
Open

jakeymac wants to merge 88 commits into
mainfrom
secure-map-service

Conversation

@jakeymac

@jakeymac jakeymac commented May 28, 2026

Copy link
Copy Markdown
Contributor

Description

This PR adds Secure Map Services to Tethys, enabling apps to register and consume map/image services that require authentication without exposing credentials to the browser.

The new feature supports:

  • API key authentication with encrypted storage
  • OAuth2 authentication tied to a user’s linked social auth account
  • optional proxying through Tethys Portal so credentials never reach the client
  • retrieving secure services as a map layer, endpoint, or server-side response
  • updating service parameters dynamically from app code

It also adds the supporting portal/admin UI, app-setting APIs, middleware for OAuth access requirements, CLI support for generating and managing a SALT_KEY, documentation, and tests.

Changes Made to Code

  • Added a new SecureMapService model in tethys_services for registering secure external map services
  • Added SecureMapServiceSetting support in tethys_apps so apps can bind to secure services
  • Added app-level APIs for:
    • declaring secure map service settings
    • retrieving a secure map service
    • updating service parameters
  • Added a secure proxy endpoint for browser-safe access to authenticated services
  • Added middleware to enforce app-specific OAuth account-link requirements
  • Added admin forms/UI for creating and editing secure map services
  • Extended map layout and gizmo support for token-aware map layers and GML layers
  • Added CLI support for SALT_KEY generation and portal config bootstrapping
  • Added documentation and a tutorial for using Secure Map Services
  • Added tests for the new models, views, middleware, CLI commands, and map behavior

Related PRs, Issues, and Discussions

  • None

Additional Notes

  • This PR introduces encryption support for stored API keys, so SALT_KEY must be configured in portal_config.yml.
  • OAuth-based secure services may require users to link the corresponding provider account before accessing the app.

Quality Checks

  • At least one new test has been written for new code
  • New code has 100% test coverage
  • Code has been formatted with Black
  • Code has been linted with flake8
  • Docstrings for new methods have been added
  • The documentation has been updated appropriately

* Added middleware to allow apps to require users to be authenticated with Oauth or be redirected to settings to get their account connected
* Added GRiD backend for Oauth authentication
* Added new basemap capabilities to allow secure map services to be used as basemaps
* Added proxy url route and view for secure requests to SecureMapService endpoints with authentication data
* Added helper methods for interacting with SecureMapServices and settings
@jakeymac jakeymac self-assigned this May 28, 2026
jakeymac added 2 commits June 27, 2026 09:48
* Added better error logging in fetch_response util method
* Updated secure map service proxy controller to accept any kind of request, not just GET
* Added form_id and draw attributes to MapLayout to allow for drawing and passing geometry to forms
* Fixed user_data in grid backend
@coveralls

coveralls commented Jul 30, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 99.02% (-1.0%) from 100.0% — secure-map-service into main

jakeymac added 3 commits July 30, 2026 15:24
…re map service settings

* Updated portal_config.yml file to have a generated SALT_KEY to use for encryption, updated settings.py to use this value
* Updated secure map proxy endpoint to always include browser params(params supplied from the browser(bbox, etc))
@jakeymac
jakeymac marked this pull request as ready for review August 3, 2026 17:19
Comment thread tethys_apps/models.py
…API key to query parameters

* Removed API key addition logic as it is now handled in get_resolved_params method
* Added timeout protection to _fetch_response method and to secure map proxy endpoint
* Updated response protection for Oauth2 responses in secure_map_proxy endpoint
…rieval of Oauth2 tokens

* Updated methods on SecureMapService class to all be private and updated references
* Updated SecureMapService and related additions to use OAuth2 name and updated references and documentation
* Refined CLI error handling to provide new and more correct error messages
* Black fixes
… for providers required by app(s) but that are not configured in the portal_config file.
…ing the install command function find the app_name using the parent folder name if install.yml is not present

* Updated install command to generate an install.yml file at a given
  file path if there isn't one there already
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants