Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,19 @@ GITDB_SYNC_POLL_SECONDS=60
# NOTIFICATION_SMTP_PASSWORD=
# NOTIFICATION_SMTP_FROM=noreply@example.com
# NOTIFICATION_SMTP_FROM_NAME=GitOps
# NOTIFICATION_SMTP_REJECT_UNAUTHORIZED=true# Git repository backing GitDB. Cloned into /data/gitdb at startup.
# NOTIFICATION_SMTP_REJECT_UNAUTHORIZED=true

# Optional cluster-wide Google sign-in (OpenID Connect). Shown on the login page when both the
# client ID and secret are set. Redirect URI to register in GCP: <ORIGIN>/auth/sso/google/callback
GOOGLE_SSO_CLIENT_ID=
GOOGLE_SSO_CLIENT_SECRET=
# Comma-separated Google Workspace domains allowed to sign in (empty: any verified Google account)
GOOGLE_SSO_ALLOWED_DOMAINS=gigigo.com,example.org
# Sign up unknown Workspace accounts of the allowed domains as cluster users (needs allowed domains)
GOOGLE_SSO_AUTO_PROVISION=


# Git repository backing GitDB. Cloned into /data/gitdb at startup.
GITDB_REPOSITORY_URL=git@github.com:getgitops/gitops-db-dev.git
GITDB_BRANCH=main

Expand Down
35 changes: 27 additions & 8 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,24 @@ con SvelteKit. Mantener este archivo y `CLAUDE.md` equivalentes en arquitectura

GitOps combina autenticacion y RBAC, organizaciones y proyectos, Open Report de seguridad y
visibilidad de Pulumi State. La ruta Vault es actualmente una base visual sin backend completo.
Google SSO y SAML son configuracion, no estrategias de autenticacion implementadas.

Google SSO es a nivel de sistema y se configura solo con variables de entorno
(`GOOGLE_SSO_CLIENT_ID`, `GOOGLE_SSO_CLIENT_SECRET` y, opcionales, `GOOGLE_SSO_ALLOWED_DOMAINS` y
`GOOGLE_SSO_AUTO_PROVISION`), leídas en cada request por `readGoogleSsoConfig()` desde
`src/modules/auth/infrastructure/config/google-sso.config.ts` en `GoogleSsoConfig`; nada se
persiste en GitDB. Si ambas credenciales están válidas, `/auth/login` muestra "Continuar con
Google" y `/org/<org>/settings/global` muestra Google SSO en solo lectura (sin exponer credenciales).
Una configuración inválida (credencial faltante, dominio inválido, inconsistencia en auto-provision)
se silencia como deshabilitada y se registra la razón; la UI nunca se rompe. `ssoService` en
`$modules/auth` ejecuta Authorization Code + PKCE (`/auth/sso/google/start` y
`/auth/sso/google/callback`, ambas sin sesión), verifica el ID token contra JWKS de Google con
`GoogleOidcClient` y autentica al usuario existente y no deshabilitado por `sub` o email verificado;
vincula el `sub` en `user.authProviders[]` y acepta invitaciones pendientes. Los dominios se
comprueban contra el claim `hd` de Workspace, no email. Con `GOOGLE_SSO_AUTO_PROVISION=true`
(requiere dominios permitidos), una cuenta Workspace desconocida recibe una cuenta GitOps User (`cluster-user`)
activa sin organización vía `userAccessService.provisionClusterUser()`. `user.disabled` solo lo
aplica Google sign-in. Templates de notificación (`src/notifications/`) se leen en tiempo de
ejecución. SAML es configuración solo.

- SvelteKit 2, Svelte 5, Vite 8 y TypeScript 6 strict
- Tailwind CSS 4 y `@lucide/svelte`
Expand All @@ -17,6 +34,8 @@ Google SSO y SAML son configuracion, no estrategias de autenticacion implementad
- Vitest, ESLint y Prettier
- Playwright para tests e2e de RBAC (`e2e/`)

Las variables de entorno se declaran en `src/env.ts` y se documentan en `.env.example`; Google SSO usa las `GOOGLE_SSO_*` descritas arriba.

Comandos:

