The Simplest Way to Make Cloud SQL and Gitea Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Pairing cloud sql and gitea gives your team a fast, self-hosted code system. Gitea stores git metadata, issues, and user accounts inside your managed database. This setup keeps your source control state out of local disk storage. Your database handles backups and high availability while the Gitea server stays stateless. When a node fails, you can start a fresh instance right away. Both tools work well together when you lock down roles and network paths. How cloud sql and gitea share data and

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

Pairing cloud sql and gitea gives your team a fast, self-hosted code system. Gitea stores git metadata, issues, and user accounts inside your managed database.

This setup keeps your source control state out of local disk storage. Your database handles backups and high availability while the Gitea server stays stateless. When a node fails, you can start a fresh instance right away. Both tools work well together when you lock down roles and network paths.

How cloud sql and gitea share data and roles

Gitea needs a database to track pull requests, webhooks, and repo permissions. Git files live on disk or object storage, while metadata goes into tables. Every page load or git push triggers reads and writes to the database.

In Cloud SQL for PostgreSQL, customers cannot make users with full superuser status. A system user named cloudsqladmin holds the top rights on the server. Customers cannot delete or change these built-in system roles. Instead, you get a default admin user named postgres. This user comes with no password, so you must set one to log in. It belongs to the cloudsqlsuperuser group, which gives it some high-level rights.

You should not run your Gitea app with the default postgres account. That user can make new databases, add roles, and set up event triggers. Instead, use that admin account one time to make a dedicated Gitea user. Give this new user rights only to the single Gitea database schema. Now the app can read and write its own tables without extra risk.

Fixing common risks between the app and database

Many teams put a shared database password into a plain text file. Then anyone who reads the server disk can steal that database key. Even worse, developers often use that same account to run manual queries. When something breaks, your logs only show the shared app user name. You have no way to tell which person ran a bad command.

Broad network paths create another big risk for your source control data. If the database has an open public address, outside attackers can probe it. You should keep traffic between the git server and database on private networks. Restrict network rules so only the Gitea compute nodes can reach the database port.

End-to-End Encryption + SQL Query Filtering: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Human access needs a separate path from the background app server traffic. Engineers sometimes need to inspect Gitea tables to fix a stuck migration. Give each engineer an individual identity rather than the app database password. Map their work email to a read-only database role for safe checks. When you need to protect sensitive columns, data masking rewrites matched fields in results. For example, masking can rewrite user emails or phone numbers during a query.

Keeping day-to-day database operations safe

Routine updates to Gitea often change tables and add new database indexes. During an upgrade, the app might need rights to alter its own schema. You can grant schema change rights to a specific migration role during updates. Once the update finishes, the daily app role only needs basic data rights.

Audit logs help you track both app traffic and human database queries. Turn on database logging to see failed logins and schema changes right away. Review these logs often to spot unusual query spikes from your git servers. Separating app roles from human roles makes every log entry clear and useful.

Govern statements and responses across databases and APIs

Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.

First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.

Frequently asked questions

Can Gitea use the default postgres user in Cloud SQL?

It can, but you should avoid doing this in a live setup. The default postgres user has broad rights to make roles and new databases. Create a scoped user that only owns the specific Gitea database instead.

Why does my Cloud SQL admin lack full superuser rights?

Cloud SQL is a managed service, so the provider keeps true superuser rights. Your admin gets the cloudsqlsuperuser role, which still handles extensions and triggers.

How should engineers inspect the Gitea database during an outage?

Engineers should never copy the database password from the Gitea server file. Give them individual read-only roles tied to their own team identities instead. This keeps an accurate log of every query run during the fix.

The query runs. The emails stay hidden.