Documentation
¶
Index ¶
- Variables
- func EncryptReplicationDataForTransport(data ReplicationData) (encrypted string, err error)
- func GetAccessGormDB(database string) (db *gorm.DB, err error)
- func GetAllSBGroups() (groups map[string]*Group, err error)
- func GetAllSBUsers() (users []string, err error)
- func GetLastSSHSessions(database string, limit int) (sessions []*helpers.SSHSession, err error)
- func GetReplicationGormDB(database string) (db *gorm.DB, err error)
- func IsAValidSBAccessFromUserInput(access string) bool
- type Access
- func BuildSBAccess(host, user, port, alias string, strictHostCheck bool) (ba *Access, err error)
- func BuildSBAccessFromUserInput(access string) (ba *Access, err error)
- func GetAllAccesses(db *gorm.DB) (accesses []*Access, err error)
- func LoadSBAccess(host, user, port string, db *gorm.DB) (ba *Access, err error)
- type AccessesByKeys
- type Group
- func (bg *Group) AddAccess(host, user, port, alias, comment string, db ...*gorm.DB) (ba *Access, err error)
- func (bg *Group) DeleteAccess(host, user, port string, db ...*gorm.DB) (ba *Access, err error)
- func (bg *Group) DisplayPubKeys(keyType string) (str string, keys []helpers.PublicKey, err error)
- func (bg *Group) GetAccesses(db ...*gorm.DB) (accesses *AccessesByKeys, err error)
- func (bg *Group) GetMembers(memberType string) (members []string, err error)
- func (bg *Group) GetSSHKeyPairs() (kp []*helpers.SSHKeyPair, err error)
- func (bg *Group) OverrideDatabaseAccessFilePath(path string)
- func (bg *Group) OverrideKeyFilesRootDir(path string)
- type Info
- type Log
- type Replication
- type ReplicationData
- type Right
- type Source
- type User
- func (bu *User) AddAccess(host, user, port, alias, comment string, db ...*gorm.DB) (ba *Access, err error)
- func (bu *User) AddIngressKey(publicKey string) (err error)
- func (bu *User) BuildGroupsMembership(groupNames []string)
- func (bu *User) DeleteAccess(host, user, port string, db ...*gorm.DB) (ba *Access, err error)
- func (bu *User) DeletePubKey(keyType string, pk helpers.PublicKey) (err error)
- func (bu *User) DisplayPubKeys(keyType string) (str string, keys []helpers.PublicKey, err error)
- func (bu *User) GetAccesses(db ...*gorm.DB) (accesses []*AccessesByKeys, err error)
- func (bu *User) GetAllGroups() (map[string]*Group, error)
- func (bu *User) GetKnownHostsFilepath() string
- func (bu *User) GetLastSSHSessions(limit int) ([]*helpers.SSHSession, error)
- func (bu *User) GetLocalLogDatabasePath() string
- func (bu *User) GetSSHKeyPairs() (kp []*helpers.SSHKeyPair, err error)
- func (bu *User) GetSelfAccesses(db ...*gorm.DB) (accesses *AccessesByKeys, err error)
- func (bu *User) GetTOTP() (enabled bool, secret string, emergencyPasswords []string)
- func (bu *User) GetTOTPFilepath() string
- func (bu *User) GetTtyrecDirectory() string
- func (bu *User) HasAccess(ba *Access, db ...*gorm.DB) (accessInfo *Info, err error)
- func (bu *User) IsACLKeeperOfGroup(groupName string) bool
- func (bu *User) IsGateKeeperOfGroup(groupName string) bool
- func (bu *User) IsMemberOfGroup(groupName string) bool
- func (bu *User) IsOwnerOfGroup(groupName string) bool
- func (bu *User) OverrideAuthorizedKeysFilePath(path string) error
- func (bu *User) OverrideDatabaseAccessFilePath(path string) error
- func (bu *User) RemoveTOTPSecret() (err error)
- func (bu *User) SetTOTPSecret(secret string, emergencyCodes []string) error
- func (bu *User) ShortString() string
Constants ¶
This section is empty.
Variables ¶
var SBGroupNameRegexp = regexp.MustCompile(`^bg_([^-]*)(-(.*))?$`)
SBGroupNameRegexp represents the regex that matches a sb group
Functions ¶
func EncryptReplicationDataForTransport ¶
func EncryptReplicationDataForTransport(data ReplicationData) (encrypted string, err error)
func GetAccessGormDB ¶
GetAccessGormDB returns a DB handler
func GetAllSBGroups ¶
GetAllSBGroups lists all sb groups. Results can be provided with optional user's right and can be filtered on group's name
func GetAllSBUsers ¶
GetAllSBUsers returns all sb users
func GetLastSSHSessions ¶
func GetLastSSHSessions(database string, limit int) (sessions []*helpers.SSHSession, err error)
GetLastSSHSessions returns the last SSH sessions
func GetReplicationGormDB ¶
GetReplicationGormDB returns a DB handler
func IsAValidSBAccessFromUserInput ¶
IsAValidSBAccessFromUserInput checks if the provided argument is of the form 'user@host[:port]' (or pretty much anything in case of an alias)
Types ¶
type Access ¶
type Access struct { UniqID string `gorm:"PRIMARY_KEY"` Host string `gorm:"type:varchar(100);unique_index:host_user_prefix_port"` Prefix string `gorm:"type:varchar(50);unique_index:host_user_prefix_port"` Alias string `gorm:"type:varchar(100);unique_index:host_user_prefix_port"` User string `gorm:"type:varchar(50);unique_index:host_user_prefix_port"` Port int `gorm:"type:varchar(5);unique_index:host_user_prefix_port"` Comment string `gorm:"type:text"` IP net.IP `gorm:"-"` }
Access descibes the basic properties of this struct
func BuildSBAccess ¶
BuildSBAccess builds a new sb access to be stored It will resolve DNS on host and store prefix
func BuildSBAccessFromUserInput ¶
BuildSBAccessFromUserInput deserializes a 'user@host:port' string into a SBAccess struct
func GetAllAccesses ¶
GetAllAccesses returns all access in the database
func LoadSBAccess ¶
LoadSBAccess loads a sb access stored in database from user input
func (*Access) BeforeCreate ¶
BeforeCreate will set a UUID if not present
func (*Access) Equals ¶
Equals compares the properties of two accesses to determine if they're the same access
func (*Access) ShortString ¶
ShortString returns a pretty print short display of the access
type AccessesByKeys ¶
type AccessesByKeys struct { Keys []*helpers.SSHKeyPair Accesses []*Access Type string Group string }
AccessesByKeys describes the basic properties of the struct
type Group ¶
type Group struct { Name string SystemName string ACLKeeper bool GateKeeper bool Member bool Owner bool OverriddenDatabaseAccessFilePath string OverriddenKeyFilesRootDir string }
Group describes the basic properties of a sb group
func (*Group) AddAccess ¶
func (bg *Group) AddAccess(host, user, port, alias, comment string, db ...*gorm.DB) (ba *Access, err error)
AddAccess adds an access to the group
func (*Group) DeleteAccess ¶
DeleteAccess deletes an access from the group
func (*Group) DisplayPubKeys ¶
DisplayPubKeys pretty displays the public key
func (*Group) GetAccesses ¶
func (bg *Group) GetAccesses(db ...*gorm.DB) (accesses *AccessesByKeys, err error)
GetAccesses returns the list of group's authorized accesses
func (*Group) GetMembers ¶
GetMembers pretty displays the members of a group
func (*Group) GetSSHKeyPairs ¶
func (bg *Group) GetSSHKeyPairs() (kp []*helpers.SSHKeyPair, err error)
GetSSHKeyPairs returns all the egress SSH key pairs of the user
func (*Group) OverrideDatabaseAccessFilePath ¶
OverrideDatabaseAccessFilePath allows to override the database access file path of the group (mainly for tests purposes)
func (*Group) OverrideKeyFilesRootDir ¶
OverrideKeyFilesRootDir allows to override the the keypairs file path of the group (mainly for tests purposes)
type Log ¶
type Log struct { UniqID string `gorm:"PRIMARY_KEY"` // PK: uniq log ID (corresponding to the ttyrec filename) LocalUsername string `gorm:"type:varchar(50)"` // The local user iniating the SSH session Arguments string `gorm:"type:text"` // The arguments passed to SSH SessionStartDate time.Time `gorm:"type:datetime"` // Session start time SessionEndDate time.Time `gorm:"type:datetime"` // Session end time IPFrom string `gorm:"type:varchar(45)"` // The IP the connection is issued from PortFrom string `gorm:"type:varchar(5)"` // The port the connection is issued from HostFrom string `gorm:"type:varchar(100)"` // The host the connection is issued from BastionIP string `gorm:"type:varchar(45)"` // A bit about myself: my IP BastionPort string `gorm:"type:varchar(5)"` // A bit about myself: my port BastionHost string `gorm:"type:varchar(100)"` // A bit about myself: my host Command string `gorm:"type:text"` // The command that was executed by this piece of software Comment string `gorm:"type:text"` // A comment, because why not? HostTo string `gorm:"type:varchar(100)"` // The host the user wanted to connect to PortTo string `gorm:"type:varchar(5)"` // The port the user wanted to connect to UserTo string `gorm:"type:varchar(100)"` // The user to connect to the distant host Allowed bool `gorm:"type:varchar(1)"` // Did we allow the connection? // Ignored helpers: not saved to database Databases []string `gorm:"-"` }
Log describes the basic properties of a log
func (*Log) PushReplication ¶
func (*Log) SetAllowed ¶
SetAllowed sets whether or not the command was allowed by sb in the log and saves it
func (*Log) SetCommand ¶
SetCommand sets the command that was executed by sb in the log and saves it
func (*Log) SetTargetAccess ¶
SetTargetAccess sets the target access information in the log and saves it
type Replication ¶
type Replication struct { UniqID string `gorm:"PRIMARY_KEY"` CreationDate time.Time `gorm:"autoCreateTime"` Instance string Action string Data string }
func GetNextReplicationEntryToPush ¶
func GetNextReplicationEntryToPush(db *gorm.DB) (entry Replication, err error)
func NewReplicationEntry ¶
func NewReplicationEntry(action string, data ReplicationData) (repl *Replication, err error)
func (*Replication) BeforeCreate ¶
func (r *Replication) BeforeCreate(tx *gorm.DB) (err error)
type ReplicationData ¶
func DecryptReplicationData ¶
func DecryptReplicationData(encryptedPayload string) (data ReplicationData, err error)
type User ¶
type User struct { User *osuser.User Groups map[string]*Group OverriddenDatabaseAccessFilePath string OverriddenAuthorizedKeysFilePath string }
User descibes the basic properties of a sb user
func LoadCurrentUser ¶
LoadCurrentUser loads the current user into a sbuser object by calling the LoadUser method
func (*User) AddAccess ¶
func (bu *User) AddAccess(host, user, port, alias, comment string, db ...*gorm.DB) (ba *Access, err error)
AddAccess adds an access to the group
func (*User) AddIngressKey ¶
AddIngressKey adds an ingress key to authorized_keys file
func (*User) BuildGroupsMembership ¶
BuildGroupsMembership builds the user's membership based on the groups that were given in input
func (*User) DeleteAccess ¶
DeleteAccess deletes an access from the personal access database
func (*User) DeletePubKey ¶
DeletePubKey deletes a key
func (*User) DisplayPubKeys ¶
DisplayPubKeys pretty displays the public key
func (*User) GetAccesses ¶
func (bu *User) GetAccesses(db ...*gorm.DB) (accesses []*AccessesByKeys, err error)
GetAccesses returns the list of user's authorized accesses
func (*User) GetAllGroups ¶
GetAllGroups returns all user's groups
func (*User) GetKnownHostsFilepath ¶
GetKnownHostsFilepath returns the user's known_hosts file path
func (*User) GetLastSSHSessions ¶
func (bu *User) GetLastSSHSessions(limit int) ([]*helpers.SSHSession, error)
GetLastSSHSessions returns the user last SSH sessions
func (*User) GetLocalLogDatabasePath ¶
GetLocalLogDatabasePath returns the path of the user private database
func (*User) GetSSHKeyPairs ¶
func (bu *User) GetSSHKeyPairs() (kp []*helpers.SSHKeyPair, err error)
GetSSHKeyPairs returns all the egress SSH key pairs of the user
func (*User) GetSelfAccesses ¶
func (bu *User) GetSelfAccesses(db ...*gorm.DB) (accesses *AccessesByKeys, err error)
GetSelfAccesses returns the list of user's authorized accesses
func (*User) GetTOTPFilepath ¶
GetTOTPFilepath returns the user's TOTP file path
func (*User) GetTtyrecDirectory ¶
GetTtyrecDirectory returns the user's ttyrecs directory
func (*User) HasAccess ¶
HasAccess returns a boolean value of whether or not the user can access the specified access with the specified user
func (*User) IsACLKeeperOfGroup ¶
IsACLKeeperOfGroup checks if the user is member of the group passed as parameter
func (*User) IsGateKeeperOfGroup ¶
IsGateKeeperOfGroup checks if the user is member of the group passed as parameter
func (*User) IsMemberOfGroup ¶
IsMemberOfGroup checks if the user is member of the group passed as parameter
func (*User) IsOwnerOfGroup ¶
IsOwnerOfGroup checks if the user is member of the group passed as parameter
func (*User) OverrideAuthorizedKeysFilePath ¶
OverrideAuthorizedKeysFilePath allows to override the authorized_keys file path of the user (mainly for tests purposes)
func (*User) OverrideDatabaseAccessFilePath ¶
OverrideDatabaseAccessFilePath allows to override the database access file path of the user (mainly for tests purposes)
func (*User) RemoveTOTPSecret ¶
RemoveTOTPSecret disables TOTP on the account
func (*User) SetTOTPSecret ¶
SetTOTPSecret sets TOTP on the current account
func (*User) ShortString ¶
ShortString returns a pretty print short display of the user