auth

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SessionRestriction_Unrestricted    SessionRestriction = 0
	SessionRestriction_AccountRecovery                    = 1 << 0
	SessionRestriction_ShareAccount                       = 1 << 1
	SessionRestriction_AcceptInvite                       = 1 << 2
	SessionRestriction_AccountExpired                     = 1 << 3
)
View Source
const ClientVersion = "c16.9.0"
View Source
const DefaultDeviceName = "GoLang Keeper API"
View Source
const DefaultKeeperServer = "keepersecurity.com"
View Source
const DefaultLocale = "en_US"

Variables

This section is empty.

Functions

func AdjustServerName

func AdjustServerName(servername string) string

func AdjustUserName

func AdjustUserName(username string) string

func CopyConfiguration

func CopyConfiguration(fromConfig IKeeperConfiguration, toConfig IKeeperConfiguration)

func GetTeamKeys

func GetTeamKeys(keeperAuth IKeeperAuth, teamKeys map[string][]byte) (errs []error)

func GetUserPublicKeys

func GetUserPublicKeys(keeperAuth IKeeperAuth, userKeys map[string]*PublicKeys) (errs []error)

func PrepareApiRequest

func PrepareApiRequest(keyId int32, payload []byte, transmissionKey []byte, sessionToken []byte, locale string) (result *proto_auth.ApiRequest, err error)

Types

type AccountAuthType

type AccountAuthType int32
const (
	AuthType_Regular AccountAuthType = iota + 1
	AuthType_SsoCloud
	AuthType_OnsiteSso
	AuthType_ManagedCompany
)

type DataKeyShareChannel

type DataKeyShareChannel = int32
const (
	DataKeyShare_KeeperPush DataKeyShareChannel = iota + 1
	DataKeyShare_AdminApproval
)

type DeviceApprovalChannel

type DeviceApprovalChannel = int32
const (
	DeviceApproval_Email DeviceApprovalChannel = iota
	DeviceApproval_TwoFactorAuth
	DeviceApproval_KeeperPush
)

type DeviceConfiguration

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

func CloneDeviceConfiguration

func CloneDeviceConfiguration(other IDeviceConfiguration) *DeviceConfiguration

func NewDeviceConfiguration

func NewDeviceConfiguration(deviceToken string, deviceKey []byte) *DeviceConfiguration

func (*DeviceConfiguration) DeviceKey

func (d *DeviceConfiguration) DeviceKey() []byte

func (*DeviceConfiguration) DeviceToken

func (d *DeviceConfiguration) DeviceToken() string

func (*DeviceConfiguration) Id

func (d *DeviceConfiguration) Id() string

func (*DeviceConfiguration) ServerInfo

type DeviceServerConfiguration

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

func NewDeviceServerConfiguration

func NewDeviceServerConfiguration(server string) *DeviceServerConfiguration

func (*DeviceServerConfiguration) CloneCode

func (ds *DeviceServerConfiguration) CloneCode() string

func (*DeviceServerConfiguration) Id

func (*DeviceServerConfiguration) Server

func (ds *DeviceServerConfiguration) Server() string

func (*DeviceServerConfiguration) SetCloneCode

func (ds *DeviceServerConfiguration) SetCloneCode(cloneCode string)

type IAuthContext

type IAuthContext interface {
	Username() string
	AccountUid() string
	SessionToken() []byte
	SessionRestriction() SessionRestriction
	DataKey() []byte
	ClientKey() []byte
	RsaPrivateKey() *rsa.PrivateKey
	EcPrivateKey() *ecdh.PrivateKey
	EcPublicKey() *ecdh.PublicKey
	EnterpriseEcPublicKey() *ecdh.PublicKey
	EnterpriseRsaPublicKey() *rsa.PublicKey
	IsEnterpriseAdmin() bool
	License() *proto_account_summary.License
	Settings() *proto_account_summary.Settings
	Enforcements() *proto_account_summary.Enforcements
	SsoLoginInfo() ISsoLoginInfo
	DeviceToken() []byte
	DevicePrivateKey() *ecdh.PrivateKey
}

type IConfigurationCollection

