accountslib

package module
v0.0.0-...-eb9ffb9 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2024 License: MIT Imports: 15 Imported by: 0

README

ge-accountslib

Documentation

Overview

ge-accounts/pkg/clientlib/accountslib/activation.go

ge-accounts/pkg/clientlib/accountslib/client.go

ge-accounts/pkg/clientlib/accountslib/user_metadata.go

ge-accounts/pkg/clientlib/accountslib/metadata_keys.go

ge-accounts/pkg/clientlib/accountslib/password-reset.go

ge-accounts/pkg/clientlib/accountslib/permissions.go

ge-accounts/pkg/clientlib/accountslib/roles.go

ge-accounts/pkg/clientlib/accountslib/sanctioned_countries.go

ge-accounts/pkg/clientlib/accountslib/service_accounts.go

ge-accounts/pkg/clientlib/accountslib/tokens.go

ge-accounts/pkg/clientlib/accountslib/users.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActivateUserInput

type ActivateUserInput struct {
	Token string `json:"token"`
}

ActivateUserInput represents the input required to activate a user

type ActivationToken

type ActivationToken struct {
	Token  string    `json:"token"`
	UserID uuid.UUID `json:"user_id"`
	Expiry string    `json:"expiry"`
}

ActivationToken represents an activation token record in the database

type AddSanctionedCountryInput

type AddSanctionedCountryInput struct {
	CountryCode string
	CountryName string
}

type AssignPermissionToRoleEvent

type AssignPermissionToRoleEvent struct {
	RoleID       uuid.UUID `json:"role_id"`
	PermissionID uuid.UUID `json:"permission_id"`
}

type AssignPermissionToRoleInput

type AssignPermissionToRoleInput struct {
	RoleID       uuid.UUID
	PermissionID uuid.UUID
}

func (*AssignPermissionToRoleInput) Validate

func (input *AssignPermissionToRoleInput) Validate() error

You would also need to define the Validate method for AssignPermissionToRoleEvent

type AssignRoleData

type AssignRoleData struct {
	UserID uuid.UUID `json:"user_id"`
	RoleID uuid.UUID `json:"role_id"`
}

AssignRoleData represents the input data to assign a role to a user.

func (*AssignRoleData) Validate

func (d *AssignRoleData) Validate() error

Validate checks if the AssignRoleData structure is valid.

type AssignRoleInput

type AssignRoleInput struct {
	ServiceAccountID uuid.UUID `json:"service_account_id"`
	RoleID           uuid.UUID `json:"role_id"`
}

AssignRoleInput represents the input data for assigning a role to a service account.

type CheckPasswordHashData

type CheckPasswordHashData struct {
	UserID   uuid.UUID `json:"userId"`
	Password string    `json:"password"`
}

func (*CheckPasswordHashData) Validate

func (d *CheckPasswordHashData) Validate() error

type CheckUserAuthorizationError

type CheckUserAuthorizationError struct {
	BaseError  error
	StatusCode int
}

This is a custom error type

func (*CheckUserAuthorizationError) Error

type Client

type Client struct {
	BaseURL    string
	HttpClient *http.Client
	Token      string
	ApiKey     string
}

Client represents an HTTP client that interacts with the API.

func NewClient

func NewClient(baseURL string, token string, apiKey string, httpClient ...*http.Client) *Client

NewClient initializes and returns a new Client.

func (*Client) ActivateUser

func (c *Client) ActivateUser(ctx context.Context, input ActivateUserInput) error

ActivateUser sends a request to activate a user with the given token

func (*Client) AddSanctionedCountry

func (c *Client) AddSanctionedCountry(input AddSanctionedCountryInput) error

func (*Client) AssignPermissionToRole

func (c *Client) AssignPermissionToRole(input AssignPermissionToRoleInput) error

func (*Client) AssignRoleToServiceAccount

func (c *Client) AssignRoleToServiceAccount(input AssignRoleInput) error

func (*Client) AssignRoleToUser

func (c *Client) AssignRoleToUser(data *AssignRoleData) error

AssignRoleToUser assigns a role to a user

func (*Client) CheckPasswordHash

func (c *Client) CheckPasswordHash(data *CheckPasswordHashData) (bool, error)

func (*Client) CheckUserAuthorization

func (c *Client) CheckUserAuthorization(ctx context.Context, token, permission string) (bool, error)

CheckUserAuthorization verifies a user's authorization to perform a certain action.

func (*Client) CreateActivationToken

func (c *Client) CreateActivationToken(ctx context.Context, input CreateActivationTokenInput) (*ActivationToken, error)

func (*Client) CreateMetadataKey

