mirror of
https://github.com/Dvorinka/Primora.git
synced 2026-10-29 16:14:53 +00:00
Username and password live in the local vault and the project vault, keyed by a stable app id rather than a host or port. Agents fetch one named secret or login when they need it. Lists stay metadata, and project reveals stay audit-logged. Authored By: TDvorak <[email protected]>
159 lines
3.7 KiB
Go
159 lines
3.7 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.29.0
|
|
// source: project_logins.sql
|
|
|
|
package db
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const deleteProjectLogin = `-- name: DeleteProjectLogin :one
|
|
DELETE FROM core.project_logins
|
|
WHERE project_id = $1
|
|
AND app = $2
|
|
RETURNING id
|
|
`
|
|
|
|
type DeleteProjectLoginParams struct {
|
|
ProjectID uuid.UUID `json:"project_id"`
|
|
App string `json:"app"`
|
|
}
|
|
|
|
func (q *Queries) DeleteProjectLogin(ctx context.Context, arg DeleteProjectLoginParams) (uuid.UUID, error) {
|
|
row := q.db.QueryRow(ctx, deleteProjectLogin, arg.ProjectID, arg.App)
|
|
var id uuid.UUID
|
|
err := row.Scan(&id)
|
|
return id, err
|
|
}
|
|
|
|
const getProjectLogin = `-- name: GetProjectLogin :one
|
|
SELECT id, project_id, app, username, ciphertext, origin, notes, created_at, updated_at FROM core.project_logins
|
|
WHERE project_id = $1
|
|
AND app = $2
|
|
`
|
|
|
|
type GetProjectLoginParams struct {
|
|
ProjectID uuid.UUID `json:"project_id"`
|
|
App string `json:"app"`
|
|
}
|
|
|
|
func (q *Queries) GetProjectLogin(ctx context.Context, arg GetProjectLoginParams) (CoreProjectLogin, error) {
|
|
row := q.db.QueryRow(ctx, getProjectLogin, arg.ProjectID, arg.App)
|
|
var i CoreProjectLogin
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.ProjectID,
|
|
&i.App,
|
|
&i.Username,
|
|
&i.Ciphertext,
|
|
&i.Origin,
|
|
&i.Notes,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const listProjectLogins = `-- name: ListProjectLogins :many
|
|
SELECT id, project_id, app, username, origin, notes, created_at, updated_at
|
|
FROM core.project_logins
|
|
WHERE project_id = $1
|
|
ORDER BY app ASC
|
|
`
|
|
|
|
type ListProjectLoginsRow struct {
|
|
ID uuid.UUID `json:"id"`
|
|
ProjectID uuid.UUID `json:"project_id"`
|
|
App string `json:"app"`
|
|
Username string `json:"username"`
|
|
Origin string `json:"origin"`
|
|
Notes string `json:"notes"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
|
}
|
|
|
|
func (q *Queries) ListProjectLogins(ctx context.Context, projectID uuid.UUID) ([]ListProjectLoginsRow, error) {
|
|
rows, err := q.db.Query(ctx, listProjectLogins, projectID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []ListProjectLoginsRow
|
|
for rows.Next() {
|
|
var i ListProjectLoginsRow
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.ProjectID,
|
|
&i.App,
|
|
&i.Username,
|
|
&i.Origin,
|
|
&i.Notes,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const upsertProjectLogin = `-- name: UpsertProjectLogin :one
|
|
INSERT INTO core.project_logins (
|
|
project_id,
|
|
app,
|
|
username,
|
|
ciphertext,
|
|
origin,
|
|
notes
|
|
) VALUES ($1, $2, $3, $4, $5, $6)
|
|
ON CONFLICT (project_id, app) DO UPDATE SET
|
|
username = EXCLUDED.username,
|
|
ciphertext = EXCLUDED.ciphertext,
|
|
origin = EXCLUDED.origin,
|
|
notes = EXCLUDED.notes,
|
|
updated_at = NOW()
|
|
RETURNING id, project_id, app, username, ciphertext, origin, notes, created_at, updated_at
|
|
`
|
|
|
|
type UpsertProjectLoginParams struct {
|
|
ProjectID uuid.UUID `json:"project_id"`
|
|
App string `json:"app"`
|
|
Username string `json:"username"`
|
|
Ciphertext []byte `json:"ciphertext"`
|
|
Origin string `json:"origin"`
|
|
Notes string `json:"notes"`
|
|
}
|
|
|
|
func (q *Queries) UpsertProjectLogin(ctx context.Context, arg UpsertProjectLoginParams) (CoreProjectLogin, error) {
|
|
row := q.db.QueryRow(ctx, upsertProjectLogin,
|
|
arg.ProjectID,
|
|
arg.App,
|
|
arg.Username,
|
|
arg.Ciphertext,
|
|
arg.Origin,
|
|
arg.Notes,
|
|
)
|
|
var i CoreProjectLogin
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.ProjectID,
|
|
&i.App,
|
|
&i.Username,
|
|
&i.Ciphertext,
|
|
&i.Origin,
|
|
&i.Notes,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|