chore: migrate to v3 and adopt Doppler for secrets management #3

Open
kamil wants to merge 574 commits from v3-cleanup into main
3 changed files with 11 additions and 7 deletions
Showing only changes of commit 56bf4dde22 - Show all commits

View File

@@ -45,10 +45,14 @@ services:
image: ghcr.io/muchobien/pocketbase:latest
#container_name: libnovel-pocketbase
restart: unless-stopped
environment:
# Auto-create superuser on first boot (used by entrypoint.sh)
PB_ADMIN_EMAIL: "${POCKETBASE_ADMIN_EMAIL:-admin@libnovel.local}"
PB_ADMIN_PASSWORD: "${POCKETBASE_ADMIN_PASSWORD:-changeme123}"
ports:
- "${POCKETBASE_PORT:-8090}:8090"
volumes:
- pb_data:/pb/pb_data
- pb_data:/pb_data
healthcheck:
test: ["CMD", "wget", "-qO-", "http://localhost:8090/api/health"]
interval: 10s

View File

@@ -9,7 +9,7 @@
// ranking_html — page(number,unique), html(text), updated(date)
// progress — session_id(text), slug(text), chapter(number), updated(date)
// audio_cache — cache_key(text,unique), filename(text), updated(date)
// users — username(text,unique), password_hash(text), role(text), created(date)
// app_users — username(text,unique), password_hash(text), role(text), created(date)
package storage
import (
@@ -60,7 +60,7 @@ func (p *pbClient) authenticate(ctx context.Context) error {
"password": p.cfg.AdminPassword,
})
req, err := http.NewRequestWithContext(ctx, http.MethodPost,
p.cfg.BaseURL+"/api/admins/auth-with-password", bytes.NewReader(body))
p.cfg.BaseURL+"/api/collections/_superusers/auth-with-password", bytes.NewReader(body))
if err != nil {
return err
}
@@ -314,7 +314,7 @@ func (s *PocketBaseStore) EnsureCollections(ctx context.Context) error {
},
},
{
"name": "users",
"name": "app_users",
"type": "base",
"schema": []map[string]interface{}{
{"name": "username", "type": "text", "required": true, "options": map[string]interface{}{"min": 3, "max": 32}},

View File

@@ -61,7 +61,7 @@ async function getToken(): Promise<string> {
log.debug('pocketbase', 'authenticating with admin credentials', { url: PB_URL, email: PB_EMAIL });
const res = await fetch(`${PB_URL}/api/admins/auth-with-password`, {
const res = await fetch(`${PB_URL}/api/collections/_superusers/auth-with-password`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ identity: PB_EMAIL, password: PB_PASSWORD })
@@ -213,7 +213,7 @@ function verifyPassword(password: string, stored: string): boolean {
* Look up a user by username. Returns null if not found.
*/
export async function getUserByUsername(username: string): Promise<User | null> {
return listOne<User>('users', `username="${username.replace(/"/g, '\\"')}"`);
return listOne<User>('app_users', `username="${username.replace(/"/g, '\\"')}"`);
}
/**
@@ -228,7 +228,7 @@ export async function createUser(username: string, password: string, role = 'use
}
const password_hash = hashPassword(password);
log.info('pocketbase', 'createUser: inserting new user', { username, role });
const res = await pbPost('/api/collections/users/records', {
const res = await pbPost('/api/collections/app_users/records', {
username,
password_hash,
role,