func (c *Client) CreateMetadataKey(input CreateMetadataKeyInput) (*MetadataKey, error)

func (*Client) CreatePasswordResetToken

func (c *Client) CreatePasswordResetToken(ctx context.Context, input CreatePasswordResetTokenInput) (*PasswordResetToken, error)

CreatePasswordResetToken creates a password reset token for the user.

func (*Client) CreatePermission

func (c *Client) CreatePermission(input CreatePermissionInput) (*Permission, error)

func (*Client) CreateRole

func (c *Client) CreateRole(input *CreateRoleInput) (*Role, error)

func (*Client) CreateToken

func (c *Client) CreateToken(input CreateTokenInput) (*Token, error)

CreateToken creates a new token for a user and returns it.

func (*Client) CreateUser

func (c *Client) CreateUser(data *User) error

func (*Client) CreateUserMetadata

func (c *Client) CreateUserMetadata(metadata *UserMetadata) error

func (*Client) DeleteActivationToken

func (c *Client) DeleteActivationToken(ctx context.Context, input DeleteActivationTokenInput) error

func (*Client) DeleteActivationTokenByUserID

func (c *Client) DeleteActivationTokenByUserID(ctx context.Context, input DeleteActivationTokenByUserIDInput) error

func (*Client) DeleteExpiredActivationTokens

func (c *Client) DeleteExpiredActivationTokens(ctx context.Context) error

DeleteExpiredActivationTokens deletes expired activation tokens

func (*Client) DeleteExpiredPasswordResetTokens

func (c *Client) DeleteExpiredPasswordResetTokens(ctx context.Context, input DeleteExpiredPasswordResetTokensInput) error

DeleteExpiredPasswordResetTokens deletes expired password reset tokens

func (*Client) DeleteExpiredTokens

func (c *Client) DeleteExpiredTokens() error

func (*Client) DeleteMetadataKey

func (c *Client) DeleteMetadataKey(input DeleteMetadataKeyInput) error

DeleteMetadataKey deletes a metadata key by its id.

func (*Client) DeletePasswordResetToken

func (c *Client) DeletePasswordResetToken(ctx context.Context, input DeletePasswordResetTokenInput) error

DeletePasswordResetToken deletes a password reset token

func (*Client) DeletePasswordResetTokenByUserID

func (c *Client) DeletePasswordResetTokenByUserID(ctx context.Context, input DeletePasswordResetTokenByUserIDInput) error

DeletePasswordResetTokenByUserID deletes password reset tokens for a specific user ID

func (*Client) DeletePermission

func (c *Client) DeletePermission(input DeletePermissionInput) error

func (*Client) DeleteRole

func (c *Client) DeleteRole(input *DeleteRoleInput) error

DeleteRole deletes a role using the API.

func (*Client) DeleteServiceAccount

func (c *Client) DeleteServiceAccount(serviceAccountID uuid.UUID) error

DeleteServiceAccount deletes a service account by its ID

func (*Client) DeleteToken

func (c *Client) DeleteToken(input DeleteTokenInput) error

DeleteToken deletes a token associated with a user.

func (*Client) DeleteTokensByUserID

func (c *Client) DeleteTokensByUserID(input DeleteTokensByUserIDInput) error

DeleteTokensByUserID sends a request to the server to delete all tokens for the given user ID.

func (*Client) DeleteUser

func (c *Client) DeleteUser(userID uuid.UUID) error

func (*Client) DeleteUserMetadataByID

func (c *Client) DeleteUserMetadataByID(id uuid.UUID) error

DeleteUserMetadataByID deletes user metadata by its ID.

func (*Client) DeleteUserMetadataByKey

func (c *Client) DeleteUserMetadataByKey(userID uuid.UUID, key string) error

func (*Client) DeleteUserMetadataByUserID

func (c *Client) DeleteUserMetadataByUserID(userID uuid.UUID) error

func (*Client) DisableTwoFactorAuthentication

func (c *Client) DisableTwoFactorAuthentication(data DisableTwoFactorAuthenticationInput) error

func (*Client) DoesPermissionExist

func (c *Client) DoesPermissionExist(input *DoesPermissionExistInput) (bool, error)

func (*Client) DoesRoleExist

func (c *Client) DoesRoleExist(input DoesRoleExistInput) (bool, error)

func (*Client) EnableTwoFactorAuthentication

func (c *Client) EnableTwoFactorAuthentication(data EnableTwoFactorAuthenticationInput) error

func (*Client) GetActivationTokenByPlaintext

func (c *Client) GetActivationTokenByPlaintext(ctx context.Context, input GetActivationTokenByPlaintextInput) (*ActivationToken, error)

