auth

package
v1.8.4 Latest Latest
Warning

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

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

Documentation

Overview

Package auth provides authentication methods.

Index

Constants

View Source
const (
	MtSCRAMSHA256       = "SCRAMSHA256"       // password
	MtSCRAMPBKDF2SHA256 = "SCRAMPBKDF2SHA256" // password pbkdf2
	MtX509              = "X509"              // client certificate
	MtJWT               = "JWT"               // json web token
	MtSessionCookie     = "SessionCookie"     // session cookie
)

authentication method types supported by the driver:

  • basic authentication (username, password based) (whether SCRAMSHA256 or SCRAMPBKDF2SHA256) and
  • X509 (client certificate) authentication and
  • JWT (token) authentication
View Source
const (
	MoSessionCookie byte = iota
	MoX509
	MoJWT
	MoSCRAMPBKDF2SHA256
	MoSCRAMSHA256
)

authentication method orders.

Variables

This section is empty.

Functions

This section is empty.

Types

type CookieGetter added in v1.3.6

type CookieGetter interface {
	Cookie() (logonname string, cookie []byte)
}

CookieGetter is implemented by authentication methods supporting cookies to reconnect.

type Decoder

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

Decoder represents an authentication decoder.

func NewDecoder

func NewDecoder(d *encoding.Decoder) *Decoder

NewDecoder returns a new decoder instance.

func (*Decoder) NumPrm

func (d *Decoder) NumPrm(expected int) error

NumPrm ckecks the number of parameters and returns an error if not equal expected, nil otherwise.

func (*Decoder) String

func (d *Decoder) String() string

type JWT

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

JWT implements JWT authentication.

func NewJWT

func NewJWT(token string) *JWT

NewJWT creates a new authJWT instance.

func (*JWT) Cookie

func (a *JWT) Cookie() (string, []byte)

Cookie implements the AuthCookieGetter interface.

func (*JWT) FinalRepDecode

func (a *JWT) FinalRepDecode(d *Decoder) error

FinalRepDecode implements the Method interface.

func (*JWT) InitRepDecode

func (a *JWT) InitRepDecode(d *Decoder) error

InitRepDecode implements the Method interface.

func (*JWT) Order

func (a *JWT) Order() byte

Order implements the Method interface.

func (*JWT) PrepareFinalReq

func (a *JWT) PrepareFinalReq(prms *Prms) error

PrepareFinalReq implements the Method interface.

func (*JWT) PrepareInitReq

func (a *JWT) PrepareInitReq(prms *Prms) error

PrepareInitReq implements the Method interface.

func (*JWT) String

func (a *JWT) String() string

func (*JWT) Typ

func (a *JWT) Typ() string

Typ implements the Method interface.

type Method

type Method interface {
	fmt.Stringer
	Typ() string
	Order() byte
	PrepareInitReq(prms *Prms) error
	InitRepDecode(d *Decoder) error
	PrepareFinalReq(prms *Prms) error
	FinalRepDecode(d *Decoder) error
}

A Method defines the interface for an authentication method.

type Methods added in v1.3.6

type Methods map[string]Method // key equals authentication method type.

Methods defines a collection of methods.

func (Methods) Order added in v1.3.6

func (m Methods) Order() []Method

Order returns an ordered method slice.

type Prms

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

Prms represents authentication parameters.

func (*Prms) AddCESU8String

func (p *Prms) AddCESU8String(s string)

AddCESU8String adds a CESU8 string parameter.

func (*Prms) Decode added in v1.2.0

func (p *Prms) Decode(dec *encoding.Decoder) error

Decode decodes the parameters.

func (*Prms) Encode

func (p *Prms) Encode(enc *encoding.Encoder) error

Encode encodes the parameters.

func (*Prms) Size

func (p *Prms) Size() int

Size returns the size in bytes of the parameters.

func (*Prms) String

func (p *Prms) String() string

type SCRAMPBKDF2SHA256

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

SCRAMPBKDF2SHA256 implements SCRAMPBKDF2SHA256 authentication.

func NewSCRAMPBKDF2SHA256

func NewSCRAMPBKDF2SHA256(username, password string) *SCRAMPBKDF2SHA256

NewSCRAMPBKDF2SHA256 creates a new authSCRAMPBKDF2SHA256 instance.

func (*SCRAMPBKDF2SHA256) FinalRepDecode

func (a *SCRAMPBKDF2SHA256) FinalRepDecode(d *Decoder) error

FinalRepDecode implements the Method interface.

