credential

package
v0.0.0-...-0026d00 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToContext

func ToContext(ctx context.Context, creds Credential) context.Context

ToContext returns new context with Credential.

Types

type Credential

type Credential interface {
	GetPrincipal() interface{}
	GetCredentials() interface{}
	IsAuthenticated() bool
	SetAuthenticated(isAuthenticated bool)
	SetUser(user user.User)
	GetUser() user.User
}

Credential interface.

func FromContext

func FromContext(ctx context.Context) Credential

FromContext returns the Credential associated with the ctx.

func NewTokenCredential

func NewTokenCredential(t string) Credential

NewTokenCredential constructor.

func NewUsernamePasswordCredential

func NewUsernamePasswordCredential(principal string, credentials string) Credential

NewUsernamePasswordCredential constructor.

type TokenCredential

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

TokenCredential struct.

func (*TokenCredential) GetCredentials

func (a *TokenCredential) GetCredentials() interface{}

GetCredentials that prove the principal is correct, this is usually a password.

func (*TokenCredential) GetPrincipal

func (a *TokenCredential) GetPrincipal() interface{}

GetPrincipal The identity of the principal being authenticated. In the case of an authentication request with username and password, this would be the username.

func (*TokenCredential) GetUser

func (a *TokenCredential) GetUser() user.User

GetUser return authenticated.

func (*TokenCredential) IsAuthenticated

func (a *TokenCredential) IsAuthenticated() bool

IsAuthenticated returns true if token is authenticated.

func (*TokenCredential) SetAuthenticated

func (a *TokenCredential) SetAuthenticated(isAuthenticated bool)

SetAuthenticated change token to authenticated.

func (*TokenCredential) SetUser

func (a *TokenCredential) SetUser(user user.User)

SetUser set user authenticated.

type UsernamePasswordCredential

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

UsernamePasswordCredential struct.

func (*UsernamePasswordCredential) GetCredentials

func (a *UsernamePasswordCredential) GetCredentials() interface{}

GetCredentials that prove the principal is correct, this is usually a password.

func (*UsernamePasswordCredential) GetPrincipal

func (a *UsernamePasswordCredential) GetPrincipal() interface{}

GetPrincipal The identity of the principal being authenticated. In the case of an authentication request with username and password, this would be the username.

func (*UsernamePasswordCredential) GetUser

func (a *UsernamePasswordCredential) GetUser() user.User

GetUser return authenticated.

func (*UsernamePasswordCredential) IsAuthenticated

func (a *UsernamePasswordCredential) IsAuthenticated() bool

IsAuthenticated returns true if token is authenticated.

func (*UsernamePasswordCredential) SetAuthenticated

func (a *UsernamePasswordCredential) SetAuthenticated(isAuthenticated bool)

SetAuthenticated change token to authenticated.

func (*UsernamePasswordCredential) SetUser

func (a *UsernamePasswordCredential) SetUser(user user.User)

SetUser set user authenticated.

Jump to

Keyboard shortcuts

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