GetActivationTokenByPlaintext retrieves an activation token by its plaintext value

func (*Client) GetActivationTokensByUserID

func (c *Client) GetActivationTokensByUserID(ctx context.Context, input GetActivationTokensByUserIDInput) ([]ActivationToken, error)

GetActivationTokensByUserID fetches all activation tokens for a given user ID

func (*Client) GetMetadataKeyByID

func (c *Client) GetMetadataKeyByID(input GetMetadataKeyByIDInput) (*UserMetadata, error)

func (*Client) GetMetadataKeyByKeyName

func (c *Client) GetMetadataKeyByKeyName(input GetMetadataKeyByKeyNameInput) (*MetadataKey, error)

GetMetadataKeyByKeyName sends a GET request to the /metadata-keys/{keyName} endpoint of the account service to retrieve the metadata key by its key name.

func (*Client) GetPasswordResetTokenByPlaintext

func (c *Client) GetPasswordResetTokenByPlaintext(ctx context.Context, input GetPasswordResetTokenByPlaintextInput) (*PasswordResetToken, error)

GetPasswordResetTokenByPlaintext retrieves a password reset token by its plaintext.

func (*Client) GetPasswordResetTokensByUserID

func (c *Client) GetPasswordResetTokensByUserID(ctx context.Context, input GetPasswordResetTokensByUserIDInput) ([]PasswordResetToken, error)

GetPasswordResetTokensByUserID retrieves password reset tokens for the user by their user ID.

func (*Client) GetPermissionByID

func (c *Client) GetPermissionByID(input GetPermissionByIDInput) (*Permission, error)

func (*Client) GetPermissionByName

func (c *Client) GetPermissionByName(input GetPermissionByNameInput) (*Permission, error)

func (*Client) GetPermissionsByRoleID

func (c *Client) GetPermissionsByRoleID(input *GetPermissionsByRoleIDInput) ([]Permission, error)

GetPermissionsByRoleID fetches the permissions associated with the provided role ID.

func (*Client) GetPermissionsByUserID

func (c *Client) GetPermissionsByUserID(input *GetPermissionsByUserIDInput) ([]Permission, error)

func (*Client) GetRoleByID

func (c *Client) GetRoleByID(roleID uuid.UUID) (*Role, error)

func (*Client) GetRoleByName

func (c *Client) GetRoleByName(roleName string) (*Role, error)

func (*Client) GetRolesByPermissionID

func (c *Client) GetRolesByPermissionID(input GetRolesByPermissionIDInput) ([]Role, error)

GetRolesByPermissionID retrieves all roles associated with a permission identified by its ID.

func (*Client) GetRolesByServiceAccountID

func (c *Client) GetRolesByServiceAccountID(input GetRolesInput) ([]Role, error)

GetRolesByServiceAccountID retrieves roles associated with a specific service account ID

func (*Client) GetRolesByUserID

func (c *Client) GetRolesByUserID(input GetRolesByUserIDInput) ([]Role, error)

func (*Client) GetRolesForUser

func (c *Client) GetRolesForUser(userID uuid.UUID) ([]Role, error)

func (*Client) GetServiceAccountByID

func (c *Client) GetServiceAccountByID(id uuid.UUID) (*ServiceAccount, error)

GetServiceAccountByID sends a GET request to the server to retrieve a service account by its ID

func (*Client) GetServiceAccountByName

func (c *Client) GetServiceAccountByName(serviceName string) (*ServiceAccount, error)

func (*Client) GetServiceAccountsByRoleID

func (c *Client) GetServiceAccountsByRoleID(input GetServiceAccountsInput) ([]ServiceAccount, error)

func (*Client) GetTokenByPlaintext

func (c *Client) GetTokenByPlaintext(input GetTokenByPlaintextInput) (*Token, error)

func (*Client) GetTokensByScope

func (c *Client) GetTokensByScope(input GetTokensByScopeInput) ([]Token, error)

GetTokensByScope gets all tokens associated with a scope.

func (*Client) GetTokensByUserID

func (c *Client) GetTokensByUserID(input GetTokensByUserIDInput) ([]Token, error)

GetTokensByUserID gets all tokens associated with a user ID.

func (*Client) GetUserByEmail

func (c *Client) GetUserByEmail(email string) (*User, error)

func (*Client) GetUserByID

func (c *Client) GetUserByID(id uuid.UUID) (*User, error)

GetUserByID fetches a user using the user's ID

func (*Client) GetUserMetadataByID

func (c *Client) GetUserMetadataByID(metadataID uuid.UUID) (*UserMetadata, error)

