client

package
v0.0.0-...-43a01a0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 26, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithClient

func WithClient(c *db.Client) func(*Database)

WithClient sets client option of a Database object.

func WithHasher

func WithHasher(h func() hash.Hash) func(*Database)

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

func NewDatabase(opts ...func(*Database)) *Database

NewDatabase returns new database client with set options.

func (*Database) BeginTx

func (d *Database) BeginTx(ctx context.Context) (*db.Tx, error)

BeginTx is a wrapper to begin transaction with defined options.

func (*Database) Close

func (d *Database) Close() error

Close calls the corresponding method of the ent database client.

func (*Database) CreateAuthCode

func (d *Database) CreateAuthCode(code storage.AuthCode) error

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

func (d *Database) CreateClient(client storage.Client) error

CreateClient saves provided oauth2 client settings into the database.

func (*Database) CreateConnector

func (d *Database) CreateConnector(connector storage.Connector) error

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

func (d *Database) CreatePassword(password storage.Password) error

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

func (d *Database) DeleteAuthCode(id string) error

DeleteAuthCode deletes an auth code from the database by id.

func (*Database) DeleteAuthRequest

func (d *Database) DeleteAuthRequest(id string) error

DeleteAuthRequest deletes an auth request from the database by id.

func (*Database) DeleteClient

func (d *Database) DeleteClient(id string) error

DeleteClient deletes an oauth2 client from the database by id.

func (*Database) DeleteConnector

func (d *Database) DeleteConnector(id string) error

DeleteConnector deletes a connector from the database by id.

func (*Database) DeleteOfflineSessions

func (d *Database) DeleteOfflineSessions(userID, connID string) error

DeleteOfflineSessions deletes an offline session from the database by user id and connector id.

func (*Database) DeletePassword

func (d *Database) DeletePassword(email string) error

DeletePassword deletes a password from the database by email.

func (*Database) DeleteRefresh

func (d *Database) DeleteRefresh(id string) error

DeleteRefresh deletes a refresh token from the database by id.

func (*Database) GarbageCollect

func (d *Database) GarbageCollect(now time.Time) (storage.GCResult, error)

GarbageCollect removes expired entities from the database.

func (*Database) GetAuthCode

func (d *Database) GetAuthCode(id string) (storage.AuthCode, error)

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) GetClient

func (d *Database) GetClient(id string) (storage.Client, error)

GetClient extracts an oauth2 client from the database by id.

func (*Database) GetConnector

func (d *Database) GetConnector(id string) (storage.Connector, error)

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

func (d *Database) GetKeys() (storage.Keys, error)

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

func (d *Database) GetPassword(email string) (storage.Password, error)

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

func (d *Database) ListClients() ([]storage.Client, error)

ListClients extracts an array of oauth2 clients from the database.

func (*Database) ListConnectors

func (d *Database) ListConnectors() ([]storage.Connector, error)

ListConnectors extracts an array of connectors from the database.

func (*Database) ListPasswords

func (d *Database) ListPasswords() ([]storage.Password, error)

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) Schema

func (d *Database) Schema() *migrate.Schema

Schema exposes migration schema to perform migrations.

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

func (d *Database) UpdateKeys(updater func(old storage.Keys) (storage.Keys, error)) error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL