Skip to content

Add federated-authorization example#48

Open
sohanmaheshwar wants to merge 6 commits into
mainfrom
federated-authorization-example
Open

Add federated-authorization example#48
sohanmaheshwar wants to merge 6 commits into
mainfrom
federated-authorization-example

Conversation

@sohanmaheshwar

Copy link
Copy Markdown
Contributor

What

Adds a new federated-authorization example: a self-contained demo of federated authentication with centralized fine-grained authorization in SpiceDB.

Users log in through different identity providers (Keycloak OIDC and GitHub OAuth). Each external account (keycloak_account, github_account) binds to a canonical internal user, and a single SpiceDB instance enforces document access control across all of them — so users from different IdPs can share resources with each other.

Contents

  • FastAPI app (app.py) with Keycloak + GitHub login flows
  • SpiceDB schema (spicedb/schema.zed) with the *_account → bound_to → user binding pattern
  • docker-compose.yml bringing up SpiceDB, Keycloak, and the app
  • Preconfigured Keycloak realm with demo users, HTML templates, and a README with setup steps

Everything runs locally via docker compose. Secrets are demo placeholders only; no real credentials are included.

Notes

  • The related docs tutorial lives at spicedb/tutorials/federated-authorization.

A self-contained demo of federated authentication with centralized fine-grained authorization in SpiceDB: users log in through different identity providers (Keycloak OIDC and GitHub OAuth), each external account binds to a canonical internal user, and a single SpiceDB instance enforces document access control across all of them.

Signed-off-by: Sohan Maheshwar <1119120+sohanmaheshwar@users.noreply.github.com>
Comment thread federated-authorization/app.py Fixed
Comment thread federated-authorization/app.py Fixed
Comment thread federated-authorization/app.py Fixed
Signed-off-by: Sohan Maheshwar <1119120+sohanmaheshwar@users.noreply.github.com>
Add document-start marker and quote all string values to satisfy the repo's quoted-strings yamllint rule.

Signed-off-by: Sohan Maheshwar <1119120+sohanmaheshwar@users.noreply.github.com>
The edit/share/unshare handlers interpolated the user-controlled doc_id path parameter straight into a redirect Location, which CodeQL flagged as URL redirection from a remote source. Document ids are always uuid.uuid4(), so normalize doc_id through uuid.UUID() at the top of each handler: invalid ids now return 404, and the redirect target can only contain hex digits and hyphens, so it cannot escape the /documents/ path.

Signed-off-by: Sohan Maheshwar <1119120+sohanmaheshwar@users.noreply.github.com>
@sohanmaheshwar
sohanmaheshwar force-pushed the federated-authorization-example branch from e4c2d14 to 1d43f54 Compare July 23, 2026 08:51
SpiceDB's REST gateway listens on :8443 inside the container, but the port was mapped from host 8090 to container 8080, so the documented http://localhost:8090 endpoint was unreachable (connection refused). Map 8090:8443 so the REST API is actually exposed.

Signed-off-by: Sohan Maheshwar <1119120+sohanmaheshwar@users.noreply.github.com>
Signed-off-by: Sohan Maheshwar <1119120+sohanmaheshwar@users.noreply.github.com>
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.

2 participants