GetUserMetadataByID retrieves user metadata by ID

func (*Client) GetUserMetadataByKey

func (c *Client) GetUserMetadataByKey(userID, key string) (*UserMetadata, error)

func (*Client) GetUserMetadataByUserID

func (c *Client) GetUserMetadataByUserID(userID uuid.UUID) (*[]UserMetadata, error)

GetUserMetadataByUserID fetches a user's metadata from the server.

func (*Client) IsCountrySanctioned

func (c *Client) IsCountrySanctioned(input IsCountrySanctionedInput) (bool, error)

func (*Client) IsPermissionAssignedToRole

func (c *Client) IsPermissionAssignedToRole(input IsPermissionAssignedToRoleInput) (bool, error)

IsPermissionAssignedToRole checks if a permission is assigned to a role.

func (*Client) IsRoleAssignedToServiceAccount

func (c *Client) IsRoleAssignedToServiceAccount(input RoleAssignmentInput) (bool, error)

func (*Client) IsUserInRole

func (c *Client) IsUserInRole(data *UserInRoleCheckData) (bool, error)

func (*Client) ListAllMetadataKeys

func (c *Client) ListAllMetadataKeys() ([]MetadataKey, error)

ListAllMetadataKeys retrieves all metadata keys.

func (*Client) ListAllUsers

func (c *Client) ListAllUsers() ([]User, error)

ListAllUsers sends a GET request to the accounts server to get a list of all users.

func (*Client) ListPermissions

func (c *Client) ListPermissions() (*ListPermissionsResponse, error)

func (*Client) ListRoles

func (c *Client) ListRoles() ([]Role, error)

func (*Client) ListServiceAccounts

func (c *Client) ListServiceAccounts() ([]ServiceAccount, error)

func (*Client) MetadataKeyExists

func (c *Client) MetadataKeyExists(keyName string) (bool, error)

MetadataKeyExists sends a GET request to the service to determine if a metadata key exists. It returns true if it exists, false if not, and any error that occurred.

func (*Client) ProcessPasswordReset

func (c *Client) ProcessPasswordReset(ctx context.Context, input ProcessPasswordResetInput) (*PasswordResetResponse, error)

ProcessPasswordReset processes a password reset using the provided token and new password.

func (*Client) RegisterServiceAccount

func (c *Client) RegisterServiceAccount(ctx context.Context, input RegisterServiceAccountInput) (*ServiceAccount, error)

RegisterServiceAccount registers a new service account with the provided name and roles.

func (*Client) RegisterUser

func (c *Client) RegisterUser(data *UserRegistrationData) error

func (*Client) RemovePermissionFromRole

func (c *Client) RemovePermissionFromRole(input RemovePermissionFromRoleInput) error

func (*Client) RemoveRoleFromServiceAccount

func (c *Client) RemoveRoleFromServiceAccount(input RemoveRoleInput) error

RemoveRoleFromServiceAccount removes a role from a service account.

func (*Client) RemoveSanctionedCountry

func (c *Client) RemoveSanctionedCountry(input RemoveSanctionedCountryInput) error

func (*Client) SetUserActiveStatus

func (c *Client) SetUserActiveStatus(event *SetUserActiveStatusEvent) error

func (*Client) UnassignRoleFromUser

func (c *Client) UnassignRoleFromUser(input *UserUnassignRoleInput) error

UnassignRoleFromUser removes a role from a user.

func (*Client) UpdateMetadataKey

func (c *Client) UpdateMetadataKey(input UpdateMetadataKeyInput) (*MetadataKey, error)

func (*Client) UpdatePermission

func (c *Client) UpdatePermission(input UpdatePermissionInput) error

func (*Client) UpdateRole

func (c *Client) UpdateRole(input *UpdateRoleInput) error

func (*Client) UpdateServiceAccount

func (c *Client) UpdateServiceAccount(input UpdateServiceAccountInput) error

UpdateServiceAccount sends a request to update a service account.

func (*Client) UpdateUser

func (c *Client) UpdateUser(userID uuid.UUID, payload *UpdateUserPayload) error

func (*Client) UpdateUserMetadata

func (c *Client) UpdateUserMetadata(userMetadata *UserMetadataUpdate) error

UpdateUserMetadata sends an HTTP request to update user metadata.

func (*Client) Validate

func (c *Client) Validate() error

Validate validates the Client fields.

func (*Client) ValidatePasswordResetToken

func (c *Client) ValidatePasswordResetToken(ctx context.Context, input ValidatePasswordResetTokenInput) (*PasswordResetToken, error)

