Repository navigation
feat(postgres): add signed download URLs mutation for standalone backups - #681
Open
frodesundby wants to merge 4 commits into
Open
frodesundby wants to merge 4 commits into
frodesundby wants to merge 4 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Signing calls ignore cancellation, and the unpaginated backup inventory can trigger thousands of IAM requests and a large mutation response.
2 open issues
2 files not reviewed
internal/graph/gengql/postgres_backup.generated.go: Generated fileinternal/graph/gengql/schema.generated.go: Generated file
What changed in this PR
Adds standalone Postgres backup downloads to Nais API, allowing teams to copy backups directly from object storage without streaming data through the API.
Changes:
- Adds a mutation returning one-hour signed URLs and file integrity metadata.
- Enforces strict team authorization and records download creation.
- Wires signing configuration and adds validation and integration coverage.
| File | Description |
|---|---|
| internal/persistence/postgres/dataloader.go | Injects the backup archive store. |
| internal/persistence/postgres/backup_download.go | Validates manifests and generates signed URLs. |
| internal/persistence/postgres/backup_download_test.go | Tests archive validation and download metadata. |
| internal/persistence/postgres/backup_activitylog.go | Registers download activity logging. |
| internal/integration/manager.go | Updates integration configuration. |
| internal/graph/schema/postgres_backup.graphqls | Defines the download mutation and response. |
| internal/graph/postgres_backup.resolvers.go | Connects the mutation to domain logic. |
| internal/graph/gengql/schema.generated.go | Adds generated mutation handling. |
| internal/graph/gengql/root_.generated.go | Updates generated schema and complexity definitions. |
| internal/graph/gengql/postgres_backup.generated.go | Adds generated input and response handling. |
| internal/database/migrations/0087_add_postgres_backup_download_authorization.sql | Grants download permission to team roles. |
| internal/cmd/api/http.go | Configures and injects the archive store. |
| internal/cmd/api/config.go | Adds signing identity configuration. |
| internal/cmd/api/api.go | Passes the signing identity into setup. |
| internal/auth/authz/queries.go | Adds strict team download authorization. |
| integration_tests/postgres_backups.lua | Covers authorization, downloads, and auditing. |
| go.sum | Updates dependency checksums. |
| go.mod | Adds the storage client dependency. |
| charts/nais-api/templates/deployment.yaml | Supplies the signing service-account email. |
Review effort: Balanced
…ning - Reject manifests whose backupName, sourceUID, serverName or backupID do not match the PostgresBackup, and archive prefixes other than the backup name - Accept only manifest schemaVersion 1 and at most 10,000 objects - Stop scheduling IAM signing calls after a failure or canceled request - Record file count and URL expiry in the download activity log entry - Drop down migration from 0087 and clarify the file key documentation
frodesundby
marked this pull request as ready for review
December 4, 2026 13:26
thokra-nav
approved these changes
Dec 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
createPostgresBackupDownload(input: CreatePostgresBackupDownloadInput!): CreatePostgresBackupDownloadPayload!returningbackup,expiresAt(1h), andfiles { key url sizeBytes sha256 }(withnais-backup.jsonlast) so teams and tenants can build off-platform copy workflows without streaming backup bytes throughnais-api.postgres:backups:downloadauthorization enforced withrequireStrictTeamAuthorization(team members and team-scoped NaisServiceAccounts only; no global admin or global service account bypass).<prefix>/nais-backup.jsonfrom the backup's DR bucket, validates relative object paths and SHA-256 checksums, signs V4GETURLs usingGOOGLE_SERVICE_ACCOUNT_EMAIL(.Values.serviceaccount.emailfrom Fasit), and recordsPOSTGRES_BACKUP_DOWNLOAD_CREATEDin the activity log.Rollout
Requires nais/pgrator#248 (
roles/storage.objectVieweron team DR buckets fornais-api) to be rolled out first.