32 lines
909 B
Go
32 lines
909 B
Go
// 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
|
|
}
|