feat: add database-backed console login
This commit is contained in:
31
internal/consoleauth/auth.go
Normal file
31
internal/consoleauth/auth.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user