```bash
Expand Down Expand Up @@ -80,12 +99,12 @@ para obtener flags de lectura de alto nivel que se filtran en AppSidebar según
Roles por defecto en `src/modules/auth/domain/role-permissions.data.ts`. Los permisos incluyen scope
como prefijo (ej: `organization:projects:read`, `project:vault:secrets:all`) y se almacenan verbatim sin
transformaciones. Recursos de módulos tienen sub-permisos granulares (ej: `project:vault:secrets:read`, `project:vault:environments:read`):
- **Cluster Admin**: vault, openreport, stateiac (todos)
- **Cluster User**: sin permisos propios; rol base para acceso a nivel cluster
- **Organization Admin**: todos los permisos de org (proyectos, usuarios, roles, configuración global, backups, server-access-keys, audit)
- **Organization Developer**: solo read/create/update de proyectos
- **Project Admin**: metadata/usuarios/roles/server-keys/audit plus todos los permisos de módulos (vault, codereport, stateiac)
- **Project Developer/Viewer**: acceso granular a módulos con permisos diferenciados (solo lectura en Viewer)
- **GitOps Admin** (`cluster-admin`) — vault, openreport, stateiac (todos)
- **GitOps User** (`cluster-user`) — rol base sin permisos propios para acceso a nivel sistema
- **Organization Admin** — todos los permisos de org (proyectos, usuarios, roles, configuración global, backups, server-access-keys, audit)
- **Organization Developer** — solo read/create/update de proyectos
- **Project Admin** — metadata/usuarios/roles/server-keys/audit plus todos los permisos de módulos (vault, codereport, stateiac)
- **Project Developer/Viewer** — acceso granular a módulos con permisos diferenciados (solo lectura en Viewer)

Los permisos de organización se propagan a sus proyectos solo cuando no hay un assignment explícito a nivel de
proyecto. Un usuario con `organization:projects:read` puede satisfacer `project:project:read` en cualquier
Expand All @@ -95,7 +114,7 @@ aplican (regla most-specific-wins). Permite delegación de autoridad granular co
`canManageOrganization()` controla acceso al area `/settings`, mientras que `canViewOrganization()` incluye
tambien usuarios con acceso solo a proyectos bajo la organización (ven el overview pero no pueden acciones de org-scope).

Al crear una organizacion (via bootstrap o cluster-settings), se llama automaticamente a
Al crear una organización (vía bootstrap o `/gitops-settings`), se llama automáticamente a
`roleService.createDefaultOrganizationRoles()`. Al crear un proyecto, se llama a
`roleService.createDefaultProjectRoles()`. Ambas operaciones inicializan sus roles por defecto.

Expand Down
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
# Mantiene al día los SHA de las actions fijadas en los workflows.
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
# No se adoptan releases de menos de 7 días.
cooldown:
default-days: 7
18 changes: 9 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quita los checksum, directamente la version como tenia, no necesitamos esos checksum, haz que la IA en contexto lo ponga


- name: Setup Bun
uses: oven-sh/setup-bun@v2
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version: latest
bun-version: 1.4.3

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

esto si, dejemos versiones fijas


- name: Install dependencies
run: bun install
Expand All @@ -30,12 +30,12 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0

- name: Setup Bun
uses: oven-sh/setup-bun@v2
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version: latest
bun-version: 1.4.3

- name: Install dependencies
run: bun install
Expand All @@ -48,12 +48,12 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0

- name: Setup Bun
uses: oven-sh/setup-bun@v2
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version: latest
bun-version: 1.4.3

- name: Install dependencies
run: bun install
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/code-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0

- name: Setup Bun
uses: oven-sh/setup-bun@v2
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version: latest
bun-version: 1.4.3

- name: Install dependencies
run: bun install

- name: Install GitOps CLI
run: bun install --global @getgitops/cli
run: bun install --global @getgitops/cli@1.2.1

- name: Run Code Report scan
env:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0

- name: Log in to the Container Registry
uses: docker/login-action@v3
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
Expand All @@ -40,10 +40,10 @@ jobs:
type=semver,pattern={{major}}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0

- name: Build and push Docker image
uses: docker/build-push-action@v6
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2
with:
context: .
push: true
Expand Down
50 changes: 36 additions & 14 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,30 @@ Guidance for working on GitOps, an open source internal developer platform built

GitOps combines identity and access management, organizations and projects, Open Report security
analysis, and Pulumi State visibility. The Vault route is currently a UI foundation and does not
yet provide a complete secrets backend. Google SSO and SAML settings are configuration only; no
external authentication strategy is implemented.

Self-service registration (`/auth/registration`) lets a visitor create a plain `cluster-user`
account with no organization membership. It is gated by a cluster-wide toggle managed at
`/cluster-settings/registration` (persisted via `clusterSettingsService` in `$modules/config`,
yet provide a complete secrets backend. SAML settings are configuration only.

Google SSO is system-wide and configured only through environment variables
(`GOOGLE_SSO_CLIENT_ID`, `GOOGLE_SSO_CLIENT_SECRET`, optional `GOOGLE_SSO_ALLOWED_DOMAINS` and
`GOOGLE_SSO_AUTO_PROVISION`), read on every request by `readGoogleSsoConfig()` from
`src/modules/auth/infrastructure/config/google-sso.config.ts` into a `GoogleSsoConfig` domain
object; nothing is persisted in GitDB. When both credentials are set and the config is valid, `/auth/login`
shows "Continue with Google" next to the password form, and each organization's
`/org/<org>/settings/global` shows Google SSO as enabled (read-only status, credentials never exposed).
A misconfigured provider (missing credential, invalid domain, inconsistent auto-provision settings)
silently counts as disabled and logs the reason; the UI never breaks. `ssoService` in `$modules/auth`
runs Authorization Code + PKCE through `/auth/sso/google/start` and `/auth/sso/google/callback`
(both allow unauthenticated access in `hooks.server.ts`), verifies the ID token against Google's
JWKS via `GoogleOidcClient`, and signs in any existing, non-disabled user found by Google `sub` or
verified email, linking the `sub` in `user.authProviders[]` and accepting pending invitations on
first sign-in. Allowed domains are checked against the Workspace `hd` claim, not the email suffix.
With `GOOGLE_SSO_AUTO_PROVISION=true` (requires at least one allowed domain), an unknown Workspace
account of an allowed domain gets an active GitOps User (`cluster-user`) account with no organization membership
through `userAccessService.provisionClusterUser()`; organizations still have to invite it.
`user.disabled` is currently enforced only by Google sign-in.

Self-service registration (`/auth/registration`) lets a visitor create a plain GitOps User (`cluster-user`)
account with no organization membership. It is gated by a system-wide toggle managed at
`/gitops-settings/registration` (persisted via `clusterSettingsService` in `$modules/config`,
off by default) and re-checked server-side on submit so it can't be bypassed while disabled. Once
registered and signed in, the user lands on `/org`, where the `cluster:organization:create`
permission (granted to `cluster-user` by default) surfaces a "New Organization" action that
Expand All @@ -36,6 +54,10 @@ The roadmap is in `IDEAS.md`. Do not describe roadmap items as implemented featu
- Vitest, ESLint, and Prettier
- Playwright for RBAC end-to-end tests (`e2e/`)

Environment variables are declared in `src/env.ts` and documented in `.env.example`; Google SSO uses the `GOOGLE_SSO_*` variables described above.

Email notification templates (`src/notifications/`) are read from disk at runtime; the Docker image copies them so emails can be sent from the container.

```bash
bun install
bun run dev
Expand Down Expand Up @@ -144,13 +166,13 @@ This ensures the UI only displays navigation items for sections the user has per
Default roles and permissions are centralized in `src/modules/auth/domain/role-permissions.data.ts`.
Permissions always include their scope as a prefix (e.g., `organization:projects:read`,
`project:vault:secrets:all`) and are stored verbatim—there is no scope-stripping transformation:
- **Cluster Admin** (`vault:all`, `openreport:all`, `stateiac:all`)
- **Cluster User** (no inherent permissions; used as base role for cluster-level access)
- **Organization Admin** (all org-level permissions: projects, users, roles, settings, backups, server-keys, audit)
- **Organization Developer** (read/create/update projects only)
- **Project Admin** (all project-level permissions: project metadata, users, roles, server-keys, audit; plus all module permissions: vault secrets/environments, codereport reports/dependencies/vulnerabilities, stateiac stacks/states/history)
- **Project Developer** (read/create/update project resources; no deletion or admin; granular module access)
- **Project Viewer** (read-only: project metadata, all modules, vault secrets/environments, codereport reports/dependencies/vulnerabilities, stateiac stacks/states/history)
- **GitOps Admin** (`cluster-admin`) — grants vault, openreport, stateiac full access
- **GitOps User** (`cluster-user`) — no inherent permissions; base role for system-level access
- **Organization Admin** — all org-level permissions: projects, users, roles, settings, backups, server-keys, audit
- **Organization Developer** — read/create/update projects only
- **Project Admin** — all project-level permissions: project metadata, users, roles, server-keys, audit; plus all module permissions: vault secrets/environments, codereport reports/dependencies/vulnerabilities, stateiac stacks/states/history
- **Project Developer** — read/create/update project resources; no deletion or admin; granular module access
- **Project Viewer** — read-only: project metadata, all modules, vault secrets/environments, codereport reports/dependencies/vulnerabilities, stateiac stacks/states/history

