auth

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Wrapper

func Wrapper(r resolver.Resolver, prefix string) api.Wrapper

Wrapper wraps a handler and authenticates requests

Types

type BlockList

type BlockList interface {
	// IsBlocked returns true if the id is blocked
	IsBlocked(ctx context.Context, id, namespace string) (bool, error)
	// Add adds an ID to the blocklist
	Add(ctx context.Context, id, namespace string) error
	// Remove removes an ID from the blocklist
	Remove(ctx context.Context, id, namespace string) error
	// List returns the entire list of blocked IDs
	List(ctx context.Context) ([]string, error)
}

BlockList manages a list of blocked IDs.

var DefaultBlockList BlockList = &InMemoryBlockList{
	blocked: map[string]bool{},
}

type InMemoryBlockList

type InMemoryBlockList struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

InMemoryBlockList is an implementation of BlockList that maintains the list in memory only.

func (*InMemoryBlockList) Add

func (i *InMemoryBlockList) Add(ctx context.Context, id, namespace string) error

func (*InMemoryBlockList) IsBlocked

func (i *InMemoryBlockList) IsBlocked(ctx context.Context, id, namespace string) (bool, error)

func (*InMemoryBlockList) List

func (i *InMemoryBlockList) List(ctx context.Context) ([]string, error)

func (*InMemoryBlockList) Remove

func (i *InMemoryBlockList) Remove(ctx context.Context, id, namespace string) error

Jump to

Keyboard shortcuts

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