gowarden

package module
v0.0.0-...-52da49d Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2024 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashPassword

func HashPassword(password string, key []byte) []byte

func HashPasswordBase64

func HashPasswordBase64(kdfParams Kdf, email, password string) string

Types

type BWConfig

type BWConfig struct {
	// urls for the servers endpoints
	Environment BWEnvironment `json:"environment"`
	// collection of bools representing available features
	FeatureStates BWFeatureStates `json:"featureStates"`
	GitHash       string          `json:"gitHash"`
	Object        string          `json:"object"`
	Server        BWServer        `json:"server"`
	Version       string          `json:"version"`
}

func GetBwConfig

func GetBwConfig(bwApiUrl url.URL) (*BWConfig, error)

type BWEnvironment

type BWEnvironment struct {
	Api          string `json:"api"`
	Identity     string `json:"identity"`
	Notification string `json:"notification"`
	Sso          string `json:"sso"`
	Vault        string `json:"vault"`
}

type BWFeatureStates

type BWFeatureStates struct {
	Fido2VaultCredentials   bool `json:"fido2-vault-credentials"`
	FlexibleCollectionsV1   bool `json:"flexible-collections-v-1"`
	KeyRotationImprovements bool `json:"key-rotation-improvements"`
}

type BWServer

type BWServer struct {
	Name    string `json:"name"`
	Url     string `json:"url"`
	Version string `json:"version"`
}

type KDFType

type KDFType uint
const (
	PBKDF2   KDFType = 0
	Argon2ID KDFType = 1
)

type Kdf

type Kdf struct {
	Type        KDFType `json:"kdf"`
	Iterations  uint32  `json:"kdfIterations"`
	Memory      uint32  `json:"kdfMemory"`
	Parallelism uint32  `json:"kdfParallelism"`
}

func Prelogin

func Prelogin(cfg BWConfig, email string) (*Kdf, error)

TODO: check if other request bodys than email are possible

type LoginResponse

type LoginResponse struct {
	MasterPasswordPolicy struct {
		Object string `json:"Object"`
	} `json:"MasterPasswordPolicy"`
	// type ids of available 2fa methods for the user
	TwoFactorProviders []string `json:"TwoFactorProviders"`
	// parameters for the available 2fa methods
	TwoFactorProviders2 map[string]interface{} `json:"TwoFactorProviders2"`
	// error message
	Error string `json:"error"`
	// error description
	ErrorDescription string `json:"error_description"`
	ErrorModel       struct {
		Message string `json:"message"`
		Object  string `json:"object"`
	} `json:"errorModel"`
	ExceptionMessage      string              `json:"exceptionMessage"`
	ExceptionStackTrace   string              `json:"exceptionStackTrace"`
	InnerExceptionMessage string              `json:"innerExceptionMessage"`
	Message               string              `json:"message"`
	ValidationErrors      map[string][]string `json:"validationErrors"`
	ForcePasswordReset    bool                `json:"forcePasswordReset"`
	Kdf                   KDFType             `json:"Kdf"`
	KdfIterations         uint32              `json:"KdfIterations"`
	KdfMemory             uint32              `json:"KdfMemory"`
	KdfParallelism        uint32              `json:"KdfParallelism"`
	Key                   string              `json:"Key"`
	PrivateKey            string              `json:"PrivateKey"`
	ResetMasterPassword   bool                `json:"ResetMasterPassword"`
	UserDecryptionOptions struct {
		HasMasterPassword bool   `json:"HasMasterPassword"`
		Object            string `json:"Object"`
	} `json:"UserDecryptionOptions"`
	AccessToken      string `json:"access_token"`
	ExpiresIn        int    `json:"expires_in"`
	TokenType        string `json:"token_type"`
	RefreshToken     string `json:"refresh_token"`
	UnofficialServer bool   `json:"unofficial_server"`
}

response from identity/connect/token

func Login

func Login(identityUrl, client_id, email, passwordHash string, mfaToken *MFAToken) (*LoginResponse, error)

type MFAToken

type MFAToken struct {
	Type MFAType
	Data string
}

type MFAType

type MFAType uint
const (
	// classig Authy, Google Authenticator, etc. time based OTP
	MFATypeTOTP MFAType = 0
	// YubiKey OTP
	MFATypeYubiKeyOTP = 3
)

func (MFAType) String

func (t MFAType) String() string

Jump to

Keyboard shortcuts

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