type IConfigurationCollection[T IEntityId] interface {
	Get(string) T
	Put(T)
	Delete(string)
	List(func(T) bool)
}

type IConfigurationStorage

type IConfigurationStorage interface {
	Get() (IKeeperConfiguration, error)
	Put(IKeeperConfiguration) error
}

func NewCommanderConfiguration

func NewCommanderConfiguration(filename string) IConfigurationStorage

func NewInMemoryConfigurationStorage

func NewInMemoryConfigurationStorage(configuration IKeeperConfiguration) IConfigurationStorage

func NewJsonConfigurationFile

func NewJsonConfigurationFile(filePath string) IConfigurationStorage

func NewJsonConfigurationStorage

func NewJsonConfigurationStorage(loader IJsonConfigurationLoader) IConfigurationStorage

type IConnectedStep

type IConnectedStep interface {
	ILoginStep
	TakeKeeperAuth() (IKeeperAuth, error)
}

type IDeviceApprovalStep

type IDeviceApprovalStep interface {
	ILoginStep
	SendPush(DeviceApprovalChannel) error
	SendCode(DeviceApprovalChannel, string) error
	Resume() error
}

type IDeviceConfiguration

type IDeviceConfiguration interface {
	IEntityId
	DeviceToken() string
	DeviceKey() []byte
	ServerInfo() IConfigurationCollection[IDeviceServerConfiguration]
}

type IDeviceServerConfiguration

type IDeviceServerConfiguration interface {
	IEntityId
	Server() string
	CloneCode() string
}

type IEntityId

type IEntityId interface {
	Id() string
}

type IErrorStep

type IErrorStep interface {
	ILoginStep
	Error() error
}

type IJsonConfigurationLoader

type IJsonConfigurationLoader interface {
	LoadJson() ([]byte, error)
	StoreJson([]byte) error
}

func NewJsonConfigurationFileLoader

func NewJsonConfigurationFileLoader(filename string) IJsonConfigurationLoader

type IKeeperAuth

type IKeeperAuth interface {
	io.Closer
	Endpoint() IKeeperEndpoint
	PushNotifications() IPushEndpoint
	AuthContext() IAuthContext
	ExecuteAuthCommand(api.IKeeperCommand, api.IKeeperResponse, bool) error
	ExecuteAuthRest(string, proto.Message, proto.Message) error
	ExecuteBatch([]api.IKeeperCommand) ([]*api.KeeperApiResponse, error)
	OnIdle()
}

type IKeeperConfiguration

type IKeeperConfiguration interface {
	Users() IConfigurationCollection[IUserConfiguration]
	Servers() IConfigurationCollection[IServerConfiguration]
	Devices() IConfigurationCollection[IDeviceConfiguration]

	LastLogin() string
	SetLastLogin(string)

	LastServer() string
	SetLastServer(string)
}

type IKeeperEndpoint

type IKeeperEndpoint interface {
	ClientVersion() string
	SetClientVersion(string)
	DeviceName() string
	SetDeviceName(string)
	Locale() string
	SetLocale(string)
	Server() string
	SetServer(string)
	ServerKeyId() int32

	CommunicateKeeper(string, []byte, []byte) ([]byte, error)

	PushServer() string
	ConnectToPushServer(*proto_auth.WssConnectionRequest) (IPushEndpoint, error)
	ConfigurationStorage() IConfigurationStorage
}

func NewKeeperEndpoint

func NewKeeperEndpoint(server string, storage IConfigurationStorage) IKeeperEndpoint

type ILoginAuth

type ILoginAuth interface {
	io.Closer
	Endpoint() IKeeperEndpoint
	Step() ILoginStep

	Login(string, ...string)
	LoginSso(string)

	AlternatePassword() bool
	SetAlternatePassword(bool)
	ResumeSession() bool
	SetResumeSession(bool)
	OnNextStep() func()
	SetOnNextStep(func())
	OnRegionChanged() func(string)
	SetOnRegionChanged(func(string))
}

func NewLoginAuth

func NewLoginAuth(endpoint IKeeperEndpoint) ILoginAuth

type ILoginStep

type ILoginStep interface {
	io.Closer
	LoginState() LoginState
}

type IPasswordStep

