|
| 1 | +# Getting Started |
| 2 | + |
| 3 | +STAC Auth Proxy is a reverse proxy that adds authentication and authorization to your STAC API. It sits between clients and your STAC API, validating tokens to authenticate request and applying custom authorization rules. |
| 4 | + |
| 5 | +## Core Requirements |
| 6 | + |
| 7 | +To get started with STAC Auth Proxy, you need to provide two essential pieces of information: |
| 8 | + |
| 9 | +### 1. OIDC Discovery URL |
| 10 | + |
| 11 | +You need a valid OpenID Connect (OIDC) discovery URL that points to your identity provider's configuration. This URL typically follows the pattern: |
| 12 | + |
| 13 | +``` |
| 14 | +https://your-auth-provider.com/.well-known/openid-configuration |
| 15 | +``` |
| 16 | + |
| 17 | +> [!TIP] |
| 18 | +> |
| 19 | +> Common OIDC providers include: |
| 20 | +> |
| 21 | +> - **Auth0**: `https://{tenant-id}.auth0.com/.well-known/openid-configuration` |
| 22 | +> - **AWS Cognito**: `https://cognito-idp.{region}.amazonaws.com/{user-pool-id}/.well-known/openid-configuration` |
| 23 | +> - **Azure AD**: `https://login.microsoftonline.com/{tenant-id}/v2.0/.well-known/openid-configuration` |
| 24 | +> - **Google**: `https://accounts.google.com/.well-known/openid-configuration` |
| 25 | +> - **Keycloak**: `https://{keycloak-server}/auth/realms/{realm-id}/.well-known/openid-configuration` |
| 26 | +
|
| 27 | +### 2. Upstream STAC API URL |
| 28 | + |
| 29 | +You need the URL to your upstream STAC API that the proxy will protect: |
| 30 | + |
| 31 | +``` |
| 32 | +https://your-stac-api.com/stac |
| 33 | +``` |
| 34 | + |
| 35 | +This should be a valid STAC API that conforms to the STAC specification. |
| 36 | + |
| 37 | +## Quick Start |
| 38 | + |
| 39 | +Here's a minimal example to get you started: |
| 40 | + |
| 41 | +### Using Docker |
| 42 | + |
| 43 | +```bash |
| 44 | +docker run -p 8000:8000 \ |
| 45 | + -e UPSTREAM_URL=https://your-stac-api.com/stac \ |
| 46 | + -e OIDC_DISCOVERY_URL=https://your-auth-provider.com/.well-known/openid-configuration \ |
| 47 | + ghcr.io/developmentseed/stac-auth-proxy:latest |
| 48 | +``` |
| 49 | + |
| 50 | +### Using Python |
| 51 | + |
| 52 | +1. Install the package: |
| 53 | + ```bash |
| 54 | + pip install stac-auth-proxy |
| 55 | + ``` |
| 56 | +2. Set environment variables: |
| 57 | + ```bash |
| 58 | + export UPSTREAM_URL=https://your-stac-api.com/stac |
| 59 | + export OIDC_DISCOVERY_URL=https://your-auth-provider.com/.well-known/openid-configuration |
| 60 | + ``` |
| 61 | +3. Run the proxy: |
| 62 | + ```bash |
| 63 | + python -m stac_auth_proxy |
| 64 | + ``` |
| 65 | + |
| 66 | +### Using Docker Compose |
| 67 | + |
| 68 | +For development and experimentation, the codebase (ie within the repository, not within the Docker or Python distributions) ships with a `docker-compose.yaml` file, allowing the proxy to be run locally alongside various supporting services: the database, the STAC API, and a Mock OIDC provider. |
| 69 | + |
| 70 | +#### pgSTAC Backend |
| 71 | + |
| 72 | +Run the application stack with a pgSTAC backend using [stac-fastapi-pgstac](https://github.com/stac-utils/stac-fastapi-pgstac): |
| 73 | + |
| 74 | +```sh |
| 75 | +docker compose up |
| 76 | +``` |
| 77 | + |
| 78 | +#### OpenSearch Backend |
| 79 | + |
| 80 | +Run the application stack with an OpenSearch backend using [stac-fastapi-elasticsearch-opensearch](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch): |
| 81 | + |
| 82 | +```sh |
| 83 | +docker compose --profile os up |
| 84 | +``` |
| 85 | + |
| 86 | +The proxy will start on `http://localhost:8000` by default. |
| 87 | + |
| 88 | +## What Happens Next? |
| 89 | + |
| 90 | +Once the proxy starts successfully: |
| 91 | + |
| 92 | +1. **Health Check**: The proxy verifies your upstream STAC API is accessible |
| 93 | +2. **Conformance Check**: It ensures your STAC API conforms to required specifications |
| 94 | +3. **OIDC Discovery**: It fetches and validates your OIDC provider configuration |
| 95 | +4. **Ready**: The proxy is now ready to handle requests |
| 96 | + |
| 97 | +## Testing Your Setup |
| 98 | + |
| 99 | +You can test that your proxy is working by accessing the health endpoint: |
| 100 | + |
| 101 | +```bash |
| 102 | +curl http://localhost:8000/healthz |
| 103 | +``` |
| 104 | + |
| 105 | +## Next Steps |
| 106 | + |
| 107 | +- [Configuration Guide](configuration.md) - Learn about all available configuration options |
| 108 | +- [Route-Level Authentication](route-level-auth.md) - Configure which endpoints require authentication |
| 109 | +- [Record-Level Authentication](record-level-auth.md) - Set up content filtering based on user permissions |
0 commit comments