Module resources have granular sub-permissions: `project:vault:secrets:read`, `project:vault:environments:read`, `project:codereport:reports:read`, `project:codereport:dependencies:read`, `project:codereport:vulnerabilities:read`, `project:stateiac:stacks:read`, `project:stateiac:states:read`, `project:stateiac:history:read`. These allow fine-grained access control within each module.

Expand All @@ -164,7 +186,7 @@ Two helpers distinguish organization visibility from management: `canManageOrgan
while `canViewOrganization()` also includes users whose only access is to a project under that organization
(they see the org overview, but cannot perform org-scope actions).

When creating an organization (via bootstrap or cluster settings), `roleService.createDefaultOrganizationRoles()` is
When creating an organization (via bootstrap or `/gitops-settings`), `roleService.createDefaultOrganizationRoles()` is
automatically invoked. When creating a project, `roleService.createDefaultProjectRoles()` is automatically invoked. Both
operations initialize their respective default roles. Keep authorization tests beside changes to permission behavior.
Machine-to-machine requests authenticate with `Authorization: Bearer gvs_...`; `hooks.server.ts`
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ RUN apk add --no-cache git openssh-client && \
COPY --from=builder /app/build ./build
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json
# email templates are read from disk at runtime (src/lib/server/infra/notifications/template.ts)
COPY --from=builder /app/src/notifications ./src/notifications

# Persistent data directory (SQLite DB + gitdb clone)
# VOLUME ["/app/data"]
Expand Down
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ operational data versioned and auditable in Git.

- Identity and access management for users, organizations, projects, roles, permissions,
invitations, sessions, and API keys.
- Cluster-wide Google sign-in (OpenID Connect) alongside local email and password login.
- Security reporting for vulnerabilities, SBOMs, secrets, licenses, and services.
- Pulumi state, history, and lock visibility for S3 and Google Cloud Storage backends.
- Git-backed, auditable application data through GitDB.
Expand Down Expand Up @@ -79,6 +80,44 @@ docker compose up --build
```

