helper

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2024 License: MIT Imports: 17 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddMFACallbackTOTP

func AddMFACallbackTOTP(c *api.Client, retrys uint, retryDelay, offset time.Duration, token string)

AddMFACallbackTOTP adds a MFA callback to the client that generates OTP Codes on demand using a Token with configurable retries and delay

func CreateFolder

func CreateFolder(ctx context.Context, c *api.Client, folderParentID, name string) (string, error)

CreateFolder Creates a new Folder

func CreateGroup

func CreateGroup(ctx context.Context, c *api.Client, name string, operations []GroupMembershipOperation) (string, error)

CreateGroup creates a Groups with Name and Memberships

func CreateResource

func CreateResource(ctx context.Context, c *api.Client, folderParentID, name, username, uri, password, description string) (string, error)

CreateResource Creates a Resource where the Password and Description are Encrypted and Returns the Resources ID

func CreateResourceSimple

func CreateResourceSimple(ctx context.Context, c *api.Client, folderParentID, name, username, uri, password, description string) (string, error)

CreateResourceSimple Creates a Legacy Resource where only the Password is Encrypted and Returns the Resources ID

func CreateUser

func CreateUser(ctx context.Context, c *api.Client, role, username, firstname, lastname string) (string, error)

CreateUser Creates a new User

func DeleteFolder

func DeleteFolder(ctx context.Context, c *api.Client, folderID string) error

DeleteFolder Deletes a Folder

func DeleteGroup

func DeleteGroup(ctx context.Context, c *api.Client, groupID string) error

DeleteGroup Deletes a Group

func DeleteResource

func DeleteResource(ctx context.Context, c *api.Client, resourceID string) error

DeleteResource Deletes a Resource

func DeleteUser

func DeleteUser(ctx context.Context, c *api.Client, userID string) error

DeleteUser Deletes a User

func GenerateOTPCode

func GenerateOTPCode(token string, when time.Time) (string, error)

GenerateOTPCode generates a 6 digit TOTP from the secret Token.

func GeneratePermissionChanges

func GeneratePermissionChanges(oldPermissions []api.Permission, changes []ShareOperation) ([]api.Permission, error)

GeneratePermissionChanges Generates the Permission Changes for a Resource/Folder nessesary for a single Share Operation

func GetFolder

func GetFolder(ctx context.Context, c *api.Client, folderID string) (string, string, error)

GetFolder Gets a Folder

func GetResource

func GetResource(ctx context.Context, c *api.Client, resourceID string) (folderParentID, name, username, uri, password, description string, err error)

GetResource Gets a Resource by ID

func GetResourceFromData

func GetResourceFromData(c *api.Client, resource api.Resource, secret api.Secret, rType api.ResourceType) (folderParentID, name, username, uri, password, description string, err error)

GetResourceFromData Decrypts Resources using only local data, the Resource object must inlude the secret

func GetUser

func GetUser(ctx context.Context, c *api.Client, userID string) (string, string, string, string, error)

GetUser Gets a User

func MoveFolder

func MoveFolder(ctx context.Context, c *api.Client, folderID, folderParentID string) error

MoveFolder Moves a Folder into a Folder

func MoveResource

func MoveResource(ctx context.Context, c *api.Client, resourceID, folderParentID string) error

MoveResource Moves a Resource into a Folder

func ParseInviteUrl

func ParseInviteUrl(url string) (string, string, error)

ParseInviteUrl Parses a Passbolt Invite URL into a user id and token

func SetupAccount

func SetupAccount(ctx context.Context, c *api.Client, userID, token, password string) (string, error)

SetupAccount Setup a Account for a Invited User. (Use ParseInviteUrl to get the userid and token from a Invite URL)

func ShareFolder

func ShareFolder(ctx context.Context, c *api.Client, folderID string, changes []ShareOperation) error

ShareFolder Shares a Folder as Specified in the Passed ShareOperation Struct Slice. Note Resources Permissions in the Folder are not Adjusted

func ShareFolderWithUsersAndGroups

func ShareFolderWithUsersAndGroups(ctx context.Context, c *api.Client, folderID string, Users []string, Groups []string, permissionType int) error

ShareFolderWithUsersAndGroups Shares a Folder With The Users and Groups with the Specified Type, if the Folder has already been shared With the User/Group the Permission Type will be Adjusted/Deleted. Note: Resources Permissions in the Folder are not Adjusted (Like the Extension does)

func ShareResource

func ShareResource(ctx context.Context, c *api.Client, resourceID string, changes []ShareOperation) error

ShareResource Shares a Resource as Specified in the Passed ShareOperation Struct Slice

func ShareResourceWithUsersAndGroups

func ShareResourceWithUsersAndGroups(ctx context.Context, c *api.Client, resourceID string, Users []string, Groups []string, permissionType int) error

ShareResourceWithUsersAndGroups Shares a Resource With The Users and Groups with the Specified Permission Type, if the Resource has already been shared With the User/Group the Permission Type will be Adjusted/Deleted

func UpdateFolder

func UpdateFolder(ctx context.Context, c *api.Client, folderID, name string) error

UpdateFolder Updates a Folder

func UpdateGroup

func UpdateGroup(ctx context.Context, c *api.Client, groupID, name string, operations []GroupMembershipOperation) error

UpdateGroup Updates a Groups Name and Memberships

func UpdateResource

func UpdateResource(ctx context.Context, c *api.Client, resourceID, name, username, uri, password, description string) error

UpdateResource Updates all Fields. Note if you want to Change the FolderParentID please use the MoveResource Function

func UpdateUser

func UpdateUser(ctx context.Context, c *api.Client, userID, role, firstname, lastname string) error

UpdateUser Updates a User

Types

type GroupMembership

type GroupMembership struct {
	UserID         string
	Username       string
	UserFirstName  string
	UserLastName   string
	IsGroupManager bool
}

GroupMembership contains who and what kind of membership they have with a group

func GetGroup

func GetGroup(ctx context.Context, c *api.Client, groupID string) (string, []GroupMembership, error)

GetGroup gets a Groups Name and Memberships

type GroupMembershipOperation

type GroupMembershipOperation struct {
	UserID         string
	IsGroupManager bool
	Delete         bool
}

GroupMembershipOperation creates/modifies/deletes a group membership

type ShareOperation

type ShareOperation struct {
	// Type of Permission: 1 = Read, 7 = can Update, 15 = Owner (Owner can also Share Resource)
	// Note: Setting this to -1 Will delete this Permission if it already Exists, errors if this Permission Dosen't Already Exists
	Type int
	// ARO is what Type this should be Shared With (User, Group)
	ARO string
	// AROID is the ID of the User or Group(ARO) this should be Shared With
	AROID string
}

ShareOperation defines how Resources are to be Shared With Users/Groups

Jump to

Keyboard shortcuts

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