feat: add database-backed console login

This commit is contained in:
2026-09-21 04:53:54 +08:00
parent 3e1db5e30d
commit a6f4aa229d
17 changed files with 781 additions and 84 deletions

View File

@@ -0,0 +1,31 @@
// Package consoleauth defines the small boundary between the HTTP console and
// the database-backed account/session implementation.
package consoleauth
import (
"context"
"time"
"git.yuntuo.hk/k2safe/orbit/platform/auth"
)
// User is the safe, browser-visible part of a console account.
type User struct {
ID string `json:"id"`
Username string `json:"username"`
DisplayName string `json:"display_name"`
}
// LoginResult contains the short-lived internal bearer and its browser session metadata.
type LoginResult struct {
User User
Token string
ExpiresAt time.Time
}
// Store is implemented by the production database adapter.
type Store interface {
Login(ctx context.Context, username, password, userAgent, remoteAddr string) (LoginResult, error)
ValidateSession(ctx context.Context, token auth.Token) error
RevokeSession(ctx context.Context, token auth.Token) error
}