auth

package
v0.0.0-...-b7c645d Latest Latest
Warning

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

Go to latest
Published: May 23, 2022 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Options(
	fx.Provide(NewJWTManager),
	fx.Provide(
		fx.Annotate(
			NewAclManager,
			fx.ParamTags(``, `optional:"true"`),
		),
	),
)

Functions

This section is empty.

Types

type ACL

type ACL interface {
	Configure(ctx context.Context, rsc string, role Role) error
	Delete(ctx context.Context, rsc string) error
	Authorized(ctx context.Context, rsc string, role Role) bool
	Allowed(ctx context.Context, rsc string) []Role
}

func NewAclManager

func NewAclManager(r repo.Repo, shStore sharedStorage.Provider) (ACL, error)

type Acl

type Acl struct {
	Key   string
	Roles int
}

func (*Acl) GetID

func (m *Acl) GetID() string

func (*Acl) GetNamespace

func (*Acl) GetNamespace() string

func (*Acl) Marshal

func (m *Acl) Marshal() ([]byte, error)

func (*Acl) Unmarshal

func (m *Acl) Unmarshal(b []byte) error

type JWTManager

type JWTManager interface {
	Generate(user User, timeout time.Duration) (string, error)
	Verify(accessToken string) (*UserClaims, error)
}

func NewJWTManager

func NewJWTManager(c config.Config) (JWTManager, error)

NewJWTManager returns a new JWT manager

type Role

type Role string
const (
	None        Role = "none"
	PublicRead  Role = "public_read"
	PublicWrite Role = "public_write"
	AuthRead    Role = "authenticated_read"
	AuthWrite   Role = "authenticated_write"
	Admin       Role = "admin"
)

type User

type User interface {
	ID() string
	Role() string
	Mtdt() map[string]interface{}
}

type UserClaims

type UserClaims struct {
	jwt.StandardClaims
	ID   string                 `json:"id"`
	Role string                 `json:"role"`
	Mtdt map[string]interface{} `json:"mtdt"`
}

UserClaims is a custom JWT claims that contains some user's information

Jump to

Keyboard shortcuts

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