httphandler

package
v0.0.0-...-9cf9cea Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 49 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 CountriesHandler

type CountriesHandler struct {
	Models *data.Models
}

func (CountriesHandler) GetCountries

func (c CountriesHandler) GetCountries(w http.ResponseWriter, r *http.Request)

GetCountries returns a list of countries

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 DeletePhoneNumberHandler

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

func (DeletePhoneNumberHandler) 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) 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 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
}

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"`
}

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 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"`
	SMSResendInterval              *int64  `json:"sms_resend_interval"`
	PaymentCancellationPeriodDays  *int64  `json:"payment_cancellation_period_days"`
	SMSRegistrationMessageTemplate *string `json:"sms_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
}

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"`
	CountryCode                    string                 `json:"country_code"`
	WalletID                       string                 `json:"wallet_id"`
	AssetID                        string                 `json:"asset_id"`
	VerificationField              data.VerificationField `json:"verification_field"`
	SMSRegistrationMessageTemplate string                 `json:"sms_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
}

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
}

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
	SMSMessengerClient message.MessengerClient
	ReCAPTCHAValidator validators.ReCAPTCHAValidator
}

func (ReceiverSendOTPHandler) ServeHTTP

type ReceiverSendOTPRequest

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

type ReceiverSendOTPResponseBody

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

type ReceiverWalletsHandler

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

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 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 RetryInvitationSMSResponse

type RetryInvitationSMSResponse 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
	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
}

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
}

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