storage: Add OfflineSession object to backend storage.
This commit is contained in:
@@ -52,6 +52,7 @@ type Storage interface {
|
||||
CreateAuthCode(c AuthCode) error
|
||||
CreateRefresh(r RefreshToken) error
|
||||
CreatePassword(p Password) error
|
||||
CreateOfflineSessions(s OfflineSessions) error
|
||||
|
||||
// TODO(ericchiang): return (T, bool, error) so we can indicate not found
|
||||
// requests that way instead of using ErrNotFound.
|
||||
@@ -61,6 +62,7 @@ type Storage interface {
|
||||
GetKeys() (Keys, error)
|
||||
GetRefresh(id string) (RefreshToken, error)
|
||||
GetPassword(email string) (Password, error)
|
||||
GetOfflineSessions(userID string, connID string) (OfflineSessions, error)
|
||||
|
||||
ListClients() ([]Client, error)
|
||||
ListRefreshTokens() ([]RefreshToken, error)
|
||||
@@ -72,6 +74,7 @@ type Storage interface {
|
||||
DeleteClient(id string) error
|
||||
DeleteRefresh(id string) error
|
||||
DeletePassword(email string) error
|
||||
DeleteOfflineSessions(userID string, connID string) error
|
||||
|
||||
// Update methods take a function for updating an object then performs that update within
|
||||
// a transaction. "updater" functions may be called multiple times by a single update call.
|
||||
@@ -92,6 +95,7 @@ type Storage interface {
|
||||
UpdateAuthRequest(id string, updater func(a AuthRequest) (AuthRequest, error)) error
|
||||
UpdateRefreshToken(id string, updater func(r RefreshToken) (RefreshToken, error)) error
|
||||
UpdatePassword(email string, updater func(p Password) (Password, error)) error
|
||||
UpdateOfflineSessions(userID string, connID string, updater func(s OfflineSessions) (OfflineSessions, error)) error
|
||||
|
||||
// GarbageCollect deletes all expired AuthCodes and AuthRequests.
|
||||
GarbageCollect(now time.Time) (GCResult, error)
|
||||
@@ -241,6 +245,30 @@ type RefreshToken struct {
|
||||
Nonce string
|
||||
}
|
||||
|
||||
// RefreshTokenRef is a reference object that contains metadata about refresh tokens.
|
||||
type RefreshTokenRef struct {
|
||||
ID string
|
||||
|
||||
// Client the refresh token is valid for.
|
||||
ClientID string
|
||||
|
||||
CreatedAt time.Time
|
||||
LastUsed time.Time
|
||||
}
|
||||
|
||||
// OfflineSessions objects are sessions pertaining to users with refresh tokens.
|
||||
type OfflineSessions struct {
|
||||
// UserID of an end user who has logged in to the server.
|
||||
UserID string
|
||||
|
||||
// The ID of the connector used to login the user.
|
||||
ConnID string
|
||||
|
||||
// Refresh is a hash table of refresh token reference objects
|
||||
// indexed by the ClientID of the refresh token.
|
||||
Refresh map[string]*RefreshTokenRef
|
||||
}
|
||||
|
||||
// Password is an email to password mapping managed by the storage.
|
||||
type Password struct {
|
||||
// Email and identifying name of the password. Emails are assumed to be valid and
|
||||
|
Reference in New Issue
Block a user