httphandler

package
v0.0.0-...-c846bbc Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 57 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultMaxMemoryAllocation = 2 * 1024 * 1024

DefaultMaxMemoryAllocation limits the max of memory allocation up to 2MB when parsing the multipart form data request

View Source
const DeviceIDHeader = "Device-ID"
View Source
const (
	InformationNotFoundOnServer = "the information you provided could not be found"
)
View Source
const OTPMessageDisclaimer = " If you did not request this code, please ignore. Do not share your code with anyone."

OTPMessageDisclaimer contains disclaimer text that needs to be added as part of the OTP message to remind the receiver how sensitive the data is.

Variables

This section is empty.

Functions

This section is empty.

Types

type AssetRequest

type AssetRequest struct {
	Code   string `json:"code"`
	Issuer string `json:"issuer"`
}

type AssetsHandler

type AssetsHandler struct {
	Models *data.Models
	engine.SubmitterEngine
	GetPreconditionsFn func() txnbuild.Preconditions
}

func (AssetsHandler) CreateAsset

func (c AssetsHandler) CreateAsset(w http.ResponseWriter, r *http.Request)

CreateAsset adds a new asset.

func (AssetsHandler) DeleteAsset

func (c AssetsHandler) DeleteAsset(w http.ResponseWriter, r *http.Request)

DeleteAsset marks an asset for soft delete.

func (AssetsHandler) GetAssets

func (c AssetsHandler) GetAssets(w http.ResponseWriter, r *http.Request)

GetAssets returns a list of assets.

type Balance

type Balance struct {
	Amount      string `json:"amount"`
	AssetCode   string `json:"asset_code"`
	AssetIssuer string `json:"asset_issuer"`
}

type BalancesHandler

type BalancesHandler struct {
	DistributionAccountResolver signing.DistributionAccountResolver
	CircleService               circle.ServiceInterface
	NetworkType                 utils.NetworkType
}

func (BalancesHandler) Get

Get returns the balances of the distribution account.

type CircleConfigHandler

type CircleConfigHandler struct {
	NetworkType                 sdpUtils.NetworkType
	CircleFactory               circle.ClientFactory
	TenantManager               tenant.ManagerInterface
	Encrypter                   sdpUtils.PrivateKeyEncrypter
	EncryptionPassphrase        string
	CircleClientConfigModel     circle.ClientConfigModelInterface
	DistributionAccountResolver signing.DistributionAccountResolver
	MonitorService              monitor.MonitorServiceInterface
}

CircleConfigHandler implements a handler to configure the Circle API access.

func (CircleConfigHandler) Patch

Patch is a handler to configure the Circle API access.

type CreateUserRequest

type CreateUserRequest struct {
	FirstName string          `json:"first_name"`
	LastName  string          `json:"last_name"`
	Email     string          `json:"email"`
	Roles     []data.UserRole `json:"roles"`
}

type DeleteContactInfoHandler

type DeleteContactInfoHandler struct {
	NetworkPassphrase string
	Models            *data.Models
}

func (DeleteContactInfoHandler) ServeHTTP

type DisbursementHandler

type DisbursementHandler struct {
	Models                        *data.Models
	MonitorService                monitor.MonitorServiceInterface
	AuthManager                   auth.AuthManager
	DisbursementManagementService *services.DisbursementManagementService
	DistributionAccountResolver   signing.DistributionAccountResolver
}

func (DisbursementHandler) GetDisbursement

func (d DisbursementHandler) GetDisbursement(w http.ResponseWriter, r *http.Request)

func (DisbursementHandler) GetDisbursementInstructions

func (d DisbursementHandler) GetDisbursementInstructions(w http.ResponseWriter, r *http.Request)

func (DisbursementHandler) GetDisbursementReceivers

func (d DisbursementHandler) GetDisbursementReceivers(w http.ResponseWriter, r *http.Request)

func (DisbursementHandler) GetDisbursements

func (d DisbursementHandler) GetDisbursements(w http.ResponseWriter, r *http.Request)

GetDisbursements returns a paginated list of disbursements

func (DisbursementHandler) PatchDisbursementStatus

func (d DisbursementHandler) PatchDisbursementStatus(w http.ResponseWriter, r *http.Request)

PatchDisbursementStatus updates the status of a disbursement

func (DisbursementHandler) PostDisbursement

func (d DisbursementHandler) PostDisbursement(w http.ResponseWriter, r *http.Request)

func (DisbursementHandler) PostDisbursementInstructions

func (d DisbursementHandler) PostDisbursementInstructions(w http.ResponseWriter, r *http.Request)

type ErrorInformationNotFound

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

ErrorInformationNotFound implements the error interface.

func (*ErrorInformationNotFound) Error

func (e *ErrorInformationNotFound) Error() string

type ErrorVerificationAttemptsExceeded

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

func (*ErrorVerificationAttemptsExceeded) Error

type ForgotPasswordHandler

type ForgotPasswordHandler struct {
	AuthManager        auth.AuthManager
	MessengerClient    message.MessengerClient
	Models             *data.Models
	ReCAPTCHAValidator validators.ReCAPTCHAValidator
	ReCAPTCHADisabled  bool
}

ForgotPasswordHandler searches for the user that is requesting a password reset and sends an email with a link to access the password reset page.

func (ForgotPasswordHandler) SendForgotPasswordMessage

func (h ForgotPasswordHandler) SendForgotPasswordMessage(ctx context.Context, uiBaseURL, email, resetToken string) error

func (ForgotPasswordHandler) ServeHTTP

ServeHTTP implements the http.Handler interface.

type ForgotPasswordRequest

type ForgotPasswordRequest struct {
	Email          string `json:"email"`
	ReCAPTCHAToken string `json:"recaptcha_token"`
}

type ForgotPasswordResponseBody

type ForgotPasswordResponseBody struct {
	Message string `json:"message"`
}

type GetBalanceResponse

type GetBalanceResponse struct {
	Account  schema.TransactionAccount `json:"account"`
	Balances []Balance                 `json:"balances"`
}

type GetProfileResponse

type GetProfileResponse struct {
	ID               string   `json:"id"`
	FirstName        string   `json:"first_name"`
	LastName         string   `json:"last_name"`
	Email            string   `json:"email"`
	Roles            []string `json:"roles"`
	OrganizationName string   `json:"organization_name"`
}

type GetReceiverResponse

type GetReceiverResponse struct {
	data.Receiver
	Wallets       []data.ReceiverWallet       `json:"wallets"`
	Verifications []data.ReceiverVerification `json:"verifications,omitempty"`
}

type HealthHandler

type HealthHandler struct {
	Version          string
	ServiceID        string
	ReleaseID        string
	DBConnectionPool db.DBConnectionPool
	Producer         events.Producer
}

HealthHandler implements a simple handler that returns the health response.

func (HealthHandler) ServeHTTP

func (h HealthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements the http.Handler interface.

type HealthResponse

type HealthResponse struct {
	Status    Status            `json:"status"`
	Version   string            `json:"version,omitempty"`
	ServiceID string            `json:"service_id,omitempty"`
	ReleaseID string            `json:"release_id,omitempty"`
	Services  map[string]Status `json:"services,omitempty"`
}

HealthResponse follows the health check response format for HTTP APIs, based on the format defined in the draft IETF network working group standard, Health Check Response Format for HTTP APIs.

https://datatracker.ietf.org/doc/html/draft-inadarei-api-health-check-06#name-api-health-response

type ListRolesHandler

type ListRolesHandler struct{}

func (ListRolesHandler) GetRoles

func (h ListRolesHandler) GetRoles(rw http.ResponseWriter, req *http.Request)

GetRoles retrieves all the users roles available

type LoginHandler

type LoginHandler struct {
	AuthManager        auth.AuthManager
	ReCAPTCHAValidator validators.ReCAPTCHAValidator
	MessengerClient    message.MessengerClient
	Models             *data.Models
	ReCAPTCHADisabled  bool
	MFADisabled        bool
}

func (LoginHandler) ServeHTTP

func (h LoginHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request)

type LoginRequest

type LoginRequest struct {
	Email          string `json:"email"`
	Password       string `json:"password"`
	ReCAPTCHAToken string `json:"recaptcha_token"`
}

type LoginResponse

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

type MFAHandler

type MFAHandler struct {
	AuthManager        auth.AuthManager
	ReCAPTCHAValidator validators.ReCAPTCHAValidator
	Models             *data.Models
	ReCAPTCHADisabled  bool
}

func (MFAHandler) ServeHTTP

func (h MFAHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request)

type MFARequest

type MFARequest struct {
	MFACode        string `json:"mfa_code"`
	RememberMe     bool   `json:"remember_me"`
	ReCAPTCHAToken string `json:"recaptcha_token"`
}

type MFAResponse

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

type OTPRegistrationType

type OTPRegistrationType string

type PatchCircleConfigRequest

type PatchCircleConfigRequest struct {
	WalletID *string `json:"wallet_id"`
	APIKey   *string `json:"api_key"`
}

type PatchDisbursementStatusRequest

type PatchDisbursementStatusRequest struct {
	Status string `json:"status"`
}

type PatchOrganizationProfileRequest

type PatchOrganizationProfileRequest struct {
	OrganizationName                    string  `json:"organization_name"`
	TimezoneUTCOffset                   string  `json:"timezone_utc_offset"`
	IsApprovalRequired                  *bool   `json:"is_approval_required"`
	ReceiverInvitationResendInterval    *int64  `json:"receiver_invitation_resend_interval_days"`
	PaymentCancellationPeriodDays       *int64  `json:"payment_cancellation_period_days"`
	ReceiverRegistrationMessageTemplate *string `json:"receiver_registration_message_template"`
	OTPMessageTemplate                  *string `json:"otp_message_template"`
	PrivacyPolicyLink                   *string `json:"privacy_policy_link"`
}

func (*PatchOrganizationProfileRequest) AreAllFieldsEmpty

func (r *PatchOrganizationProfileRequest) AreAllFieldsEmpty() bool

type PatchPaymentStatusRequest

type PatchPaymentStatusRequest struct {
	Status string `json:"status"`
}

type PatchUserPasswordRequest

type PatchUserPasswordRequest struct {
	CurrentPassword string `json:"current_password"`
	NewPassword     string `json:"new_password"`
}

type PatchUserProfileRequest

type PatchUserProfileRequest struct {
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
	Email     string `json:"email"`
}

type PaymentsHandler

type PaymentsHandler struct {
	Models                      *data.Models
	DBConnectionPool            db.DBConnectionPool
	AuthManager                 auth.AuthManager
	EventProducer               events.Producer
	CrashTrackerClient          crashtracker.CrashTrackerClient
	DistributionAccountResolver signing.DistributionAccountResolver
}

func (PaymentsHandler) GetPayment

func (p PaymentsHandler) GetPayment(w http.ResponseWriter, r *http.Request)

func (PaymentsHandler) GetPayments

func (p PaymentsHandler) GetPayments(w http.ResponseWriter, r *http.Request)

func (PaymentsHandler) PatchPaymentStatus

func (p PaymentsHandler) PatchPaymentStatus(w http.ResponseWriter, r *http.Request)

func (PaymentsHandler) RetryPayments

func (p PaymentsHandler) RetryPayments(rw http.ResponseWriter, req *http.Request)

type PostDisbursementRequest

type PostDisbursementRequest struct {
	Name                                string                       `json:"name"`
	WalletID                            string                       `json:"wallet_id"`
	AssetID                             string                       `json:"asset_id"`
	VerificationField                   data.VerificationType        `json:"verification_field"`
	RegistrationContactType             data.RegistrationContactType `json:"registration_contact_type"`
	ReceiverRegistrationMessageTemplate string                       `json:"receiver_registration_message_template"`
}

type ProfileHandler

type ProfileHandler struct {
	Models                      *data.Models
	AuthManager                 auth.AuthManager
	MaxMemoryAllocation         int64
	BaseURL                     string
	PublicFilesFS               fs.FS
	DistributionAccountResolver signing.DistributionAccountResolver
	PasswordValidator           *authUtils.PasswordValidator
	utils.NetworkType
}

func (ProfileHandler) GetOrganizationInfo

func (h ProfileHandler) GetOrganizationInfo(rw http.ResponseWriter, req *http.Request)
func (h ProfileHandler) GetOrganizationLogo(rw http.ResponseWriter, req *http.Request)

GetOrganizationLogo renders the stored organization logo. The image is rendered inline (not attached - the attached option downloads the content) so the client can embed the image.

func (ProfileHandler) GetProfile

func (h ProfileHandler) GetProfile(rw http.ResponseWriter, req *http.Request)

func (ProfileHandler) PatchOrganizationProfile

func (h ProfileHandler) PatchOrganizationProfile(rw http.ResponseWriter, req *http.Request)

func (ProfileHandler) PatchUserPassword

func (h ProfileHandler) PatchUserPassword(rw http.ResponseWriter, req *http.Request)

func (ProfileHandler) PatchUserProfile

func (h ProfileHandler) PatchUserProfile(rw http.ResponseWriter, req *http.Request)

type ReceiverHandler

type ReceiverHandler struct {
	Models           *data.Models
	DBConnectionPool db.DBConnectionPool
}

func (ReceiverHandler) GetReceiver

func (rh ReceiverHandler) GetReceiver(w http.ResponseWriter, r *http.Request)

func (ReceiverHandler) GetReceiverVerificationTypes

func (rh ReceiverHandler) GetReceiverVerificationTypes(w http.ResponseWriter, r *http.Request)

GetReceiverVerification returns a list of verification types

func (ReceiverHandler) GetReceivers

func (rh ReceiverHandler) GetReceivers(w http.ResponseWriter, r *http.Request)

type ReceiverRegistrationData

type ReceiverRegistrationData struct {
	StellarAccount       string
	JWTToken             string
	Title                string
	Message              string
	ReCAPTCHASiteKey     string
	PrivacyPolicyLink    string
	OrganizationName     string
	TruncatedContactInfo string
}

type ReceiverRegistrationHandler

type ReceiverRegistrationHandler struct {
	Models              *data.Models
	ReceiverWalletModel *data.ReceiverWalletModel
	ReCAPTCHASiteKey    string
}

func (ReceiverRegistrationHandler) ServeHTTP

ServeHTTP will serve the SEP-24 deposit page needed to register users.

type ReceiverSendOTPData

type ReceiverSendOTPData struct {
	OTP              string
	OrganizationName string
}

type ReceiverSendOTPHandler

type ReceiverSendOTPHandler struct {
	Models             *data.Models
	MessageDispatcher  message.MessageDispatcherInterface
	ReCAPTCHAValidator validators.ReCAPTCHAValidator
}

func (ReceiverSendOTPHandler) ServeHTTP

type ReceiverSendOTPRequest

type ReceiverSendOTPRequest struct {
	PhoneNumber    string `json:"phone_number"`
	Email          string `json:"email"`
	ReCAPTCHAToken string `json:"recaptcha_token"`
}

type ReceiverSendOTPResponseBody

type ReceiverSendOTPResponseBody struct {
	Message           string                `json:"message"`
	VerificationField data.VerificationType `json:"verification_field"`
}

type ReceiverWalletsHandler

type ReceiverWalletsHandler struct {
	Models             *data.Models
	EventProducer      events.Producer
	CrashTrackerClient crashtracker.CrashTrackerClient
}

func (ReceiverWalletsHandler) RetryInvitation

func (h ReceiverWalletsHandler) RetryInvitation(rw http.ResponseWriter, req *http.Request)

type RefreshTokenHandler

type RefreshTokenHandler struct {
	AuthManager auth.AuthManager
}

func (RefreshTokenHandler) PostRefreshToken

func (h RefreshTokenHandler) PostRefreshToken(rw http.ResponseWriter, req *http.Request)

type RegistrationContactTypesHandler

type RegistrationContactTypesHandler struct{}

func (RegistrationContactTypesHandler) Get

type ResetPasswordHandler

type ResetPasswordHandler struct {
	AuthManager       auth.AuthManager
	PasswordValidator *authUtils.PasswordValidator
}

ResetPasswordHandler resets the user password by receiving a valid reset token and the new password.

func (ResetPasswordHandler) ServeHTTP

ServeHTTP implements the http.Handler interface.

type ResetPasswordRequest

type ResetPasswordRequest struct {
	Password   string `json:"password"`
	ResetToken string `json:"reset_token"`
}

type RetryInvitationMessageResponse

type RetryInvitationMessageResponse struct {
	ID               string     `json:"id"`
	ReceiverID       string     `json:"receiver_id"`
	WalletID         string     `json:"wallet_id"`
	CreatedAt        time.Time  `json:"created_at"`
	InvitationSentAt *time.Time `json:"invitation_sent_at"`
}

type RetryPaymentsRequest

type RetryPaymentsRequest struct {
	PaymentIDs []string `json:"payment_ids"`
}

type StatisticsHandler

type StatisticsHandler struct {
	DBConnectionPool db.DBConnectionPool
}

func (StatisticsHandler) GetStatistics

func (s StatisticsHandler) GetStatistics(w http.ResponseWriter, r *http.Request)

func (StatisticsHandler) GetStatisticsByDisbursement

func (s StatisticsHandler) GetStatisticsByDisbursement(w http.ResponseWriter, r *http.Request)

type Status

type Status string

Status indicates whether the service is health or not.

const (
	// StatusPass indicates that the service is healthy.
	StatusPass Status = "pass"
	// StatusFail indicates that the service is unhealthy.
	StatusFail Status = "fail"
)

type StellarTomlHandler

type StellarTomlHandler struct {
	AnchorPlatformBaseSepURL    string
	DistributionAccountResolver signing.DistributionAccountResolver
	NetworkPassphrase           string
	Models                      *data.Models
	Sep10SigningPublicKey       string
	InstanceName                string
}

func (StellarTomlHandler) ServeHTTP

func (s StellarTomlHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP will serve the stellar.toml file needed to register users through SEP-24.

type UpdateDisbursementStatusResponseBody

type UpdateDisbursementStatusResponseBody struct {
	Message string `json:"message"`
}

type UpdatePaymentStatusResponseBody

type UpdatePaymentStatusResponseBody struct {
	Message string `json:"message"`
}

type UpdateReceiverHandler

type UpdateReceiverHandler struct {
	Models           *data.Models
	DBConnectionPool db.DBConnectionPool
}

func (UpdateReceiverHandler) UpdateReceiver

func (h UpdateReceiverHandler) UpdateReceiver(rw http.ResponseWriter, req *http.Request)

type UpdateRolesRequest

type UpdateRolesRequest struct {
	UserID string          `json:"user_id"`
	Roles  []data.UserRole `json:"roles"`
}

type UserActivationRequest

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

type UserHandler

type UserHandler struct {
	AuthManager        auth.AuthManager
	CrashTrackerClient crashtracker.CrashTrackerClient
	MessengerClient    message.MessengerClient
	Models             *data.Models
}

func (UserHandler) CreateUser

func (h UserHandler) CreateUser(rw http.ResponseWriter, req *http.Request)

func (UserHandler) GetAllUsers

func (h UserHandler) GetAllUsers(rw http.ResponseWriter, req *http.Request)

func (UserHandler) UpdateUserRoles

func (h UserHandler) UpdateUserRoles(rw http.ResponseWriter, req *http.Request)

func (UserHandler) UserActivation

func (h UserHandler) UserActivation(rw http.ResponseWriter, req *http.Request)

type UserSorterByEmail

type UserSorterByEmail []auth.User

func (UserSorterByEmail) Len

func (a UserSorterByEmail) Len() int

func (UserSorterByEmail) Less

func (a UserSorterByEmail) Less(i, j int) bool

func (UserSorterByEmail) Swap

func (a UserSorterByEmail) Swap(i, j int)

type UserSorterByIsActive

type UserSorterByIsActive []auth.User

func (UserSorterByIsActive) Len

func (a UserSorterByIsActive) Len() int

func (UserSorterByIsActive) Less

func (a UserSorterByIsActive) Less(i, j int) bool

func (UserSorterByIsActive) Swap

func (a UserSorterByIsActive) Swap(i, j int)

type VerifyReceiverRegistrationHandler

type VerifyReceiverRegistrationHandler struct {
	AnchorPlatformAPIService    anchorplatform.AnchorPlatformAPIServiceInterface
	Models                      *data.Models
	ReCAPTCHAValidator          validators.ReCAPTCHAValidator
	NetworkPassphrase           string
	EventProducer               events.Producer
	CrashTrackerClient          crashtracker.CrashTrackerClient
	DistributionAccountResolver signing.DistributionAccountResolver
}

func (VerifyReceiverRegistrationHandler) VerifyReceiverRegistration

func (v VerifyReceiverRegistrationHandler) VerifyReceiverRegistration(w http.ResponseWriter, r *http.Request)

VerifyReceiverRegistration is the handler for the SEP-24 `POST /wallet-registration/verification` endpoint. It is where the SDP verifies the receiver's PII & OTP, update the receiver wallet with the Stellar account and memo, found in the JWT token, and PATCH the transaction on the AnchorPlatform.

type WalletsHandler

type WalletsHandler struct {
	Models      *data.Models
	NetworkType utils.NetworkType
}

func (WalletsHandler) DeleteWallet

func (c WalletsHandler) DeleteWallet(rw http.ResponseWriter, req *http.Request)

func (WalletsHandler) GetWallets

func (h WalletsHandler) GetWallets(w http.ResponseWriter, r *http.Request)

GetWallets returns a list of wallets

func (WalletsHandler) PatchWallets

func (h WalletsHandler) PatchWallets(rw http.ResponseWriter, req *http.Request)

func (WalletsHandler) PostWallets

func (h WalletsHandler) PostWallets(rw http.ResponseWriter, req *http.Request)

Jump to

Keyboard shortcuts

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