lifecycle

package
v0.0.0-...-3f4c8ed Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: AGPL-3.0 Imports: 40 Imported by: 19

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AskReupload func(*instance.Instance) error

AskReupload is the function that will be called when the disk quota is increased to ask reuploading files from the sharings. A package variable is used to avoid a dependency on the model/sharing package (which would lead to circular import issue).

View Source
var ErrHintSameAsPassword = errors.New("The hint cannot be the same as the password")

ErrHintSameAsPassword is used when trying to set an hint that is the same as the password, which would defeat security (e.g. the hint is not encrypted in CouchDB).

View Source
var ErrInvalidMagicLink = errors.New("invalid magic link")

ErrInvalidMagicLink is used when the code for a magic link is invalid

View Source
var ErrMagicLinkNotAvailable = errors.New("magic link is not available on this instance")

ErrMagicLinkNotAvailable is used when requesting a magic link on a Cozy where this feature has not been activated.

Functions

func AskDeletion

func AskDeletion(inst *instance.Instance) error

func Block

func Block(inst *instance.Instance, reason ...string) error

Block function blocks an instance with an optional reason parameter

func CheckHint

func CheckHint(inst *instance.Instance, setting *settings.Settings, hint string) error

CheckHint returns true if the hint is valid, ie it is not the same as the password.

func CheckMagicLink(inst *instance.Instance, code string) error

func CheckPassphraseRenewToken

func CheckPassphraseRenewToken(inst *instance.Instance, tok []byte) error

CheckPassphraseRenewToken checks whether the given token is good to use for resetting the passphrase.

func ChooseCouchCluster

func ChooseCouchCluster(clusters []config.CouchDBCluster) (int, error)

func Create

func Create(opts *Options) (*instance.Instance, error)

Create builds an instance and initializes it

func CreateKeyPair

func CreateKeyPair(symKey []byte) (string, string, error)

CreateKeyPair creates a key pair for sharing ciphers with a bitwarden organization. It returns in first position the public key, and in second position the private key. The public key is encoded in base64. The private key is encrypted, and in in the cipherString format.

func CreateMagicLinkCode

func CreateMagicLinkCode(inst *instance.Instance) (string, error)

func CreatePassphraseKey

func CreatePassphraseKey(masterKey []byte) (string, []byte, error)

CreatePassphraseKey creates an encryption key for Bitwarden. It returns in the first position the key encrypted with the masterKey, and in clear in second position. See https://github.com/jcs/rubywarden/blob/master/API.md

func DefineViewsAndIndex

func DefineViewsAndIndex(inst *instance.Instance) error

DefineViewsAndIndex can be used to ensure that the CouchDB views and indexes used by the stack are correctly set. It expects that most index/view don't exist. It is faster when creating a new instance for example.

func Destroy

func Destroy(domain string) error

Destroy is used to remove the instance. All the data linked to this instance will be permanently deleted.

func ForceUpdatePassphrase

func ForceUpdatePassphrase(inst *instance.Instance, newPassword []byte, params PassParameters) error

ForceUpdatePassphrase replace the passphrase without checking the current one

func GetInstance

func GetInstance(domain string) (*instance.Instance, error)

GetInstance retrieves the instance for a request by its host.

func ManagerSignTOS

func ManagerSignTOS(inst *instance.Instance, originalReq *http.Request) error

ManagerSignTOS make a request to the manager in order to finalize the TOS signing flow.

func NewSecurityStamp

func NewSecurityStamp() string

NewSecurityStamp returns a new UUID that can be used as a security stamp.

func PassphraseRenew

func PassphraseRenew(inst *instance.Instance, tok []byte, params PassParameters) error

PassphraseRenew changes the passphrase to the specified one if the given token matches the `PassphraseResetToken` field.

func Patch

func Patch(i *instance.Instance, opts *Options) error

Patch updates the given instance with the specified options if necessary. It can also update the settings document if provided in the options.

func RegisterPassphrase

func RegisterPassphrase(inst *instance.Instance, tok []byte, params PassParameters) error

RegisterPassphrase replace the instance registerToken by a passphrase

func RequestPassphraseReset

func RequestPassphraseReset(inst *instance.Instance, from string) error

RequestPassphraseReset generates a new registration token for the user to renew its password.

func Reset

func Reset(inst *instance.Instance) error

Reset will clean all the data from the instances, and most apps. It should be used only just before an import.

func SendHint

func SendHint(inst *instance.Instance) error

SendHint sends by mail the hint for the passphrase.

func SendMagicLink(inst *instance.Instance, redirect string) error

func SendMailConfirmationCode

func SendMailConfirmationCode(inst *instance.Instance) error

SendMailConfirmationCode send a code to validate the email of the instance in order to activate 2FA.

func SendTwoFactorPasscode

func SendTwoFactorPasscode(inst *instance.Instance) ([]byte, error)

SendTwoFactorPasscode sends by mail the two factor secret to the owner of the instance. It returns the generated token.

func Unblock

func Unblock(inst *instance.Instance) error

Unblock reverts the blocking of an instance

func UpdatePassphrase

func UpdatePassphrase(
	inst *instance.Instance,
	current []byte,
	twoFactorPasscode string,
	twoFactorToken []byte,
	params PassParameters,
) error

UpdatePassphrase replace the passphrase

func UpdateViewsAndIndex

func UpdateViewsAndIndex(inst *instance.Instance) error

UpdateViewsAndIndex can be used to ensure that the CouchDB views and indexes used by the stack are correctly set. It has the same effect as DefineViewsAndIndex, but it expect most index/views already exist.

Types

type Options

type Options struct {
	Domain             string
	DomainAliases      []string
	Locale             string
	UUID               string
	OIDCID             string
	FranceConnectID    string
	TOSSigned          string
	TOSLatest          string
	Timezone           string
	ContextName        string
	Sponsorships       []string
	FeatureSets        []string
	Email              string
	PublicName         string
	Settings           string
	SettingsObj        *couchdb.JSONDoc
	AuthMode           string
	Passphrase         string
	Key                string
	KdfIterations      int
	SwiftLayout        int
	CouchCluster       int
	DiskQuota          int64
	Apps               []string
	AutoUpdate         *bool
	MagicLink          *bool
	Debug              *bool
	Traced             *bool
	OnboardingFinished *bool
	Blocked            *bool
	BlockingReason     string
	FromCloudery       bool // Do not call the cloudery when the changes come from it
}

Options holds the parameters to create a new instance.

type PassParameters

type PassParameters struct {
	Pass       []byte // Pass is the password hashed on client side, but not yet on server.
	Iterations int    // Iterations is the number of iterations applied by PBKDF2 on client side.
	Key        string // Key is the encryption key (encrypted, and in CipherString format).
	PublicKey  string // PublicKey is part of the key pair for bitwarden (encoded in base64).
	PrivateKey string // PrivateKey is the other part (encrypted, in CipherString format).
	Hint       string // Hint is the hint for the user to find again their password
}

PassParameters are the parameters for setting a new passphrase

type Store

type Store interface {
	SaveMagicLinkCode(db prefixer.Prefixer, code string) error
	CheckMagicLinkCode(db prefixer.Prefixer, code string) bool
}

Store is an object to store and retrieve magic link codes.

TODO: Move to [token.Service] with [token.MagicLink] namespace.

func GetStore

func GetStore() Store

GetStore returns the store for temporary move objects.

Jump to

Keyboard shortcuts

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