ValidatePasswordResetToken validates a password reset token

func (*Client) VerifyActivationToken

func (c *Client) VerifyActivationToken(ctx context.Context, token string) (*ActivationToken, error)

VerifyActivationToken verifies the provided activation token

func (*Client) VerifyEmail

func (c *Client) VerifyEmail(event *VerifyEmailEvent) error

func (*Client) VerifyPasswordResetToken

func (c *Client) VerifyPasswordResetToken(ctx context.Context, input VerifyPasswordResetTokenInput) (*PasswordResetToken, error)

VerifyPasswordResetToken verifies a password reset token

func (*Client) VerifyPhoneNumber

func (c *Client) VerifyPhoneNumber(user *User) error

func (*Client) VerifyToken

func (c *Client) VerifyToken(token string) (*Token, error)

type CreateActivationTokenInput

type CreateActivationTokenInput struct {
	UserID uuid.UUID `json:"user_id"`
}

CreateActivationTokenInput represents the input required to create an activation token

type CreateMetadataKeyInput

type CreateMetadataKeyInput struct {
	KeyName string `json:"key_name"`
}

type CreatePasswordResetTokenInput

type CreatePasswordResetTokenInput struct {
	UserID uuid.UUID `json:"user_id"`
}

CreatePasswordResetTokenInput represents the input required to create a password reset token.

type CreatePermissionInput

type CreatePermissionInput struct {
	Name        string
	Description string
}

type CreateRoleInput

type CreateRoleInput struct {
	Name              string
	Description       string
	CompanyDomainOnly bool
	IsInternal        bool
	UserID            uuid.UUID
}

func (*CreateRoleInput) Validate

func (input *CreateRoleInput) Validate() error

type CreateTokenInput

type CreateTokenInput struct {
	UserID uuid.UUID `json:"user_id"`
	Scope  string    `json:"scope"`
}

CreateTokenInput represents the input data for creating a new token.

type DeleteActivationTokenByUserIDInput

type DeleteActivationTokenByUserIDInput struct {
	UserID uuid.UUID `json:"user_id"`
}

DeleteActivationTokenByUserIDInput represents the input required to delete activation tokens by user ID

type DeleteActivationTokenInput

type DeleteActivationTokenInput struct {
	TokenID uuid.UUID `json:"token_id"`
}

DeleteActivationTokenInput represents the input required to delete an activation token

type DeleteExpiredPasswordResetTokensInput

type DeleteExpiredPasswordResetTokensInput struct{}

DeleteExpiredPasswordResetTokensInput represents the input required to delete expired password reset tokens

type DeleteMetadataKeyInput

type DeleteMetadataKeyInput struct {
	ID uuid.UUID `json:"id"`
}

type DeletePasswordResetTokenByUserIDInput

type DeletePasswordResetTokenByUserIDInput struct {
	UserID uuid.UUID `json:"user_id"`
}

DeletePasswordResetTokenByUserIDInput represents the input required to delete password reset tokens by user ID

type DeletePasswordResetTokenInput

type DeletePasswordResetTokenInput struct {
	TokenID uuid.UUID `json:"token_id"`
}

DeletePasswordResetTokenInput represents the input required to delete a password reset token

type DeletePermissionInput

type DeletePermissionInput struct {
	ID uuid.UUID `json:"id"`
}

type DeleteRoleInput

type DeleteRoleInput struct {
	RoleID uuid.UUID
	UserID uuid.UUID
}

type DeleteTokenInput

type DeleteTokenInput struct {
	UserID  uuid.UUID `json:"userId"`
	TokenID uuid.UUID `json:"tokenId"`
}

DeleteTokenInput represents the input data for deleting a token.

type DeleteTokensByUserIDInput

type DeleteTokensByUserIDInput struct {
	UserID uuid.UUID `json:"userId"`
}

DeleteTokensByUserIDInput represents the input for deleting all tokens of a user.

type DisableTwoFactorAuthenticationInput

type DisableTwoFactorAuthenticationInput struct {
	UserID uuid.UUID `json:"user_id"`
}

type DoesPermissionExistInput

type DoesPermissionExistInput struct {
	PermissionID uuid.UUID
}

type DoesRoleExistInput

type DoesRoleExistInput struct {
	RoleID uuid.UUID
}

type EnableTwoFactorAuthenticationInput

type EnableTwoFactorAuthenticationInput struct {
	UserID           uuid.UUID `json:"user_id"`
	TwoFactorEnabled bool      `json:"two_factor_enabled"`
}

type GetActivationTokenByPlaintextInput

type GetActivationTokenByPlaintextInput struct {
	Plaintext string `json:"plaintext"`
}

