# README
auth
import "github.com/SuperBuker/terraform-provider-dns-he-net/client/auth"
Index
- Constants
- Variables
- func addChecksum(data []byte) ([]byte, error)
- func buildSecret(a *Auth) []byte
- func configFilePath(a *Auth, cs AuthStore) string
- func decrypt(a *Auth, cipherData []byte) ([]byte, error)
- func deserialise(bytes []byte) (string, []*http.Cookie, error)
- func encrypt(a *Auth, data []byte) ([]byte, error)
- func extractChecksum(data []byte) ([]byte, error)
- func initIV(iv []byte) error
- func serialise(account string, cookies []*http.Cookie) ([]byte, error)
- type Auth
- type AuthStore
- type ErrFileChecksum
- type ErrFileEncoding
- type ErrFileEncryption
- type ErrFileIO
- type ErrOTPDisabled
- type Status
- type authStore
- type serialisedStore
Constants
const otpUrl = "otpauth://totp/dns.he.net:%s?secret=%s&issuer=dns.he.net"
Variables
var configPath = configdir.LocalConfig("terraform-provider-dns-he-net")
func addChecksum
func addChecksum(data []byte) ([]byte, error)
addChecksum prepends a checksum to the given data.
func buildSecret
func buildSecret(a *Auth) []byte
buildSecret generates secret from Auth.
func configFilePath
func configFilePath(a *Auth, cs AuthStore) string
configFilePath returns the path to the cookie file for the given user. The cookie file is named depending on the aht username and cookie store type.
func decrypt
func decrypt(a *Auth, cipherData []byte) ([]byte, error)
decrypt the given data using the given Auth, returns new slice and custom error.
func deserialise
func deserialise(bytes []byte) (string, []*http.Cookie, error)
func encrypt
func encrypt(a *Auth, data []byte) ([]byte, error)
encrypt the given data using the given Auth, returns new slice and custom error.
func extractChecksum
func extractChecksum(data []byte) ([]byte, error)
extractChecksum given data, returns new slice and error.
func initIV
func initIV(iv []byte) error
initIV creates a new nonce, returns error.
func serialise
func serialise(account string, cookies []*http.Cookie) ([]byte, error)
type Auth
type Auth struct {
User string
Password string
OTPKey *otp.Key
store authStore
}
func NewAuth
func NewAuth(user, pass, otpSecret string, storeMode AuthStore) (Auth, error)
NewAuth returns an Auth struct with the given user, password and otpSecret. The OTPKey is generated from the otpSecret. The cookieStore is selected by the storeMode.
func (*Auth) GetAuthForm
func (a *Auth) GetAuthForm() map[string]string
GetAuthForm returns a map with the user and password fields.
func (*Auth) GetCode
func (a *Auth) GetCode() (string, error)
GetCode returns the OTP code generated by the OTPKey.
func (*Auth) Load
func (a *Auth) Load() (string, []*http.Cookie, error)
Load returns the cookies stored in the cookieStore if they are not expired.
func (*Auth) Save
func (a *Auth) Save(account string, cookies []*http.Cookie) error
Save saves the cookies in the cookieStore.
type AuthStore
type AuthStore int8
const (
Dummy AuthStore = iota
Simple
Encrypted
)
type ErrFileChecksum
ErrFileChecksum is returned by the Reader when the file checksum fails to validate.
type ErrFileChecksum struct {
}
func (*ErrFileChecksum) Error
func (e *ErrFileChecksum) Error() string
Error returns a human-readable error message.
func (*ErrFileChecksum) Unwrap
func (e *ErrFileChecksum) Unwrap() []error
Unwrap implements the errors.Unwrap interface.
type ErrFileEncoding
ErrFileEncoding is an error returned when there is an issue decoding or encoding a file.
type ErrFileEncoding struct {
err error
}
func (*ErrFileEncoding) Error
func (e *ErrFileEncoding) Error() string
Error returns a human-readable error message.
func (*ErrFileEncoding) Unwrap
func (e *ErrFileEncoding) Unwrap() []error
Unwrap returns the underlying error that caused this error.
type ErrFileEncryption
ErrFileEncryption is returned by the when the file encryption fails.
type ErrFileEncryption struct {
err error
}
func (*ErrFileEncryption) Error
func (e *ErrFileEncryption) Error() string
Error returns a human-readable error message.
func (*ErrFileEncryption) Unwrap
func (e *ErrFileEncryption) Unwrap() []error
Unwrap returns the underlying error that caused this error.
type ErrFileIO
ErrFileIO is an error returned when there is an issue reading from or writing to a file.
type ErrFileIO struct {
err error
}
func (*ErrFileIO) Error
func (e *ErrFileIO) Error() string
Error returns a human-readable error message.
func (*ErrFileIO) Unwrap
func (e *ErrFileIO) Unwrap() []error
Unwrap returns the underlying error that caused this error.
type ErrOTPDisabled
ErrOTPDisabled is an error returned when the OTP is disabled.
type ErrOTPDisabled struct {
}
func (*ErrOTPDisabled) Error
func (e *ErrOTPDisabled) Error() string
Error returns a human-readable error message.
func (*ErrOTPDisabled) Unwrap
func (e *ErrOTPDisabled) Unwrap() []error
Unwrap implements the errors.Unwrap interface.
type Status
Status indicates the current authentication status.
type Status int8
const (
NoAuth Status = iota
Ok
OTP
Unknown
Other
)
type authStore
type authStore struct {
Load func(a *Auth) (string, []*http.Cookie, error)
Save func(a *Auth, account string, cookies []*http.Cookie) error
}
func dummyStore
func dummyStore() authStore
Load and Save functions for a dummy cookie store. Load() returns a not implemented error, Save() skips the operation.
func encryptedStore
func encryptedStore() authStore
Load and Save functions for a encrypted and checksum validated cookie store.
func simpleStore
func simpleStore() authStore
Load and Save functions for a simple file-based cookie store.
func storeSelector
func storeSelector(cs AuthStore) authStore
type serialisedStore
type serialisedStore struct {
Account string `json:"account"`
Cookies []*http.Cookie `json:"cookies"`
}
Generated by gomarkdoc