type IPasswordStep interface {
	ILoginStep
	Username() string
	VerifyPassword(string) error
	VerifyBiometricKey([]byte) error
}

type IPushEndpoint

type IPushEndpoint interface {
	io.Closer
	IsClosed() bool
	RegisterCallback(PushCallback)
	RemoveCallback(PushCallback)
	RemoveAllCallback()
	Push(*NotificationEvent)
	SendToPushChannel([]byte, bool) error
}

func NewWebSocketEndpoint

func NewWebSocketEndpoint(url string, key []byte) IPushEndpoint

type IServerConfiguration

type IServerConfiguration interface {
	IEntityId
	Server() string
	ServerKeyId() int32
}

type ISsoDataKeyStep

type ISsoDataKeyStep interface {
	ILoginStep
	Channels() []DataKeyShareChannel
	RequestDataKey(DataKeyShareChannel) error
	Resume() error
}

type ISsoLoginInfo

type ISsoLoginInfo interface {
	IsCloud() bool
	SsoProvider() string
	SsoUrl() string
	IdpSessionId() string
}

type ISsoTokenStep

type ISsoTokenStep interface {
	ILoginStep
	LoginName() string
	LoginAsProvider() bool
	SsoLoginUrl() string
	IsCloudSso() bool
	SetSsoToken(string) error
	LoginWithPassword() error
}

type ITwoFactorChannelInfo

type ITwoFactorChannelInfo interface {
	ChannelType() TwoFactorChannel
	ChannelName() string
	ChannelUid() []byte
	Phone() string
	PushActions() []TwoFactorPushAction
	MaxDuration() TwoFactorDuration
}

type ITwoFactorStep

type ITwoFactorStep interface {
	ILoginStep
	Channels() []ITwoFactorChannelInfo
	Duration() TwoFactorDuration
	SetDuration(TwoFactorDuration)
	SendPush([]byte, TwoFactorPushAction) error
	SendCode([]byte, string) error
	Resume() error
}

type IUserConfiguration

type IUserConfiguration interface {
	IEntityId
	Username() string
	Password() string
	Server() string
	LastDevice() IUserDeviceConfiguration
}

type IUserDeviceConfiguration

type IUserDeviceConfiguration interface {
	IEntityId
	DeviceToken() string
}

type KeeperConfiguration

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

func CloneKeeperConfiguration

func CloneKeeperConfiguration(other IKeeperConfiguration) *KeeperConfiguration

func NewKeeperConfiguration

func NewKeeperConfiguration() *KeeperConfiguration

func (*KeeperConfiguration) Devices

func (*KeeperConfiguration) LastLogin

func (c *KeeperConfiguration) LastLogin() string

func (*KeeperConfiguration) LastServer

func (c *KeeperConfiguration) LastServer() string

func (*KeeperConfiguration) Servers

func (*KeeperConfiguration) SetLastLogin

func (c *KeeperConfiguration) SetLastLogin(lastLogin string)

func (*KeeperConfiguration) SetLastServer

func (c *KeeperConfiguration) SetLastServer(lastServer string)

func (*KeeperConfiguration) Users

type LoginState

type LoginState = int
const (
	LoginState_Ready LoginState = iota + 1
	LoginState_DeviceApproval
	LoginState_TwoFactor
	LoginState_Password
	LoginState_SsoToken
	LoginState_SsoDataKey
	LoginState_Connected
	LoginState_Error
)

type NotificationEvent

type NotificationEvent struct {
	Command              string `json:"command"`
	Event                string `json:"event"`
	Message              string `json:"message"`
	Email                string `json:"email"`
	Username             string `json:"username"`
	Approved             bool   `json:"approved"`
	Sync                 bool   `json:"sync"`
	Passcode             string `json:"passcode"`
	DeviceName           string `json:"deviceName"`
	EncryptedLoginToken  string `json:"encryptedLoginToken"`
	EncryptedDeviceToken string `json:"encryptedDeviceToken"`
	IPAddress            string `json:"ipAddress"`
}

type PublicKeys

type PublicKeys struct {
	RsaPublicKey *rsa.PublicKey
	EcPublicKey  *ecdh.PublicKey
}

type PushCallback

