lifecycle

package
v0.0.0-...-4b98c26 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2021 License: AGPL-3.0 Imports: 34 Imported by: 0

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).

Functions

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 CheckPassphrase

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

CheckPassphrase confirm an instance password

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 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 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 CreateWithoutHooks

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

CreateWithoutHooks builds an instance and initializes it. The difference with Create is that script hooks are not executed for this function.

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.

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) 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 SendMail

func SendMail(inst *instance.Instance, m *Mail) error

SendMail send a mail to the instance owner.

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 Triggers

func Triggers(db prefixer.Prefixer) []job.TriggerInfos

Triggers returns the list of the triggers to add when an instance is created

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

Types

type Mail

type Mail struct {
	TemplateName   string
	TemplateValues map[string]interface{}
}

Mail contains the informations to send a mail for the instance owner.

type Options

type Options struct {
	Domain             string
	DomainAliases      []string
	Locale             string
	UUID               string
	OIDCID             string
	TOSSigned          string
	TOSLatest          string
	Timezone           string
	ContextName        string
	Email              string
	PublicName         string
	Settings           string
	SettingsObj        *couchdb.JSONDoc
	AuthMode           string
	Passphrase         string
	Key                string
	KdfIterations      int
	SwiftLayout        int
	DiskQuota          int64
	Apps               []string
	AutoUpdate         *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

Jump to

Keyboard shortcuts

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