22 lines
437 B
Go
22 lines
437 B
Go
package auth
|
|
|
|
import (
|
|
"context"
|
|
|
|
"spark-server/internal/pkg/errs"
|
|
)
|
|
|
|
// Static accepts one token. Used in tests and local bring-up.
|
|
type Static struct {
|
|
Token string
|
|
UserID int64
|
|
DeviceID uint64
|
|
}
|
|
|
|
func (s Static) Authenticate(_ context.Context, token string) (*Principal, error) {
|
|
if s.Token == "" || token != s.Token {
|
|
return nil, errs.ErrUnauthorized
|
|
}
|
|
return &Principal{UserID: s.UserID, DeviceID: s.DeviceID}, nil
|
|
}
|