Skip to content

Let chapter 7's read-side run against the deployment - #62

Open
alukach wants to merge 1 commit into
feat/stac-auth-proxy-lambdafrom
feat/cognito-password-auth
Open

alukach wants to merge 1 commit into
feat/stac-auth-proxy-lambdafrom
feat/cognito-password-auth

Conversation

@alukach

@alukach alukach commented Sep 14, 2026

Copy link
Copy Markdown
Member

Targets feat/stac-auth-proxy-lambda (#49), not main.

Chapter 7 says it needs docker-compose. Only half of it does — sections 7.4 to 7.5.1 just read, and the deployed proxy already runs the same filter against the seeded private-alice-demo and private-bob-demo collections. This makes that half actually runnable, and narrows the warning to match.

Two things were in the way

A notebook could not sign in to Cognito without a browser. Confirmed against the live pool:

InvalidParameterException: USER_PASSWORD_AUTH flow not enabled for this client

Now enabled on the app client. It does not weaken the write protection: Cognito issues USER_PASSWORD_AUTH tokens scoped aws.cognito.signin.user.admin and never the custom stac/* scopes, so such a token still fails the scope check in PRIVATE_ENDPOINTS. It carries username, which is all the row-level filter reads.

user_srp is named alongside it deliberately — specifying any flow replaces Cognito's implicit defaults, and silently dropping SRP would be an unintended narrowing of the client.

The narrowed warning would have been a half-truth without a way to act on it. The notebook calls require_local_auth_stack(), which hard-fails without MOCK_OIDC_ENDPOINT. So docs/stac_auth.py gains deployed_auth() and get_cognito_token(), and §7.3.3 gains a short snippet showing the swap — the setup cell, the seeded collection ids, and where to stop.

Verification

deployed_auth() exercised against the live config endpoint: returns the proxy endpoint, client id, the region parsed out of the discovery URL, and the shared password.

get_cognito_token() currently fails with exactly the USER_PASSWORD_AUTH flow not enabled error above — which is the redeploy and nothing else. Worth confirming after deploy that a token really does come back carrying username; the scope claim is documented Cognito behaviour rather than something I could test pre-deploy.

Also ran: cdk synth (OK, ExplicitAuthFlows now ['ALLOW_USER_PASSWORD_AUTH', 'ALLOW_USER_SRP_AUTH', 'ALLOW_REFRESH_TOKEN_AUTH']), the filter self-check, notebook JSON validity, ruff.

Why 7.6 stays local

Not only because writes are disabled. These tokens carry no stac/write scope, so the write-rejection demo would fail at route-level auth rather than demonstrating row-level auth — the right answer for the wrong reason, which is worse than not showing it.

On the related question of getting custom scopes at all: stac/read and stac/write are only issuable from the OAuth token endpoint (/oauth2/token), via authorization_code (needs a browser redirect) or client_credentials (needs a client secret and has no user identity, so no username claim). The InitiateAuth flows don't take a scope parameter at all. So a headless token carrying both a user identity and a custom scope isn't reachable through Cognito's supported APIs — which is the constraint that shapes this split.

🤖 Generated with Claude Code

https://claude.ai/code/session_01P1CCcrx5fDKuAGsNh8DUFG

Chapter 7 claimed it needed docker-compose. Only half of it does. Sections
7.4 to 7.5.1 just read, and the deployed proxy already runs the same filter
against seeded `private-alice-demo` and `private-bob-demo` collections.

Two things were in the way.

A notebook could not sign in to Cognito without a browser. Confirmed
against the live pool:

  InvalidParameterException: USER_PASSWORD_AUTH flow not enabled for this client

Enable that flow on the app client. It does not weaken the write
protection: Cognito issues USER_PASSWORD_AUTH tokens scoped
`aws.cognito.signin.user.admin` and never the custom `stac/*` scopes, so
such a token still fails PRIVATE_ENDPOINTS. It does carry `username`, which
is all the row-level filter reads. `user_srp` is named alongside it because
specifying any flow replaces Cognito's implicit defaults, and silently
dropping SRP would be an unintended narrowing.

Second, the narrowed warning would have been a half-truth without a way to
act on it -- the notebook calls require_local_auth_stack(), which hard-fails
without MOCK_OIDC_ENDPOINT. Add `deployed_auth()` and `get_cognito_token()`
to docs/stac_auth.py, and a 7.3.3 snippet showing the swap.

Verified `deployed_auth()` against the live config endpoint: it returns the
proxy endpoint, client id, region parsed from the discovery URL, and the
shared password. `get_cognito_token()` currently fails with exactly the
error above, which is the redeploy and nothing else.

Section 7.6 stays local, and not only because writes are disabled: these
tokens carry no `stac/write` scope, so the write rejection there would fail
at route-level auth rather than demonstrating row-level auth -- the right
answer for the wrong reason.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P1CCcrx5fDKuAGsNh8DUFG
@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant