tpm

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthHeaderPublicKey        = "X-Public-Key"
	AuthHeaderRequestHash      = "X-Request-Hash"
	AuthHeaderRequestTimestamp = "X-Request-Timestamp"
)
View Source
const (
	DefaultApiVersion    = "v5"
	DefaultTLSSkipVerify = false
)
View Source
const (
	ShortDateTimeFormat = "2006-01-02"
	LongDateTimeFormat  = "2006-01-02 15:04:05"
)

Variables

View Source
var (
	ErrPasswordNameIsRequired = errors.New("password name is a required")
	ErrProjectIDIsRequired    = errors.New("project id is a required")
	ErrPasswordNotFound       = errors.New("the password does not exist or you cannot access it")
	ErrProjectNotFound        = errors.New("the project does not exist or you cannot access it")

	ErrProjectNameIsRequired = errors.New("project name is a required")
)

Functions

This section is empty.

Types

type ApiError

type ApiError struct {
	Type    string
	Message string
}

func (ApiError) Error

func (e ApiError) Error() string

type Client

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

func NewClient

func NewClient(c Config) Client

func (Client) CreateResource added in v0.5.0

func (c Client) CreateResource(
	endpoint string,
	requestBody any,
	response any,
) error

func (Client) DeleteResource added in v0.5.0

func (c Client) DeleteResource(endpoint string) error

func (Client) GetResource added in v0.5.0

func (c Client) GetResource(endpoint string, response any) error

func (Client) UpdateResource added in v0.5.0

func (c Client) UpdateResource(endpoint string, requestBody any) error

type Config

type Config struct {
	Host       string
	PublicKey  string
	PrivateKey string
	ApiVersion string
	TLSConfig  TLSConfig
}

type CreateGroupRequest added in v0.4.0

type CreateGroupRequest struct {
	Name string `json:"name"`
}

type CreateGroupResponse added in v0.4.0

type CreateGroupResponse struct {
	ID int `json:"id"`
}

type CreatePasswordRequest

type CreatePasswordRequest struct {
	Name         string    `json:"name,omitempty"`
	ProjectID    int       `json:"project_id"`
	Tags         Tags      `json:"tags"`
	AccessInfo   string    `json:"access_info"`
	Username     string    `json:"username"`
	Email        string    `json:"email"`
	Password     string    `json:"password"`
	ExpiryDate   ShortDate `json:"expiry_date"`
	Notes        string    `json:"notes"`
	CustomData1  string    `json:"custom_data1"`
	CustomData2  string    `json:"custom_data2"`
	CustomData3  string    `json:"custom_data3"`
	CustomData4  string    `json:"custom_data4"`
	CustomData5  string    `json:"custom_data5"`
	CustomData6  string    `json:"custom_data6"`
	CustomData7  string    `json:"custom_data7"`
	CustomData8  string    `json:"custom_data8"`
	CustomData9  string    `json:"custom_data9"`
	CustomData10 string    `json:"custom_data10"`
}

https://teampasswordmanager.com/docs/api-passwords#create_password

type CreatePasswordResponse

type CreatePasswordResponse struct {
	ID int `json:"id,omitempty"`
}

type CreateProjectRequest

type CreateProjectRequest struct {
	Name     string `json:"name,omitempty"`
	ParentID int    `json:"parent_id"`
	Tags     Tags   `json:"tags,omitempty"`
	Notes    string `json:"notes,omitempty"`
}

type CreateProjectResponse

type CreateProjectResponse struct {
	ID int `json:"id,omitempty"`
}

type CreateUserRequest added in v0.4.0

type CreateUserRequest struct {
	Username                string   `json:"username"`
	EmailAddress            string   `json:"email_address"`
	Name                    string   `json:"name"`
	Role                    UserRole `json:"role"`
	Password                string   `json:"password"`
	CanCreateProjectsInRoot bool     `json:"can_create_projects_in_root,omitempty"`
}

type CreateUserResponse added in v0.4.0

type CreateUserResponse struct {
	ID int `json:"id"`
}

type CustomField

type CustomField struct {
	Type  string `json:"type,omitempty"`
	Label string `json:"label,omitempty"`
	Data  string `json:"data,omitempty"`
}

