Work

Apollo Bridge connects visitors with the stories behind artworks.

Apollo Bridge

Art discovery, with access under control.

Keycloak IdentityGo API Access controlPostgreSQL Artwork data

Visitors scan an artwork to discover information supplied by its gallery or museum. I built the main backend, with a focus on security, authentication and authorization.

The core access decision is simple: discovering art and managing a gallery's catalogue need different permissions. The Go API integrates with Keycloak for identity and uses roles to control sensitive artwork operations.

The repository's threat model maps the wider system, from the mobile client and backend to the image service and deployment pipeline. It provides the context for the security decisions below.

Role
Backend engineering, security, authentication & authorization
Product
Art discovery for galleries and museums
Stack
Go, Gin, Keycloak, JWT, PostgreSQL, GORM, Docker, Railway
01

Start with the threat model

Security extends beyond the API. Tokens, credentials, artwork data and model files cross different trust boundaries.

Map the system an attacker can reach

The model separates the client, Railway's backend and identity services, the dedicated AI training server, and the GitHub deployment pipeline. It distinguishes public traffic from private connections and marks where sensitive data lives.

Each boundary raises different questions: can someone hijack a session, escalate a role, inject a query, abuse an API or upload a malicious file? The model also includes developer credentials and compromised dependencies, because an attack does not have to start in the app.

Threat model showing the mobile client, Railway-hosted backend and Keycloak, a separate AI training server, databases, GitHub Actions and the developer machine. Trust boundaries separate these systems; threats include session hijacking, privilege escalation, SQL injection, API abuse and compromised credentials.
Original threat model from the backend repository. Open the diagram to inspect it at full size.

Turn threats into layers of protection

The backend's security documentation pairs injection risks with input validation, sanitization and parameterized database queries. Rate limiting addresses request abuse; security headers address browser-facing risks.

The model covers services beyond my main backend. Its image-upload and training-data threats describe the wider system's attack surface, rather than implying that API authentication alone protects every component.

02

Identity and permissions are separate checks

Keycloak handles identity. The Go backend consumes signed tokens and checks the roles needed by protected operations.

Verify the token's signature

The authentication middleware accepts a bearer token or an access-token cookie. It restricts signatures to RS256 and uses the token's key ID to find the matching public key in Keycloak's JWKS. A token-size limit rejects oversized input before parsing.

Signing in does not grant gallery permissions

The access middleware takes a required role and a client ID, then reads the client's roles from the JWT's resource_access claims. The documented access policy reserves posting, editing and deleting artworks for gallery users.

Keep session handling on the backend

The callback exchanges an authorization code with Keycloak and stores access and refresh tokens in Secure, HttpOnly cookies. The middleware includes a refresh flow that exchanges a refresh token for a new token pair when an access token expires.

The security document specifies ten-minute access tokens and rotating refresh tokens as the session policy. Those lifetimes and rotation rules depend on identity-provider configuration as well as backend code.