auth

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientWithDatabaseRead added in v0.3.0

func ClientWithDatabaseRead(db db.Manager) common.Option[clientManager]

func ClientWithExecuteMigration added in v0.3.0

func ClientWithExecuteMigration(enabled bool, dir ...string) common.Option[clientManager]

func ClientWithLazyLoadData added in v0.3.0

func ClientWithLazyLoadData(v bool) common.Option[clientManager]

func ClientWithLogger added in v0.3.0

func ClientWithLogger(v logger.Manager) common.Option[clientManager]

func UserAuthWithDatabaseRead added in v0.3.6

func UserAuthWithDatabaseRead(db db.Manager) common.Option[clientManager]

func UserAuthWithLogger added in v0.3.6

func UserAuthWithLogger(v logger.Manager) common.Option[clientManager]

Types

type Client added in v0.3.0

type Client struct {
	ID         int        `db:"id"`
	Name       string     `db:"name"`
	Secret     string     `db:"secret"`
	ExpiredAt  *time.Time `db:"expire_at"`
	Disabled   bool       `db:"disabled"`
	CreatedAt  time.Time  `db:"created_at"`
	UpdatedAt  *time.Time `db:"updated_at"`
	DisabledAt *time.Time `db:"disabled_at"`
}

type ClientManager added in v0.3.0

type ClientManager interface {
	AddClients(ctx context.Context, items Clients) error
	AddScopes(ctx context.Context, items ClientScopes) error
	AddClientsWithScopes(ctx context.Context, items ClientWithScopes) error

	GetClientsWithScopesBy(ctx context.Context, by db.IHelper) (ClientsWithScopes, error)

	VoidClientsByIds(ctx context.Context, ids ...int) error
	VoidScopeByIds(ctx context.Context, id ...int) error

	IsAllowed(secret, resource, scope string) (clientName string, allowed bool)

	Init() error
	MustInit() ClientManager
	AddOptions(opts ...common.Option[clientManager]) ClientManager
	// contains filtered or unexported methods
}

func NewClientManager added in v0.3.0

func NewClientManager(dbm db.Manager, opts ...common.Option[clientManager]) ClientManager

type ClientScope added in v0.3.0

type ClientScope struct {
	ID         int        `db:"id"`
	ClientID   int        `db:"client_id"`
	Resource   string     `db:"resource"`
	Scopes     Scopes     `db:"scopes"`
	Disabled   bool       `db:"disabled"`
	CreatedAt  time.Time  `db:"created_at"`
	UpdatedAt  *time.Time `db:"updated_at"`
	DisabledAt *time.Time `db:"disabled_at"`
}

type ClientScopes added in v0.3.0

type ClientScopes []*ClientScope

type ClientWithScopes added in v0.3.0

type ClientWithScopes struct {
	*Client
	Scopes ClientScopes
}

type Clients added in v0.3.0

type Clients []*Client

type ClientsWithScopes added in v0.3.0

type ClientsWithScopes []*ClientWithScopes

type Scope added in v0.3.0

type Scope string
const (
	ScopeRead      Scope = "read"
	ScopeWrite     Scope = "write"
	ScopeDelete    Scope = "delete"
	ScopeUndefined Scope = "undefined"
)

func (Scope) FromHttpMethod added in v0.3.2

func (s Scope) FromHttpMethod(method string) Scope

func (*Scope) Scan added in v0.3.0

func (s *Scope) Scan(src interface{}) error

Scan implements the sql.Scanner interface.

func (Scope) String added in v0.3.0

func (s Scope) String() string

func (Scope) Value added in v0.3.0

func (s Scope) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type Scopes added in v0.3.0

type Scopes []Scope

func (Scopes) AllowedTo added in v0.3.0

func (s Scopes) AllowedTo(scope Scope) bool

func (Scopes) AllowedToRead added in v0.3.0

func (s Scopes) AllowedToRead() bool

func (Scopes) AllowedToWrite added in v0.3.0

func (s Scopes) AllowedToWrite() bool

func (Scopes) FromStringArray added in v0.3.0

func (s Scopes) FromStringArray(values []string) Scopes

func (Scopes) IsAllowedByHttpMethod added in v0.3.0

func (s Scopes) IsAllowedByHttpMethod(method string) bool

func (*Scopes) Scan added in v0.3.0

func (s *Scopes) Scan(src interface{}) error

Scan implements the sql.Scanner interface.

func (Scopes) ToStringArray added in v0.3.0

func (s Scopes) ToStringArray() []string

func (Scopes) Value added in v0.3.0

func (s Scopes) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type UserAuthRecord added in v0.3.6

type UserAuthRecord struct {
	ID         int        `db:"id"`
	UserID     int        `db:"user_id"`
	Email      string     `db:"email"`
	Phone      string     `db:"phone"`
	Creds      string     `db:"creds"`
	Disabled   bool       `db:"disabled"`
	CreatedAt  time.Time  `db:"created_at"`
	UpdatedAt  *time.Time `db:"updated_at"`
	DisabledAt *time.Time `db:"disabled_at"`
	ExpiredAt  *time.Time `db:"expired_at"`
}

type UserAuthRecords added in v0.3.6

type UserAuthRecords []*UserAuthRecord

type UserManager added in v0.3.6

type UserManager interface {
	Add(ctx context.Context, records ...UserAuthRecord) error
	Save(ctx context.Context, record UserAuthRecord) (UserAuthRecord, error)
	RemoveByIds(ctx context.Context, ids ...int) error
	RemoveByUserIds(ctx context.Context, userIds ...int) error

	GetByUserIds(ctx context.Context, userIds ...int) (UserAuthRecords, error)

	Init() error
	MustInit() UserManager
}

func NewUserAuthManager added in v0.3.6

func NewUserAuthManager(dbm db.Manager, opts ...common.Option[userManager]) UserManager

Jump to

Keyboard shortcuts

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