func (*SCRAMPBKDF2SHA256) InitRepDecode

func (a *SCRAMPBKDF2SHA256) InitRepDecode(d *Decoder) error

InitRepDecode implements the Method interface.

func (*SCRAMPBKDF2SHA256) Order

func (a *SCRAMPBKDF2SHA256) Order() byte

Order implements the Method interface.

func (*SCRAMPBKDF2SHA256) PrepareFinalReq

func (a *SCRAMPBKDF2SHA256) PrepareFinalReq(prms *Prms) error

PrepareFinalReq implements the Method interface.

func (*SCRAMPBKDF2SHA256) PrepareInitReq

func (a *SCRAMPBKDF2SHA256) PrepareInitReq(prms *Prms) error

PrepareInitReq implements the Method interface.

func (*SCRAMPBKDF2SHA256) String

func (a *SCRAMPBKDF2SHA256) String() string

func (*SCRAMPBKDF2SHA256) Typ

func (a *SCRAMPBKDF2SHA256) Typ() string

Typ implements the Method interface.

type SCRAMSHA256

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

SCRAMSHA256 implements SCRAMSHA256 authentication.

func NewSCRAMSHA256

func NewSCRAMSHA256(username, password string) *SCRAMSHA256

NewSCRAMSHA256 creates a new authSCRAMSHA256 instance.

func (*SCRAMSHA256) FinalRepDecode

func (a *SCRAMSHA256) FinalRepDecode(d *Decoder) error

FinalRepDecode implements the Method interface.

func (*SCRAMSHA256) InitRepDecode

func (a *SCRAMSHA256) InitRepDecode(d *Decoder) error

InitRepDecode implements the Method interface.

func (*SCRAMSHA256) Order

func (a *SCRAMSHA256) Order() byte

Order implements the Method interface.

func (*SCRAMSHA256) PrepareFinalReq

func (a *SCRAMSHA256) PrepareFinalReq(prms *Prms) error

PrepareFinalReq implements the Method interface.

func (*SCRAMSHA256) PrepareInitReq

func (a *SCRAMSHA256) PrepareInitReq(prms *Prms) error

PrepareInitReq implements the Method interface.

func (*SCRAMSHA256) String

func (a *SCRAMSHA256) String() string

func (*SCRAMSHA256) Typ

func (a *SCRAMSHA256) Typ() string

Typ implements the Method interface.

type SessionCookie

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

SessionCookie implements session cookie authentication.

func NewSessionCookie

func NewSessionCookie(cookie []byte, logonname, clientID string) *SessionCookie

NewSessionCookie creates a new authSessionCookie instance.

func (*SessionCookie) FinalRepDecode

func (a *SessionCookie) FinalRepDecode(d *Decoder) error

FinalRepDecode implements the Method interface.

func (*SessionCookie) InitRepDecode

func (a *SessionCookie) InitRepDecode(d *Decoder) error

InitRepDecode implements the Method interface.

func (*SessionCookie) Order

func (a *SessionCookie) Order() byte

Order implements the Method interface.

func (*SessionCookie) PrepareFinalReq

func (a *SessionCookie) PrepareFinalReq(prms *Prms) error

PrepareFinalReq implements the Method interface.

func (*SessionCookie) PrepareInitReq

func (a *SessionCookie) PrepareInitReq(prms *Prms) error

PrepareInitReq implements the Method interface.

func (*SessionCookie) String

func (a *SessionCookie) String() string

func (*SessionCookie) Typ

func (a *SessionCookie) Typ() string

Typ implements the Mthod interface.

type X509

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

X509 implements X509 authentication.

func NewX509

func NewX509(certKey *x509.CertKey) *X509

NewX509 creates a new authX509 instance.

func (*X509) FinalRepDecode

func (a *X509) FinalRepDecode(d *Decoder) error

FinalRepDecode implements the Method interface.

func (*X509) InitRepDecode

func (a *X509) InitRepDecode(d *Decoder) error

InitRepDecode implements the Method interface.

func (*X509) Order

func (a *X509) Order() byte

Order implements the Method interface.

func (*X509) PrepareFinalReq

func (a *X509) PrepareFinalReq(prms *Prms) error

PrepareFinalReq implements the Method interface.

func (*X509) PrepareInitReq

func (a *X509) PrepareInitReq(prms *Prms) error

PrepareInitReq implements the Method interface.

func (*X509) String

func (a *X509) String() string

func (*X509) Typ

func (a *X509) Typ() string

Typ implements the Method interface.

Jump to

Keyboard shortcuts

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