mirror of
https://github.com/netbirdio/netbird.git
synced 2025-01-11 16:38:27 +01:00
da75a76d41
For better auditing this PR adds a dashboard login event to the management service. For that the user object was extended with a field for last login that is not actively saved to the database but kept in memory until next write. The information about the last login can be extracted from the JWT claims nb_last_login. This timestamp will be stored and compared on each API request. If the value changes we generate an event to inform about a login.
29 lines
1.2 KiB
Go
29 lines
1.2 KiB
Go
package server
|
|
|
|
import "time"
|
|
|
|
type Store interface {
|
|
GetAllAccounts() []*Account
|
|
GetAccount(accountID string) (*Account, error)
|
|
GetAccountByUser(userID string) (*Account, error)
|
|
GetAccountByPeerPubKey(peerKey string) (*Account, error)
|
|
GetAccountByPeerID(peerID string) (*Account, error)
|
|
GetAccountBySetupKey(setupKey string) (*Account, error) // todo use key hash later
|
|
GetAccountByPrivateDomain(domain string) (*Account, error)
|
|
GetTokenIDByHashedToken(secret string) (string, error)
|
|
GetUserByTokenID(tokenID string) (*User, error)
|
|
SaveAccount(account *Account) error
|
|
DeleteHashedPAT2TokenIDIndex(hashedToken string) error
|
|
DeleteTokenID2UserIDIndex(tokenID string) error
|
|
GetInstallationID() string
|
|
SaveInstallationID(ID string) error
|
|
// AcquireAccountLock should attempt to acquire account lock and return a function that releases the lock
|
|
AcquireAccountLock(accountID string) func()
|
|
// AcquireGlobalLock should attempt to acquire a global lock and return a function that releases the lock
|
|
AcquireGlobalLock() func()
|
|
SavePeerStatus(accountID, peerID string, status PeerStatus) error
|
|
SaveUserLastLogin(accountID, userID string, lastLogin time.Time) error
|
|
// Close should close the store persisting all unsaved data.
|
|
Close() error
|
|
}
|