Documentation ¶
Index ¶
- func WithClient(c *db.Client) func(*Database)
- func WithHasher(h func() hash.Hash) func(*Database)
- func WithTxIsolationLevel(level sql.IsolationLevel) func(*Database)
- type Database
- func (d *Database) BeginTx(ctx context.Context) (*db.Tx, error)
- func (d *Database) Close() error
- func (d *Database) CreateAuthCode(code storage.AuthCode) error
- func (d *Database) CreateAuthRequest(authRequest storage.AuthRequest) error
- func (d *Database) CreateClient(client storage.Client) error
- func (d *Database) CreateConnector(connector storage.Connector) error
- func (d *Database) CreateDeviceRequest(request storage.DeviceRequest) error
- func (d *Database) CreateDeviceToken(token storage.DeviceToken) error
- func (d *Database) CreateOfflineSessions(session storage.OfflineSessions) error
- func (d *Database) CreatePassword(password storage.Password) error
- func (d *Database) CreateRefresh(refresh storage.RefreshToken) error
- func (d *Database) DeleteAuthCode(id string) error
- func (d *Database) DeleteAuthRequest(id string) error
- func (d *Database) DeleteClient(id string) error
- func (d *Database) DeleteConnector(id string) error
- func (d *Database) DeleteOfflineSessions(userID, connID string) error
- func (d *Database) DeletePassword(email string) error
- func (d *Database) DeleteRefresh(id string) error
- func (d *Database) GarbageCollect(now time.Time) (storage.GCResult, error)
- func (d *Database) GetAuthCode(id string) (storage.AuthCode, error)
- func (d *Database) GetAuthRequest(id string) (storage.AuthRequest, error)
- func (d *Database) GetClient(id string) (storage.Client, error)
- func (d *Database) GetConnector(id string) (storage.Connector, error)
- func (d *Database) GetDeviceRequest(userCode string) (storage.DeviceRequest, error)
- func (d *Database) GetDeviceToken(deviceCode string) (storage.DeviceToken, error)
- func (d *Database) GetKeys() (storage.Keys, error)
- func (d *Database) GetOfflineSessions(userID, connID string) (storage.OfflineSessions, error)
- func (d *Database) GetPassword(email string) (storage.Password, error)
- func (d *Database) GetRefresh(id string) (storage.RefreshToken, error)
- func (d *Database) ListClients() ([]storage.Client, error)
- func (d *Database) ListConnectors() ([]storage.Connector, error)
- func (d *Database) ListPasswords() ([]storage.Password, error)
- func (d *Database) ListRefreshTokens() ([]storage.RefreshToken, error)
- func (d *Database) Schema() *migrate.Schema
- func (d *Database) UpdateAuthRequest(id string, updater func(old storage.AuthRequest) (storage.AuthRequest, error)) error
- func (d *Database) UpdateClient(id string, updater func(old storage.Client) (storage.Client, error)) error
- func (d *Database) UpdateConnector(id string, updater func(old storage.Connector) (storage.Connector, error)) error
- func (d *Database) UpdateDeviceToken(deviceCode string, ...) error
- func (d *Database) UpdateKeys(updater func(old storage.Keys) (storage.Keys, error)) error
- func (d *Database) UpdateOfflineSessions(userID string, connID string, ...) error
- func (d *Database) UpdatePassword(email string, updater func(old storage.Password) (storage.Password, error)) error
- func (d *Database) UpdateRefreshToken(id string, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithClient ¶
WithClient sets client option of a Database object.
func WithHasher ¶
WithHasher sets client option of a Database object.
func WithTxIsolationLevel ¶
func WithTxIsolationLevel(level sql.IsolationLevel) func(*Database)
WithTxIsolationLevel sets correct isolation level for database transactions.
Types ¶
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
func NewDatabase ¶
NewDatabase returns new database client with set options.
func (*Database) CreateAuthCode ¶
CreateAuthCode saves provided auth code into the database.
func (*Database) CreateAuthRequest ¶
func (d *Database) CreateAuthRequest(authRequest storage.AuthRequest) error
CreateAuthRequest saves provided auth request into the database.
func (*Database) CreateClient ¶
CreateClient saves provided oauth2 client settings into the database.
func (*Database) CreateConnector ¶
CreateConnector saves a connector into the database.
func (*Database) CreateDeviceRequest ¶
func (d *Database) CreateDeviceRequest(request storage.DeviceRequest) error
CreateDeviceRequest saves provided device request into the database.
func (*Database) CreateDeviceToken ¶
func (d *Database) CreateDeviceToken(token storage.DeviceToken) error
CreateDeviceToken saves provided token into the database.
func (*Database) CreateOfflineSessions ¶
func (d *Database) CreateOfflineSessions(session storage.OfflineSessions) error
CreateOfflineSessions saves provided offline session into the database.
func (*Database) CreatePassword ¶
CreatePassword saves provided password into the database.
func (*Database) CreateRefresh ¶
func (d *Database) CreateRefresh(refresh storage.RefreshToken) error
CreateRefresh saves provided refresh token into the database.
func (*Database) DeleteAuthCode ¶
DeleteAuthCode deletes an auth code from the database by id.
func (*Database) DeleteAuthRequest ¶
DeleteAuthRequest deletes an auth request from the database by id.
func (*Database) DeleteClient ¶
DeleteClient deletes an oauth2 client from the database by id.
func (*Database) DeleteConnector ¶
DeleteConnector deletes a connector from the database by id.
func (*Database) DeleteOfflineSessions ¶
DeleteOfflineSessions deletes an offline session from the database by user id and connector id.
func (*Database) DeletePassword ¶
DeletePassword deletes a password from the database by email.
func (*Database) DeleteRefresh ¶
DeleteRefresh deletes a refresh token from the database by id.
func (*Database) GarbageCollect ¶
GarbageCollect removes expired entities from the database.
func (*Database) GetAuthCode ¶
GetAuthCode extracts an auth code from the database by id.
func (*Database) GetAuthRequest ¶
func (d *Database) GetAuthRequest(id string) (storage.AuthRequest, error)
GetAuthRequest extracts an auth request from the database by id.
func (*Database) GetConnector ¶
GetConnector extracts a connector from the database by id.
func (*Database) GetDeviceRequest ¶
func (d *Database) GetDeviceRequest(userCode string) (storage.DeviceRequest, error)
GetDeviceRequest extracts a device request from the database by user code.
func (*Database) GetDeviceToken ¶
func (d *Database) GetDeviceToken(deviceCode string) (storage.DeviceToken, error)
GetDeviceToken extracts a token from the database by device code.
func (*Database) GetKeys ¶
GetKeys returns signing keys, public keys and verification keys from the database.
func (*Database) GetOfflineSessions ¶
func (d *Database) GetOfflineSessions(userID, connID string) (storage.OfflineSessions, error)
GetOfflineSessions extracts an offline session from the database by user id and connector id.
func (*Database) GetPassword ¶
GetPassword extracts a password from the database by email.
func (*Database) GetRefresh ¶
func (d *Database) GetRefresh(id string) (storage.RefreshToken, error)
GetRefresh extracts a refresh token from the database by id.
func (*Database) ListClients ¶
ListClients extracts an array of oauth2 clients from the database.
func (*Database) ListConnectors ¶
ListConnectors extracts an array of connectors from the database.
func (*Database) ListPasswords ¶
ListPasswords extracts an array of passwords from the database.
func (*Database) ListRefreshTokens ¶
func (d *Database) ListRefreshTokens() ([]storage.RefreshToken, error)
ListRefreshTokens extracts an array of refresh tokens from the database.
func (*Database) UpdateAuthRequest ¶
func (d *Database) UpdateAuthRequest(id string, updater func(old storage.AuthRequest) (storage.AuthRequest, error)) error
UpdateAuthRequest changes an auth request by id using an updater function and saves it to the database.
func (*Database) UpdateClient ¶
func (d *Database) UpdateClient(id string, updater func(old storage.Client) (storage.Client, error)) error
UpdateClient changes an oauth2 client by id using an updater function and saves it to the database.
func (*Database) UpdateConnector ¶
func (d *Database) UpdateConnector(id string, updater func(old storage.Connector) (storage.Connector, error)) error
UpdateConnector changes a connector by id using an updater function and saves it to the database.
func (*Database) UpdateDeviceToken ¶
func (d *Database) UpdateDeviceToken(deviceCode string, updater func(old storage.DeviceToken) (storage.DeviceToken, error)) error
UpdateDeviceToken changes a token by device code using an updater function and saves it to the database.
func (*Database) UpdateKeys ¶
UpdateKeys rotates keys using updater function.
func (*Database) UpdateOfflineSessions ¶
func (d *Database) UpdateOfflineSessions(userID string, connID string, updater func(s storage.OfflineSessions) (storage.OfflineSessions, error)) error
UpdateOfflineSessions changes an offline session by user id and connector id using an updater function.
func (*Database) UpdatePassword ¶
func (d *Database) UpdatePassword(email string, updater func(old storage.Password) (storage.Password, error)) error
UpdatePassword changes a password by email using an updater function and saves it to the database.
func (*Database) UpdateRefreshToken ¶
func (d *Database) UpdateRefreshToken(id string, updater func(old storage.RefreshToken) (storage.RefreshToken, error)) error
UpdateRefreshToken changes a refresh token by id using an updater function and saves it to the database.