auth

package
v1.24.3 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PermissionAdmin = "*:*:*"
	PermissionNone  = ""
)

Variables

This section is empty.

Functions

func Permission

func Permission(resource, action, id string) string

Types

type AuthenticationManager

type AuthenticationManager interface {
	UserInfo(ctx context.Context, token string) (UserInfo, error)
}

type AuthorizationManager

type AuthorizationManager interface {
	AddPermission(ctx context.Context, username string, permissions string) error
	ListPermissions(ctx context.Context, username string) ([]string, error)
	ListUsersHasPermission(ctx context.Context, permission string) ([]string, error)
	RemovePermission(ctx context.Context, username string, permissions string) error
	HasPermission(ctx context.Context, username string, permission string) bool
}

type LocalAuthorization

type LocalAuthorization struct {
	// contains filtered or unexported fields
}

func NewLocalAuthorization

func NewLocalAuthorization(ctx context.Context, db *mongo.Database) *LocalAuthorization

func (*LocalAuthorization) AddPermission

func (a *LocalAuthorization) AddPermission(ctx context.Context, username string, permission string) error

func (*LocalAuthorization) HasPermission

func (a *LocalAuthorization) HasPermission(ctx context.Context, username string, permission string) bool

func (*LocalAuthorization) Init

func (a *LocalAuthorization) Init(ctx context.Context) error

func (*LocalAuthorization) ListPermissions

func (a *LocalAuthorization) ListPermissions(ctx context.Context, username string) ([]string, error)

func (*LocalAuthorization) ListUsersHasPermission

func (a *LocalAuthorization) ListUsersHasPermission(ctx context.Context, permissionRegexp string) ([]string, error)

func (*LocalAuthorization) RemovePermission

func (a *LocalAuthorization) RemovePermission(ctx context.Context, username string, permission string) error

type UnVerifyJWTAuthenticationManager

type UnVerifyJWTAuthenticationManager struct{}

func NewUnVerifyJWTAuthenticationManager

func NewUnVerifyJWTAuthenticationManager() *UnVerifyJWTAuthenticationManager

func (*UnVerifyJWTAuthenticationManager) UserInfo

type UserInfo

type UserInfo struct {
	Username string `json:"username,omitempty"`
}

Jump to

Keyboard shortcuts

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