shared

package
v0.0.0-...-af18150 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const BasicAuthUserKey = "BasicAuthUserKey"
View Source
const BearerUserKey = "BearerUserKey"
View Source
const RefKeyForBasicAuthAccountCenter = "mdl.basic_auth_account"
View Source
const RefKeyForBearerValidator = "mdl.bearer_validator"

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	User  string `json:"user"`
	Email string `json:"email"`
	// contains filtered or unexported fields
}

type BasicAuthAccountCenter

type BasicAuthAccountCenter interface {
	GetRealm() string
	SearchCredential(credential string) (account any, found bool)
}

BasicAuthAccountCenter

     ac := &AccountCenter{} // the struct must implement BasicAuthAccountCenter interface
	 config := NewWebConfig().SetDependentRef(RefKeyForBasicAuthAccountCenter, ac)

type BasicAuthMiddleware

type BasicAuthMiddleware struct {
	WebMiddleware
	// contains filtered or unexported fields
}

func (*BasicAuthMiddleware) Authorize

func (b *BasicAuthMiddleware) Authorize(ctx struct {
	WebContext `http:"basic_auth,method=handle"`
})

func (*BasicAuthMiddleware) DidDependencyInitialization

func (b *BasicAuthMiddleware) DidDependencyInitialization()

type BearerMiddleware

type BearerMiddleware struct {
	WebMiddleware
	// contains filtered or unexported fields
}

func (*BearerMiddleware) ParseBearerHeader

func (b *BearerMiddleware) ParseBearerHeader(ctx struct {
	WebContext `http:"bearer,method=handle"`
})

type BearerValidator

type BearerValidator interface {
	BearerSecret() string
	ValidateClaims(claims any) (userData any, err error)
}

BearerValidator

     av := &AccountValidator{} // the struct must implement BearerValidator interface
	 config := NewWebConfig().SetDependentRef(RefKeyForBearerValidator, av)

type FakeAccountDb

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

FakeAccountDb should implement BasicAuthAccountCenter interface

func (*FakeAccountDb) BearerSecret

func (a *FakeAccountDb) BearerSecret() string

BearerSecret implements one function of BearerValidator interface.

func (*FakeAccountDb) GetRealm

func (a *FakeAccountDb) GetRealm() string

GetRealm implements one function of BasicAuthAccountCenter interface.

func (*FakeAccountDb) InitFakeDb

func (a *FakeAccountDb) InitFakeDb() []Account

func (*FakeAccountDb) SearchCredential

func (a *FakeAccountDb) SearchCredential(credential string) (account any, found bool)

SearchCredential implements one function of BasicAuthAccountCenter interface.

func (*FakeAccountDb) ValidateClaims

func (a *FakeAccountDb) ValidateClaims(claims any) (userData any, err error)

ValidateClaims implements one function of BearerValidator interface.

Jump to

Keyboard shortcuts

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