GetActivationTokenByPlaintextInput represents the input required to get an activation token by plaintext

type GetActivationTokensByUserIDInput

type GetActivationTokensByUserIDInput struct {
	UserID uuid.UUID `json:"user_id"`
}

GetActivationTokensByUserIDInput represents the input required to get activation tokens by user ID

type GetMetadataKeyByIDInput

type GetMetadataKeyByIDInput struct {
	MetadataKeyID uuid.UUID `json:"metadata_key_id"`
	UserID        uuid.UUID `json:"user_id"`
}

type GetMetadataKeyByKeyNameInput

type GetMetadataKeyByKeyNameInput struct {
	KeyName string `json:"key_name"`
}

type GetPasswordResetTokenByPlaintextInput

type GetPasswordResetTokenByPlaintextInput struct {
	Plaintext string `json:"plaintext"`
}

GetPasswordResetTokenByPlaintextInput represents the input required to get a password reset token by plaintext

type GetPasswordResetTokensByUserIDInput

type GetPasswordResetTokensByUserIDInput struct {
	UserID uuid.UUID `json:"user_id"`
}

GetPasswordResetTokensByUserIDInput represents the input required to get password reset tokens by user ID

type GetPermissionByIDInput

type GetPermissionByIDInput struct {
	PermissionID uuid.UUID
}

type GetPermissionByNameInput

type GetPermissionByNameInput struct {
	PermissionName string
}

type GetPermissionsByRoleIDInput

type GetPermissionsByRoleIDInput struct {
	RoleID uuid.UUID
}

type GetPermissionsByUserIDInput

type GetPermissionsByUserIDInput struct {
	UserID uuid.UUID
}

type GetRolesByPermissionIDInput

type GetRolesByPermissionIDInput struct {
	PermissionID uuid.UUID
}

type GetRolesByUserIDInput

type GetRolesByUserIDInput struct {
	UserID uuid.UUID
}

type GetRolesInput

type GetRolesInput struct {
	ServiceAccountID uuid.UUID `json:"service_account_id"`
}

GetRolesInput represents the input data for retrieving roles of a service account.

type GetServiceAccountsInput

type GetServiceAccountsInput struct {
	RoleID uuid.UUID `json:"role_id"`
}

GetServiceAccountsInput represents the input data for retrieving service accounts by a role ID.

type GetTokenByPlaintextInput

type GetTokenByPlaintextInput struct {
	Plaintext string `json:"plaintext"`
}

GetTokenByPlaintextInput represents the input data for retrieving a token by plaintext.

type GetTokensByScopeInput

type GetTokensByScopeInput struct {
	Scope string `json:"scope"`
}

GetTokensByScopeInput represents the input data for retrieving a token by scope.

type GetTokensByUserIDInput

type GetTokensByUserIDInput struct {
	UserID uuid.UUID `json:"user_id"`
}

GetTokensByUserIDInput represents the input data for retrieving a token by user ID.

type IsCountrySanctionedInput

type IsCountrySanctionedInput struct {
	CountryCode string
}

type IsPermissionAssignedToRoleInput

type IsPermissionAssignedToRoleInput struct {
	RoleID       uuid.UUID
	PermissionID uuid.UUID
}

type ListPermissionsResponse

type ListPermissionsResponse struct {
	Permissions []Permission `json:"permissions"`
}

type MetadataKey

type MetadataKey struct {
	ID      uuid.UUID `json:"id"`
	KeyName string    `json:"key_name"`
}

MetadataKey represents a metadata key record in the database

type MetadataKeyExistsInput

type MetadataKeyExistsInput struct {
	KeyName string
}

type PasswordResetResponse

type PasswordResetResponse struct {
	Message string    `json:"message"`
	UserID  uuid.UUID `json:"user_id"`
}

PasswordResetResponse represents the response from the password reset processing endpoint.

type PasswordResetToken

type PasswordResetToken struct {
	Token     string    `json:"token"`
	UserID    uuid.UUID `json:"user_id"`
	CreatedAt string    `json:"created_at"`
	Expiry    string    `json:"expiry"`
}

PasswordResetToken represents a password reset token record in the database

type Permission

type Permission struct {
	ID          uuid.UUID `json:"id"`
	Name        string    `json:"name"`
	Description string    `json:"description"`
}

Permission represents the structure of a permission.

type PermissionRequest

type PermissionRequest struct {
	Token       string `json:"token"`
	Permissions string `json:"permissions"`
}

PermissionRequest represents the JSON request body sent to the authentication server to check a service account's permissions.

type PermissionResponse