The container is available at `http://localhost:3000` and stores persistent data in `./data`.
The image ships `git` without an SSH client, so point `GITDB_REPOSITORY_URL` at an HTTPS remote
and authenticate with `GITDB_TOKEN` (or `GITDB_USERNAME`/`GITDB_PASSWORD`); with an SSH
(`git@...`) remote the container can commit locally but cannot push.

### Google sign-in

Google sign-in is configured once for the whole cluster, through environment variables:

1. In Google Cloud Console, open **APIs & Services → Credentials** and create an **OAuth client ID**
of type **Web application** (configure the consent screen as *Internal* for Workspace-only
access).
2. Under **Authorized redirect URIs** (not *JavaScript origins*), add
`https://<your-host>/auth/sso/google/callback`. For local use add the URI of the port you run
on, which must match exactly: `http://localhost:5173/auth/sso/google/callback` for
`bun run dev`, `http://localhost:3000/auth/sso/google/callback` for Docker.
3. Set the variables and restart GitOps:

```bash
GOOGLE_SSO_CLIENT_ID=123456789-abc.apps.googleusercontent.com
GOOGLE_SSO_CLIENT_SECRET=...
# optional: comma-separated Google Workspace domains allowed to sign in
GOOGLE_SSO_ALLOWED_DOMAINS=example.com
# optional: sign up unknown Workspace accounts of the allowed domains automatically
GOOGLE_SSO_AUTO_PROVISION=false
```

The login page then shows **Continue with Google**, and every organization's **Settings → Global**
shows Google SSO as enabled for the cluster. Leave `GOOGLE_SSO_ALLOWED_DOMAINS` empty to accept
personal `@gmail.com` accounts, which carry no Workspace domain. With an *External* consent screen
in testing mode, only the accounts listed as test users can sign in.

By default only existing or invited users can sign in with Google. With
`GOOGLE_SSO_AUTO_PROVISION=true` (requires at least one allowed domain), the first Google sign-in of
an unknown `@example.com` Workspace account creates a plain GitOps User (`cluster-user`) with no organization
membership; organizations still have to invite it. Personal Google accounts are never signed up
automatically, because the domain is checked against the Workspace `hd` claim, not the email
address. If the variables are inconsistent (only one credential set, an invalid domain, or
automatic sign-up without domains), the Google button is hidden and the reason is logged.

## Development

Expand Down
Loading
Loading