useridentity

package
v3.10.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddressUpdate

type AddressUpdate int
const (
	AddressUpdateNoop AddressUpdate = iota
	AddressUpdateCreated
	AddressUpdateEnabled
	AddressUpdateDisabled
	AddressUpdateUpdated
	AddressUpdateDeleted
)

type BridgePassProvider

type BridgePassProvider interface {
	BridgePass() []byte
}

type FixedBridgePassProvider

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

func NewFixedBridgePassProvider

func NewFixedBridgePassProvider(pass []byte) *FixedBridgePassProvider

func (FixedBridgePassProvider) BridgePass

func (f FixedBridgePassProvider) BridgePass() []byte

type IdentityProvider

type IdentityProvider interface {
	GetUser(ctx context.Context) (proton.User, error)
	GetAddresses(ctx context.Context) ([]proton.Address, error)
}

type KeyPassProvider

type KeyPassProvider interface {
	KeyPass() []byte
}

type Service

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

Service contains all the data required to establish the user identity. This includes all the user's information as well as mail addresses and keys.

func NewService

func NewService(
	service userevents.Subscribable,
	eventPublisher events.EventPublisher,
	state *State,
	bridgePassProvider BridgePassProvider,
	telemetry Telemetry,
) *Service

func (*Service) CheckAuth

func (s *Service) CheckAuth(ctx context.Context, email string, password []byte) (string, error)

func (*Service) GetAPIUser

func (s *Service) GetAPIUser(ctx context.Context) (proton.User, error)

func (*Service) GetAddresses

func (s *Service) GetAddresses(ctx context.Context) (map[string]proton.Address, error)

func (*Service) HandleAddressEvents

func (s *Service) HandleAddressEvents(ctx context.Context, addressEvents []proton.AddressEvent) error

func (*Service) HandleRefreshEvent

func (s *Service) HandleRefreshEvent(ctx context.Context, _ proton.RefreshFlag) error

func (*Service) HandleUsedSpaceEvent

func (s *Service) HandleUsedSpaceEvent(ctx context.Context, newSpace int64) error

func (*Service) HandleUserEvent

func (s *Service) HandleUserEvent(ctx context.Context, user *proton.User) error

func (*Service) Resync

func (s *Service) Resync(ctx context.Context) error

func (*Service) Start

func (s *Service) Start(ctx context.Context, group *orderedtasks.OrderedCancelGroup)

type State

type State struct {
	AddressesSorted []proton.Address
	Addresses       map[string]proton.Address
	User            proton.User
	// contains filtered or unexported fields
}

State holds all the required user identity state. The idea of this type is that it can be replicated across all services to avoid lock contention. The only requirement is that the service with the respective events.

func NewState

func NewState(
	user proton.User,
	addresses []proton.Address,
	provider IdentityProvider,
) *State

func NewStateFromProvider

func NewStateFromProvider(ctx context.Context, provider IdentityProvider) (*State, error)

func (*State) CheckAuth

func (s *State) CheckAuth(email string, password []byte, bridgePassProvider BridgePassProvider) (string, error)

CheckAuth returns whether the given email and password can be used to authenticate over IMAP or SMTP with this user. It returns the address ID of the authenticated address.

func (*State) Clone

func (s *State) Clone() *State

func (*State) GetAddr

func (s *State) GetAddr(email string) (proton.Address, error)

GetAddr returns the address for the given email address.

func (*State) GetAddrByID

func (s *State) GetAddrByID(id string) (proton.Address, bool)

GetAddrByID returns the address for the given addressID.

func (*State) GetPrimaryAddr

func (s *State) GetPrimaryAddr() (proton.Address, error)

GetPrimaryAddr returns the primary address for this user.

func (*State) OnAddressCreated

func (s *State) OnAddressCreated(event proton.AddressEvent) AddressUpdate

func (*State) OnAddressDeleted

func (s *State) OnAddressDeleted(event proton.AddressEvent) (proton.Address, AddressUpdate)

func (*State) OnAddressEvents

func (s *State) OnAddressEvents(events []proton.AddressEvent)

func (*State) OnAddressUpdated

func (s *State) OnAddressUpdated(event proton.AddressEvent) (proton.Address, AddressUpdate)

func (*State) OnRefreshEvent

func (s *State) OnRefreshEvent(ctx context.Context) error

func (*State) OnUserEvent

func (s *State) OnUserEvent(user proton.User)

func (*State) OnUserSpaceChanged

func (s *State) OnUserSpaceChanged(value uint64) bool

func (*State) WithAddrKR

func (s *State) WithAddrKR(addrID string, keyPass []byte, fn func(userKR, addrKR *crypto.KeyRing) error) error

func (*State) WithAddrKRs

func (s *State) WithAddrKRs(keyPass []byte, fn func(*crypto.KeyRing, map[string]*crypto.KeyRing) error) error

type Telemetry

type Telemetry interface {
	ReportConfigStatusFailure(errDetails string)
}

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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