type PermissionResponse struct {
	HasPermission bool `json:"has_permission"`
}

PermissionResponse represents the JSON response returned from the authentication server when checking a service account's permissions.

type ProcessPasswordResetInput

type ProcessPasswordResetInput struct {
	Token       string `json:"token"`
	NewPassword string `json:"new_password"`
}

ProcessPasswordResetInput represents the input required to process a password reset.

type RegisterServiceAccountInput

type RegisterServiceAccountInput struct {
	ServiceName string `json:"name"`
	Role        string `json:"role"`
}

type RemovePermissionFromRoleEvent

type RemovePermissionFromRoleEvent struct {
	RoleID       uuid.UUID `json:"role_id"`
	PermissionID uuid.UUID `json:"permission_id"`
}

type RemovePermissionFromRoleInput

type RemovePermissionFromRoleInput struct {
	RoleID       uuid.UUID
	PermissionID uuid.UUID
}

func (*RemovePermissionFromRoleInput) Validate

func (input *RemovePermissionFromRoleInput) Validate() error

type RemoveRoleInput

type RemoveRoleInput struct {
	ServiceAccountID uuid.UUID `json:"service_account_id"`
	RoleID           uuid.UUID `json:"role_id"`
}

RemoveRoleInput represents the input data for removing a role from a service account.

type RemoveSanctionedCountryInput

type RemoveSanctionedCountryInput struct {
	CountryCode string
}

type Role

type Role struct {
	ID                uuid.UUID `json:"id"`
	Name              string    `json:"name"`
	Description       string    `json:"description"`
	CompanyDomainOnly bool      `json:"company_domain_only"`
	IsInternal        bool      `json:"is_internal"`
}

Role represents the structure of a role.

type RoleAssignmentInput

type RoleAssignmentInput struct {
	ServiceAccountID uuid.UUID `json:"service_account_id"`
	RoleID           uuid.UUID `json:"role_id"`
}

RoleAssignmentInput represents the input data for checking a role assignment.

type RoleData

type RoleData struct {
	Name              string `json:"name"`
	Description       string `json:"description"`
	CompanyDomainOnly bool   `json:"company_domain_only"`
	IsInternal        bool   `json:"is_internal"`
}

RoleData represents the input data for a new role.

type RolesForUserResponse

type RolesForUserResponse struct {
	Roles []Role `json:"roles"`
}

type SanctionedCountry

type SanctionedCountry struct {
	ID          uuid.UUID `json:"id"`
	CountryCode string    `json:"country_code"`
	CountryName string    `json:"country_name"`
	AddedAt     time.Time `json:"added_at"`
}

SanctionedCountry represents the structure of a sanctioned country.

type ServiceAccount

type ServiceAccount struct {
	ID          uuid.UUID  `db:"id" json:"id"`
	Secret      string     `db:"secret" json:"secret"`
	ServiceName string     `db:"service_name" json:"service_name"`
	Roles       []string   `json:"roles"`
	CreatedAt   time.Time  `db:"created_at" json:"created_at"`
	ExpiresAt   *time.Time `db:"expires_at" json:"expires_at,omitempty"`
}

ServiceAccount represents the structure of a service account.

type SetUserActiveStatusEvent

type SetUserActiveStatusEvent struct {
	UserID   string `json:"user_id"`
	IsActive bool   `json:"is_active"`
}

SetUserActiveStatusEvent represents the event of a user's active status change.

func (*SetUserActiveStatusEvent) Validate

func (e *SetUserActiveStatusEvent) Validate() error

Validate validates the SetUserActiveStatusEvent data.

type Token

type Token struct {
	Plaintext string
	Hash      []byte
	UserID    uuid.UUID
	Expiry    time.Time
	Scope     string
	Error     error
}

Token represents the structure of a token.

func (*Token) Validate

func (t *Token) Validate() error

type UpdateMetadataKeyInput

type UpdateMetadataKeyInput struct {
	ID      uuid.UUID `json:"id"`
	KeyName string    `json:"key_name"`
}

type UpdatePermissionInput

type UpdatePermissionInput struct {
	ID          uuid.UUID `json:"id"`
	Name        string    `json:"name"`
	Description string    `json:"description"`
}

func (*UpdatePermissionInput) Validate

func (input *UpdatePermissionInput) Validate() error

type UpdateRoleInput

type UpdateRoleInput struct {
	Role   *Role
	UserID uuid.UUID
}

type UpdateServiceAccountInput

type UpdateServiceAccountInput struct {
	ID          uuid.UUID  `json:"id"`
	ServiceName string     `json:"service_name"`
	Roles       []string   `json:"roles"`
	ExpiresAt   *time.Time `json:"expires_at,omitempty"`
}

