2018-09-25 19:13:38 +00:00
|
|
|
package platform
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Session is a user session.
|
|
|
|
type Session struct {
|
2018-09-26 18:17:03 +00:00
|
|
|
// ID is only required for auditing purposes.
|
2018-09-25 19:13:38 +00:00
|
|
|
ID ID `json:"id"`
|
|
|
|
Key string `json:"key"`
|
|
|
|
CreatedAt time.Time `json:"createdAt"`
|
|
|
|
ExpiresAt time.Time `json:"expiresAt"`
|
|
|
|
UserID ID `json:"userID,omitempty"`
|
|
|
|
Permissions []Permission `json:"permissions,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// SessionService represents a service for managing user sessions.
|
|
|
|
type SessionService interface {
|
|
|
|
FindSession(ctx context.Context, key string) (*Session, error)
|
|
|
|
ExpireSession(ctx context.Context, key string) error
|
|
|
|
CreateSession(ctx context.Context, user string) (*Session, error)
|
|
|
|
}
|