Commit Graph

12 Commits

Author SHA1 Message Date
75ea7c70c2 auth: implement cookie-based auth for HTML endpoints and Bearer token auth for API endpoints
Some checks failed
CI / lint (push) Failing after 15s
CI / test (push) Has been skipped
CI / build (push) Has been skipped
CI / docker (push) Has been skipped
Details:

  • HTML endpoints (/, /profile, /admin, /login, /register):

    - Authenticate via HTTP-only cookie named 'token'

    - Handlers in internal/templates/templates.go check cookie validity

    - /admin endpoint additionally checks for role='admin'

    - Unauthenticated users redirected to /login

    - Non-admin users accessing /admin get HTTP 403 Forbidden

  • API endpoints (/api/*):

    - Authenticate via Bearer token in Authorization header only

    - Handlers in internal/api/api.go use authenticateRequest() function

    - Function extracts token from 'Authorization: Bearer <token>' header

    - Validates token against yggdrasil_sessions table

    - No cookie checking for API endpoints (launcher compatibility)

  • Web login (/api/web/login):

    - Sets HTTP-only cookie 'token' for browser storage

    - Returns JSON with token, UUID, username for JS localStorage

    - Maintains backward compatibility with existing JavaScript

  • JavaScript in HTML pages:

    - Gets token from localStorage (set by login response)

    - Sets Authorization: Bearer <token> header for API fetch calls

    - Updated admin.html and profile.js to include token in headers

This separation ensures:

  • HTML endpoints work automatically with browser cookies

  • API endpoints work with browsers (via JS) and launchers (Bearer tokens)

  • Security sensitive actions require proper role validation

  • Clean separation of concerns between document and API interfaces
2026-06-07 23:11:51 +03:00
b9e986d25a feat: добавить веб-интерфейс админ-панели для управления модпаками
All checks were successful
CI / lint (push) Successful in 1m1s
CI / test (push) Successful in 42s
CI / build (push) Successful in 18s
CI / docker (push) Successful in 1m16s
2026-06-07 19:06:27 +03:00
f765fecf24 fix: check skin_hash/cape_hash instead of skin/cape in profile JS
All checks were successful
CI / lint (push) Successful in 16s
CI / test (push) Successful in 41s
CI / build (push) Successful in 17s
CI / docker (push) Successful in 1m13s
2026-06-06 20:36:19 +03:00
f4f7a52749 fix: remove inline onerror from skin/cape images in template
All checks were successful
CI / lint (push) Successful in 16s
CI / docker (push) Successful in 1m10s
CI / test (push) Successful in 40s
CI / build (push) Successful in 17s
Inline onerror was firing on empty src, hiding images before JS could load them
2026-06-06 20:27:18 +03:00
b8c136878b fix: pass os/arch to launcher latest endpoint and improve skin/cape loading
All checks were successful
CI / lint (push) Successful in 16s
CI / test (push) Successful in 41s
CI / build (push) Successful in 17s
CI / docker (push) Successful in 1m7s
2026-06-06 20:08:37 +03:00
329c0d3fda fix: skin/cape image loading with error handling
All checks were successful
CI / lint (push) Successful in 17s
CI / test (push) Successful in 43s
CI / build (push) Successful in 18s
CI / docker (push) Successful in 1m10s
2026-06-06 20:00:26 +03:00
6a8213a234 fix: use skin_hash and cape_hash for skin/cape URLs in profile page
All checks were successful
CI / lint (push) Successful in 17s
CI / test (push) Successful in 43s
CI / build (push) Successful in 17s
CI / docker (push) Successful in 1m17s
2026-06-06 19:44:58 +03:00
7ae0f44fd6 fix: skin and cape URLs in profile page to use /skins/ endpoint
All checks were successful
CI / lint (push) Successful in 1m0s
CI / test (push) Successful in 42s
CI / build (push) Successful in 18s
CI / docker (push) Successful in 1m23s
2026-06-06 19:29:14 +03:00
74ad023a36 fix: align form field names in skin/cape upload (file → skin/cape)
All checks were successful
CI / lint (push) Successful in 18s
CI / test (push) Successful in 20s
CI / build (push) Successful in 20s
CI / docker (push) Successful in 1m7s
JS sent fd.append('file', ...) but Go expected r.FormFile("skin") / r.FormFile("cape").
2026-06-04 18:33:05 +03:00
21d48200f5 fix: parse templates individually to prevent content block overwrite
Some checks failed
CI / lint (push) Failing after 19s
CI / test (push) Has been skipped
CI / build (push) Has been skipped
CI / docker (push) Has been skipped
Root cause: ParseFS with wildcard html/*.html caused all {{define "content"}}

blocks to overwrite each other — last alphabetically (register.html) won for

all pages. Now each page is parsed separately with base.html as its own template.

Also fix footer link: GitHub → Gitea project page.
2026-06-04 16:57:34 +03:00
008d9a129e feat: redesign website templates with full pages
All checks were successful
CI / lint (push) Successful in 18s
CI / test (push) Successful in 20s
CI / build (push) Successful in 19s
CI / docker (push) Successful in 1m7s
- Redesigned base.html: dark Minecraft theme, sticky header, responsive grid, cards, server cards with status indicators, profile styles
- index.html: hero section, server list grid, how-to-start steps, features section
- login.html: centered card layout, client-side validation, fetch API
- registration.html: password confirmation, pattern validation, error alerts
- profile.html: new page — skin/cape upload & delete, launcher download links, auth-gated via localStorage token
- templates.go: added /profile route, extended pageData with Username/UUID
2026-06-03 20:37:24 +03:00
7ad02cb1b2 feat: implement email validation, CI/CD pipeline, migration history, and web templates
Some checks failed
CI / lint (push) Failing after 21s
CI / build (push) Has been skipped
CI / test (push) Has been skipped
CI / docker (push) Has been skipped
Email validation:
- Replace @/. check with net/mail.ParseAddress on register
- Add size limit check (max 254 chars, RFC 5321)

CI/CD Pipeline:
- Add .gitea/workflows/ci.yml (lint → test → build → docker push)
- Registry: gitea.mrixs.me/Mrixs/MrixsCraft-server
- Push only on main branch

Database:
- Add migrations/002_migration_history.sql (tracking applied migrations)
- Add migrations/README.md (manual apply instructions)

Web Templates:
- Add base.html with Minecraft-themed layout (dark + green accent)
- Add index.html, login.html, register.html with POST forms
- Rewrite templates.go for data-driven rendering with pageData struct
- Fallback placeholder preserved when templates dir missing
2026-05-30 00:39:51 +03:00