auth

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: MIT Imports: 20 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]

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(db 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 OAuthManager added in v0.3.0

type OAuthManager interface {
	GetPermissions(ctx context.Context, token, realm string) (OAuthPermissions, error)
}

func NewOAuthManager added in v0.3.0

func NewOAuthManager(opts ...common.Option[oauthManager]) OAuthManager

type OAuthPermission added in v0.3.0

type OAuthPermission struct {
	ResourceName string   `json:"resource_name"`
	Scopes       []string `json:"scopes"`
}

type OAuthPermissions added in v0.3.0

type OAuthPermissions []*OAuthPermission

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.

Jump to

Keyboard shortcuts

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