feat: publish standalone worker
Separate worker packaging and service lifecycle from the control plane.
Этот коммит содержится в:
32
app/models/authidentity/auth_identity.go
Обычный файл
32
app/models/authidentity/auth_identity.go
Обычный файл
@@ -0,0 +1,32 @@
|
||||
// Package authidentity provides the AuthIdentity and Basic types for QOR-style
|
||||
// authentication identity management. Vendored from github.com/glebtv/auth/auth_identity
|
||||
// to eliminate the rsgit.ru/rs/sessionmanager transitive dependency.
|
||||
package authidentity
|
||||
|
||||
import "time"
|
||||
|
||||
// AuthIdentity combines Basic provider info with SignLogs for a full identity record.
|
||||
type AuthIdentity struct {
|
||||
Basic
|
||||
SignLogs
|
||||
}
|
||||
|
||||
// TableName returns the database table name for AuthIdentity.
|
||||
func (AuthIdentity) TableName() string {
|
||||
return "identities"
|
||||
}
|
||||
|
||||
// Basic represents the core identity fields (provider, UID, encrypted password).
|
||||
type Basic struct {
|
||||
ID int64 `gorm:"primary_key" json:"id"`
|
||||
Provider string
|
||||
UID string `gorm:"column:uid"`
|
||||
EncryptedPassword string
|
||||
UserID *int64
|
||||
ConfirmedAt *time.Time
|
||||
}
|
||||
|
||||
// TableName returns the database table name for Basic.
|
||||
func (Basic) TableName() string {
|
||||
return "identities"
|
||||
}
|
||||
50
app/models/authidentity/sign_logs.go
Обычный файл
50
app/models/authidentity/sign_logs.go
Обычный файл
@@ -0,0 +1,50 @@
|
||||
package authidentity
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"time"
|
||||
)
|
||||
|
||||
// SignLogs holds login history (log entries and sign-in count).
|
||||
type SignLogs struct {
|
||||
Log string `sql:"-"`
|
||||
SignInCount uint
|
||||
Logs []SignLog
|
||||
}
|
||||
|
||||
// Scan implements sql.Scanner for deserializing SignLogs from JSON.
|
||||
func (signLogs *SignLogs) Scan(data interface{}) (err error) {
|
||||
switch values := data.(type) {
|
||||
case []byte:
|
||||
if len(values) != 0 {
|
||||
return json.Unmarshal(values, signLogs)
|
||||
}
|
||||
case string:
|
||||
return signLogs.Scan([]byte(values))
|
||||
case []string:
|
||||
for _, str := range values {
|
||||
if err := signLogs.Scan(str); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
default:
|
||||
err = errors.New("unsupported driver -> Scan pair for SignLogs")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Value implements driver.Valuer for serializing SignLogs to JSON.
|
||||
func (signLogs SignLogs) Value() (driver.Value, error) {
|
||||
results, err := json.Marshal(signLogs)
|
||||
return string(results), err
|
||||
}
|
||||
|
||||
// SignLog represents a single login event entry.
|
||||
type SignLog struct {
|
||||
UserAgent string
|
||||
At *time.Time
|
||||
IP string
|
||||
}
|
||||
Ссылка в новой задаче
Block a user