UpdateServiceAccountInput represents the input data for updating a service account.

type UpdateUserPayload

type UpdateUserPayload struct {
	Email            *string `json:"email,omitempty"`
	Userhandle       *string `json:"userhandle,omitempty"`
	FirstName        *string `json:"first_name,omitempty"`
	LastName         *string `json:"last_name,omitempty"`
	DisplayName      *string `json:"display_name,omitempty"`
	IsActive         *bool   `json:"is_active,omitempty"`
	IsEmailVerified  *bool   `json:"is_email_verified,omitempty"`
	IsPhoneVerified  *bool   `json:"is_phone_verified,omitempty"`
	TwoFactorEnabled *bool   `json:"two_factor_enabled,omitempty"`
}

func (*UpdateUserPayload) Validate

func (u *UpdateUserPayload) Validate() error

type User

type User struct {
	ID               uuid.UUID `json:"id"`
	Email            string    `json:"email"`
	Userhandle       string    `json:"userhandle,omitempty"`
	PasswordHash     []byte    `json:"-"`
	FirstName        string    `json:"first_name,omitempty"`
	LastName         string    `json:"last_name,omitempty"`
	DisplayName      string    `json:"display_name,omitempty"`
	AvatarURL        string    `json:"avatar_url,omitempty"`
	PhoneNumber      string    `json:"phone_number,omitempty"`
	IsActive         bool      `json:"is_active"`
	IsEmailVerified  bool      `json:"is_email_verified"`
	IsPhoneVerified  bool      `json:"is_phone_verified"`
	TwoFactorEnabled bool      `json:"two_factor_enabled"`
	CreatedAt        time.Time `json:"created_at"`
	UpdatedAt        time.Time `json:"updated_at,omitempty"`
}

User represents the structure of a user.

func (*User) Validate

func (u *User) Validate() error

Validate validates the User fields.

type UserInRoleCheckData

type UserInRoleCheckData struct {
	UserID uuid.UUID `json:"user_id"`
	RoleID uuid.UUID `json:"role_id"`
}

UserInRoleCheckData represents the input data for a user role check.

type UserMetadata

type UserMetadata struct {
	ID        uuid.UUID `json:"id"`
	UserID    uuid.UUID `json:"user_id"`
	KeyID     uuid.UUID `json:"key"`
	Value     string    `json:"value"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at,omitempty"`
}

UserMetadata represents the structure of a user metadata.

func (*UserMetadata) Validate

func (u *UserMetadata) Validate() error

type UserMetadataUpdate

type UserMetadataUpdate struct {
	ID     uuid.UUID `json:"id"`
	UserID uuid.UUID `json:"user_id"`
	Key    string    `json:"key"`
	Value  string    `json:"value"`
}

UserMetadataUpdate represents the input data for updating user metadata.

func (*UserMetadataUpdate) Validate

func (u *UserMetadataUpdate) Validate() error

Validate validates the UserMetadataUpdate fields.

type UserRegistrationData

type UserRegistrationData struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

UserRegistrationData represents the input data for a new user registration.

func (*UserRegistrationData) Validate

func (d *UserRegistrationData) Validate() error

Validate validates the UserRegistrationData fields.

type UserRemoveRoleEvent

type UserRemoveRoleEvent struct {
	UserID uuid.UUID `json:"user_id"`
	RoleID uuid.UUID `json:"role_id"`
}

UserRemoveRoleEvent represents the payload structure for the RemoveRoleFromUser event.

type UserRoleData

type UserRoleData struct {
	UserID uuid.UUID `json:"user_id"`
	RoleID uuid.UUID `json:"role_id"`
}

type UserUnassignRoleInput

type UserUnassignRoleInput struct {
	UserID uuid.UUID `json:"user_id"`
	RoleID uuid.UUID `json:"role_id"`
}

type ValidatePasswordResetTokenInput

type ValidatePasswordResetTokenInput struct {
	Token string `json:"token"`
}

ValidatePasswordResetTokenInput represents the input required to validate a password reset token

type VerifyEmailEvent

type VerifyEmailEvent struct {
	UserID uuid.UUID `json:"user_id"`
	Email  string    `json:"email"`
}

func (*VerifyEmailEvent) Validate

func (e *VerifyEmailEvent) Validate() error

type VerifyPasswordResetTokenInput

type VerifyPasswordResetTokenInput struct {
	Token string `json:"token"`
}

VerifyPasswordResetTokenInput represents the input required to verify a password reset token

Jump to

Keyboard shortcuts

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