type PushCallback = func(*NotificationEvent) bool

type PushEndpoint

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

func (*PushEndpoint) Close

func (p *PushEndpoint) Close() error

func (*PushEndpoint) IsClosed

func (p *PushEndpoint) IsClosed() bool

func (*PushEndpoint) Push

func (p *PushEndpoint) Push(event *NotificationEvent)

func (*PushEndpoint) RegisterCallback

func (p *PushEndpoint) RegisterCallback(cb PushCallback)

func (*PushEndpoint) RemoveAllCallback

func (p *PushEndpoint) RemoveAllCallback()

func (*PushEndpoint) RemoveCallback

func (p *PushEndpoint) RemoveCallback(cb PushCallback)

func (*PushEndpoint) SendToPushChannel

func (p *PushEndpoint) SendToPushChannel(_ []byte, _ bool) error

type ServerConfiguration

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

func CloneServerConfiguration

func CloneServerConfiguration(other IServerConfiguration) *ServerConfiguration

func NewServerConfiguration

func NewServerConfiguration(server string) *ServerConfiguration

func (*ServerConfiguration) Id

func (s *ServerConfiguration) Id() string

func (*ServerConfiguration) Server

func (s *ServerConfiguration) Server() string

func (*ServerConfiguration) ServerKeyId

func (s *ServerConfiguration) ServerKeyId() int32

func (*ServerConfiguration) SetServerKeyId

func (s *ServerConfiguration) SetServerKeyId(keyId int32)

type SessionRestriction

type SessionRestriction int32

func (SessionRestriction) Has

func (r SessionRestriction) Has(restriction SessionRestriction) bool

type TwoFactorChannel

type TwoFactorChannel = int32
const (
	TwoFactorChannel_Other TwoFactorChannel = iota
	TwoFactorChannel_Authenticator
	TwoFactorChannel_TextMessage
	TwoFactorChannel_DuoSecurity
	TwoFactorChannel_RSASecurID
	TwoFactorChannel_KeeperDNA
	TwoFactorChannel_SecurityKey
	TwoFactorChannel_Backup
)

type TwoFactorDuration

type TwoFactorDuration = int32
const (
	TwoFactorDuration_EveryLogin TwoFactorDuration = iota
	TwoFactorDuration_Every12Hour
	TwoFactorDuration_EveryDay
	TwoFactorDuration_Every30Days
	TwoFactorDuration_Forever
)

type TwoFactorPushAction

type TwoFactorPushAction = int32
const (
	TwoFactorAction_DuoPush TwoFactorPushAction = iota + 1
	TwoFactorAction_DuoTextMessage
	TwoFactorAction_DuoVoiceCall
	TwoFactorAction_TextMessage
	TwoFactorAction_KeeperDna
)

type UserConfiguration

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

func CloneUserConfiguration

func CloneUserConfiguration(other IUserConfiguration) *UserConfiguration

func NewUserConfiguration

func NewUserConfiguration(username string) *UserConfiguration

func (*UserConfiguration) Id

func (u *UserConfiguration) Id() string

func (*UserConfiguration) LastDevice

func (*UserConfiguration) Password

func (u *UserConfiguration) Password() string

func (*UserConfiguration) Server

func (u *UserConfiguration) Server() string

func (*UserConfiguration) SetLastDevice

func (u *UserConfiguration) SetLastDevice(lastDevice IUserDeviceConfiguration)

func (*UserConfiguration) SetPassword

func (u *UserConfiguration) SetPassword(password string)

func (*UserConfiguration) SetServer

func (u *UserConfiguration) SetServer(server string)

func (*UserConfiguration) Username

func (u *UserConfiguration) Username() string

type UserDeviceConfiguration

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

func CloneUserDeviceConfiguration

func CloneUserDeviceConfiguration(other IUserDeviceConfiguration) *UserDeviceConfiguration

func NewUserDeviceConfiguration

func NewUserDeviceConfiguration(deviceToken string) *UserDeviceConfiguration

func (*UserDeviceConfiguration) DeviceToken

func (ud *UserDeviceConfiguration) DeviceToken() string

func (*UserDeviceConfiguration) Id

Jump to

Keyboard shortcuts

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