type ErrorResponse

type ErrorResponse struct {
	Error   bool   `json:"error"`
	Type    string `json:"type"`
	Message string `json:"message"`
}

type ExpireStatus added in v0.4.0

type ExpireStatus int
const (
	NotExpired ExpireStatus = iota
	ExpiresToday
	Expired
	ExpiresSoon
)

func (ExpireStatus) String added in v0.4.0

func (i ExpireStatus) String() string

type GetGroupResponse added in v0.5.0

type GetGroupResponse struct {
	ID           int      `json:"id,omitempty"`
	Name         string   `json:"name,omitempty"`
	IsLdap       bool     `json:"is_ldap,omitempty"`
	LdapServerID int      `json:"ldap_server_id,omitempty"`
	GroupDn      string   `json:"group_dn,omitempty"`
	Users        []User   `json:"users,omitempty"`
	CreatedOn    LongDate `json:"created_on,omitempty"`
	CreatedBy    User     `json:"created_by,omitempty"`
	UpdatedOn    LongDate `json:"updated_on,omitempty"`
	UpdatedBy    User     `json:"updated_by,omitempty"`
}

type Group added in v0.4.0

type Group struct {
	ID   int    `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
}

type GroupClient added in v0.4.0

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

func NewGroupClient added in v0.4.0

func NewGroupClient(c Config) GroupClient

func (GroupClient) AddUserToGroup added in v0.5.0

func (c GroupClient) AddUserToGroup(groupID, userID int) error

func (GroupClient) Create added in v0.4.0

func (GroupClient) Delete added in v0.4.0

func (c GroupClient) Delete(ID int) error

func (GroupClient) DeleteUserFromGroup added in v0.5.0

func (c GroupClient) DeleteUserFromGroup(groupID, userID int) error

func (GroupClient) Get added in v0.5.0

func (c GroupClient) Get(ID int) (GetGroupResponse, error)

func (GroupClient) Update added in v0.5.0

func (c GroupClient) Update(ID int, request UpdateGroupRequest) error

type GroupPermission added in v0.4.0

type GroupPermission struct {
	Group      Group      `json:"groupt,omitempty"`
	Permission Permission `json:"permission,omitempty"`
}

type LockingRequestNotify added in v0.4.0

type LockingRequestNotify int
const (
	// TODO: Think how to handle clashing name issue with LockingRequestNotify
	PasswordNotLocked LockingRequestNotify = iota
	NotifyManager
	NotifyAll
)

func (LockingRequestNotify) String added in v0.4.0

func (i LockingRequestNotify) String() string

type LockingType added in v0.4.0

type LockingType int
const (
	NotLocked LockingType = iota
	RequiresReasonToUnlock
	RequiresPermissionToUnlock
)

func (LockingType) String added in v0.4.0

func (i LockingType) String() string

type LongDate added in v0.4.0

type LongDate time.Time

func (LongDate) MarshalJSON added in v0.4.0

func (d LongDate) MarshalJSON() ([]byte, error)

func (LongDate) String added in v0.4.0

func (d LongDate) String() string

func (*LongDate) UnmarshalJSON added in v0.4.0

func (d *LongDate) UnmarshalJSON(b []byte) (err error)

type Password

type Password struct {
	ID      int    `json:"id"`
	Name    string `json:"name"`
	Project struct {
		Name string `json:"name"`
	} `json:"project"`
}

type PasswordAccess added in v0.4.0

type PasswordAccess int
const (
	PasswordAccessNoAccess PasswordAccess = 0
	PasswordAccessRead     PasswordAccess = 10
	PasswordAccessEdit     PasswordAccess = 20
	PasswordAccessManage   PasswordAccess = 30
)

type PasswordClient

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

func NewPasswordClient

func NewPasswordClient(c Config) PasswordClient

func (PasswordClient) Create

func (c PasswordClient) Create(createPasswordRequest CreatePasswordRequest) (CreatePasswordResponse, error)

func (PasswordClient) Delete

func (c PasswordClient) Delete(passwordID int) error

func (PasswordClient) Find

func (c PasswordClient) Find(field string) ([]Password, error)

func (PasswordClient) Get

func (c PasswordClient) Get(passwordID int) (PasswordData, error)

func (PasswordClient) Update

func (c PasswordClient) Update(passwordID int, createPasswordRequest UpdatePasswordRequest) error

func (PasswordClient) UpdatePasswordSecurity added in v0.4.0

func (c PasswordClient) UpdatePasswordSecurity(
	passwordID int,
	updatePasswordSecurity UpdatePasswordSecurityRequest,
) error

type PasswordData

type PasswordData struct {
	ID      int    `json:"id,omitempty"`
	Name    string `json:"name,omitempty"`
	Project struct {
		Name string `json:"name,omitempty"`
		ID   int    `json:"id,omitempty"`
	} `json:"project,omitempty"`
	Tags         Tags         `json:"tags"`
	AccessInfo   string       `json:"access_info,omitempty"`
	Username     string       `json:"username,omitempty"`
	Email        string       `json:"email,omitempty"`
	Password     string       `json:"password,omitempty"`
	ExpiryDate   ShortDate    `json:"expiry_date,omitempty"`
	ExpiryStatus ExpireStatus `json:"expiry_status,omitempty"`
	Notes        string       `json:"notes,omitempty"`

	CustomField1  *CustomField `json:"custom_field1,omitempty"`
	CustomField2  *CustomField `json:"custom_field2,omitempty"`
	CustomField3  *CustomField `json:"custom_field3,omitempty"`
	CustomField4  *CustomField `json:"custom_field4,omitempty"`
	CustomField5  *CustomField `json:"custom_field5,omitempty"`
	CustomField6  *CustomField `json:"custom_field6,omitempty"`
	CustomField7  *CustomField `json:"custom_field7,omitempty"`
	CustomField8  *CustomField `json:"custom_field8,omitempty"`
	CustomField9  *CustomField `json:"custom_field9,omitempty"`
	CustomField10 *CustomField `json:"custom_field10,omitempty"`

	UsersPermissions     []UserPermission     `json:"users_permissions,omitempty"`
	GroupsPermissions    []GroupPermission    `json:"groups_permissions,omitempty"`
	Parents              []int                `json:"parents,omitempty"`
	UserPermission       Permission           `json:"user_permission,omitempty"`
	Archived             bool                 `json:"archived,omitempty"`
	ProjectArchived      bool                 `json:"project_archived,omitempty"`
	Favorite             bool                 `json:"favorite,omitempty"`
	NumberOfFiles        int                  `json:"num_files,omitempty"`
	Locked               bool                 `json:"locked,omitempty"`
	LockingType          LockingType          `json:"locking_type,omitempty"`
	LockingRequestNotify LockingRequestNotify `json:"locking_request_notify,omitempty"`
	ExternalSharing      bool                 `json:"external_sharing,omitempty"`
	ExternalURL          string               `json:"external_url,omitempty"`
	Linked               bool                 `json:"linked,omitempty"`
	SourcePasswordID     int                  `json:"source_password_id,omitempty"`
	ManagedBy            User                 `json:"managed_by,omitempty"`
	CreatedOn            LongDate             `json:"created_on,omitempty"`
	CreatedBy            User                 `json:"created_by,omitempty"`
	UpdatedOn            LongDate             `json:"updated_on,omitempty"`
	UpdatedBy            User                 `json:"updated_by,omitempty"`
}

https://teampasswordmanager.com/docs/api-passwords/#show_password

type PasswordPermission added in v0.4.0

type PasswordPermission [2]int

func NewPasswordPermission added in v0.4.0

func NewPasswordPermission(ID int, access PasswordAccess) PasswordPermission

type Permission added in v0.4.0

type Permission struct {
	ID    int    `json:"id,omitempty"`
	Label string `json:"label,omitempty"`
}

type ProjectClient

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

func NewProjectClient

func NewProjectClient(c Config) ProjectClient

func (ProjectClient) Create

func (ProjectClient) Delete

func (c ProjectClient) Delete(ID int) error

func (ProjectClient) Get

func (c ProjectClient) Get(ID int) (ProjectData, error)

func (ProjectClient) Update

func (c ProjectClient) Update(ID int, r UpdateProjectRequest) error

type ProjectData

type ProjectData struct {
	ID       int    `json:"id,omitempty"`
	Name     string `json:"name,omitempty"`
	ParentID int    `json:"parent_id,omitempty"`
	Tags     Tags   `json:"tags,omitempty"`
	Notes    string `json:"notes,omitempty"`
}

type ShortDate added in v0.4.0

type ShortDate time.Time

func (ShortDate) MarshalJSON added in v0.4.0

func (d ShortDate) MarshalJSON() ([]byte, error)

func (ShortDate) String added in v0.4.0

func (d ShortDate) String() string

func (*ShortDate) UnmarshalJSON added in v0.4.0

func (d *ShortDate) UnmarshalJSON(b []byte) (err error)

type TLSConfig added in v0.6.0

type TLSConfig struct {
	SkipVerify bool
}

type Tags

type Tags []string

func (Tags) MarshalJSON

func (t Tags) MarshalJSON() ([]byte, error)

func (Tags) ToString

func (t Tags) ToString() string

func (*Tags) UnmarshalJSON

func (t *Tags) UnmarshalJSON(data []byte) error

type UpdateGroupRequest added in v0.5.0

type UpdateGroupRequest struct {
	Name string `json:"name"`
}

type UpdatePasswordRequest

type UpdatePasswordRequest struct {
	Name         string    `json:"name"`
	Tags         Tags      `json:"tags"`
	AccessInfo   string    `json:"access_info"`
	Username     string    `json:"username,"`
	Email        string    `json:"email,"`
	Password     string    `json:"password"`
	ExpiryDate   ShortDate `json:"expiry_date"`
	Notes        string    `json:"notes"`
	CustomData1  string    `json:"custom_data1"`
	CustomData2  string    `json:"custom_data2"`
	CustomData3  string    `json:"custom_data3"`
	CustomData4  string    `json:"custom_data4"`
	CustomData5  string    `json:"custom_data5"`
	CustomData6  string    `json:"custom_data6"`
	CustomData7  string    `json:"custom_data7"`
	CustomData8  string    `json:"custom_data8"`
	CustomData9  string    `json:"custom_data9"`
	CustomData10 string    `json:"custom_data10"`
}

https://teampasswordmanager.com/docs/api-passwords#update_password

type UpdatePasswordSecurityRequest added in v0.4.0

type UpdatePasswordSecurityRequest struct {
	ManagedBy         int                  `json:"managed_by,omitempty"`
	UsersPermissions  []PasswordPermission `json:"users_permissions"`
	GroupsPermissions []PasswordPermission `json:"groups_permissions"`
}

type UpdateProjectRequest

type UpdateProjectRequest struct {
	Name  string `json:"name,omitempty"`
	Tags  Tags   `json:"tags"`
	Notes string `json:"notes"`
}

type User added in v0.4.0

type User struct {
	ID       int    `json:"id,omitempty"`
	Username string `json:"username,omitempty"`
	Email    string `json:"email_address,omitempty"`
	Name     string `json:"name,omitempty"`
	Role     string `json:"Role,omitempty"`
}

type UserClient added in v0.4.0

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

func NewUserClient added in v0.4.0

func NewUserClient(c Config) UserClient

func (UserClient) Create added in v0.4.0

func (UserClient) Delete added in v0.4.0

func (c UserClient) Delete(ID int) error

type UserPermission added in v0.4.0

type UserPermission struct {
	User       User       `json:"user,omitempty"`
	Permission Permission `json:"permission,omitempty"`
}

type UserRole added in v0.4.0

type UserRole string
const (
	// UserRoleAdmin role owners can do anything.
	UserRoleAdmin UserRole = "admin"
	// UserRoleProjectManager role owners are like normal users and also create/delete projects.
	UserRoleProjectManager UserRole = "project manager"
	// UserRoleNormalUser role owners work with passwords and projects, but not create/delete projects.
	UserRoleNormalUser UserRole = "normal user"
	// UserRoleReadOnly role owners only read passwords on assigned projects.
	UserRoleReadOnly UserRole = "read only"
	// UserRoleReadOnly role owners like a project manager plus access to Users/Groups, Log and Settings. read passwords on assigned projects.
	UserRoleIT UserRole = "it"
)

Jump to

Keyboard shortcuts

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