datastore

package
v0.0.0-...-e4f806a Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrClientNotFound = errors.New("client not found")
View Source
var ErrScopeNotFound = errors.New("scope not found")
View Source
var ErrTenantNotFound = errors.New("tenant not found")
View Source
var ErrVersionMismatch = errors.New("version mismatch")

Functions

func CreatePlaceholders

func CreatePlaceholders(start int, count int, builder *strings.Builder) *strings.Builder

func ParseErrorIntoStatus

func ParseErrorIntoStatus(err error, status *sso.ResponseStatus) *sso.ResponseStatus

func StartDatastore

func StartDatastore(ctx context.Context, datastore *Datastore) error

func StopDataStore

func StopDataStore(ctx context.Context, datastore *Datastore)

Types

type AccountDoc

type AccountDoc struct {
	ID               string
	Password         string
	ActivationMethod sso.ActivationMethod
	Name             string
	CreatedAt        time.Time
	UpdatedAt        time.Time
	DeletedAt        time.Time
}

type ClientDoc

type ClientDoc struct {
	ID           string
	Name         string `validate:"required" json:"name"`
	Secret       string
	RedirectURIs []string       `validate:"required,min=1,unique,dive,url" json:"redirect_uris"`
	Type         sso.ClientType `validate:"min=0,max=1" json:"type"`
	CreatedAt    time.Time
	UpdatedAt    time.Time
	DeletedAt    time.Time
}

func (*ClientDoc) FromUpsertClientRequest

func (c *ClientDoc) FromUpsertClientRequest(req *sso.UpsertClientRequest)

type Datastore

type Datastore struct {
	Options       *Options
	Client        *sql.DB
	Logger        *logrus.Logger
	IDGenerator28 *id.IDGenerator
}

func (*Datastore) ClientExistsByID

func (d *Datastore) ClientExistsByID(ctx context.Context, clientID string, tx *sql.Tx) (bool, error)

func (*Datastore) IsAccountInTenant

func (d *Datastore) IsAccountInTenant(ctx context.Context, accountID string, tenantID string) (bool, error)

func (*Datastore) RegisterEvent

func (d *Datastore) RegisterEvent(event *sso.RegisterEventRequest)

func (*Datastore) RevokeScopes

func (d *Datastore) RevokeScopes(ctx context.Context, req *sso.RevokeScopesRequest) error

func (*Datastore) RevokeToken

func (d *Datastore) RevokeToken(ctx context.Context, req *sso.RevokeTokenRequest) error

func (*Datastore) TenantExistsByID

func (d *Datastore) TenantExistsByID(ctx context.Context, tenantID string, tx *sql.Tx) (bool, error)

func (*Datastore) UpsertClient

func (d *Datastore) UpsertClient(ctx context.Context, req *sso.UpsertClientRequest) (*ClientDoc, error)

func (*Datastore) UpsertScope

func (d *Datastore) UpsertScope(ctx context.Context, req *sso.UpsertScopeRequest) (*ScopeDoc, error)

func (*Datastore) UpsertTenant

func (d *Datastore) UpsertTenant(ctx context.Context, req *sso.UpsertTenantRequest) (*TenantDoc, error)

type Options

type Options struct {
	PostgresURI    string
	MaxConnections int
	Validator      *validator.Validate
}

type ScopeDoc

type ScopeDoc struct {
	ID        string
	ClientID  string `validate:"required,len=28" json:"client_id"`
	Scope     string `validate:"required,min=1,max=100" json:"scope"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt time.Time
}

func (*ScopeDoc) FromUpsertScopeRequest

func (s *ScopeDoc) FromUpsertScopeRequest(req *sso.UpsertScopeRequest)

type ScopeI18nDoc

type ScopeI18nDoc struct {
	Description string `validate:"required,min=1,max=200" json:"description"`
	Locale      string
}

func (*ScopeI18nDoc) FromUpsertScopeRequest

func (s *ScopeI18nDoc) FromUpsertScopeRequest(req *sso.UpsertScopeRequest)

type TenantDoc

type TenantDoc struct {
	ID        string
	Name      string `validate:"required,min=1,max=60" json:"name"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt time.Time
}

func (*TenantDoc) FromUpsertTenantRequest

func (c *TenantDoc) FromUpsertTenantRequest(req *sso.UpsertTenantRequest)

Jump to

Keyboard shortcuts

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