Documentation
¶
Index ¶
- Constants
- func CORSMiddleware(next http.Handler) http.Handler
- func NewAPIEngine(address string, generalHandler http.Handler) (*apiEngine, error)
- func NewAccessKeysHandler(keyAccessProvider KeyAccessProvider, auth Authenticator) (*accessKeysHandler, error)
- func NewCaptchaHandler(handler CaptchaHandler) (*captchaHandler, error)
- func NewCryptoPaymentHandler(client CryptoPaymentClient, storage KeyAccessProvider, auth Authenticator, ...) (*cryptoPaymentHandler, error)
- func NewGatewayTester() *gatewayTester
- func NewJWTAuthenticator(key string) *jwtAuthenticator
- func NewLoginHandler(provider KeyAccessProvider, auth Authenticator) (*loginHandler, error)
- func NewPerformanceHandler(keyAccessProvider KeyAccessProvider, auth Authenticator) (*performanceHandler, error)
- func NewRegistrationHandler(keyAccessProvider KeyAccessProvider, emailSender EmailSender, ...) (*registrationHandler, error)
- func NewUserCredentialsHandler(keyAccessProvider KeyAccessProvider, emailSender EmailSender, ...) (*userCredentialsHandler, error)
- func NewUsersHandler(keyAccessProvider KeyAccessProvider, auth Authenticator) (*usersHandler, error)
- type Authenticator
- type CaptchaHandler
- type CaptchaResponse
- type CryptoPaymentClient
- type EmailSender
- type KeyAccessProvider
- type MutexHandler
Constants ¶
const ( EndpointApiAccessKeys = "/api/admin-access-keys" EndpointApiAdminUsers = "/api/admin-users" EndpointApiLogin = "/api/login" EndpointApiRegister = "/api/register" EndpointApiActivate = "/api/activate" EndpointCaptchaMultiple = "/api/captcha/" EndpointCaptchaSingle = "/api/captcha" EndpointAppInfo = "/api/app-info" EndpointApiPerformance = "/api/performance" EndpointApiChangePassword = "/api/change-password" EndpointApiRequestEmailChange = "/api/request-email-change" EndpointApiConfirmEmailChange = "/api/confirm-email-change" EndpointApiCryptoPaymentConfig = "/api/crypto-payment/config" EndpointApiCryptoPaymentCreateAddress = "/api/crypto-payment/create-address" EndpointApiCryptoPaymentAccount = "/api/crypto-payment/account" EndpointApiAdminCryptoPaymentAccount = "/api/admin-crypto-payment/account" EndpointSwagger = "/swagger/" EndpointRoot = "/" EndpointFrontendLogin = "/#/login" )
Constants for endpoint namings
Variables ¶
This section is empty.
Functions ¶
func CORSMiddleware ¶
CORSMiddleware enables CORS for the handler
func NewAPIEngine ¶
NewAPIEngine creates and opens a new API engine
func NewAccessKeysHandler ¶
func NewAccessKeysHandler(keyAccessProvider KeyAccessProvider, auth Authenticator) (*accessKeysHandler, error)
NewAccessKeysHandler creates a new AccessKeysHandler
func NewCaptchaHandler ¶
func NewCaptchaHandler(handler CaptchaHandler) (*captchaHandler, error)
NewCaptchaHandler creates a new captcha handler
func NewCryptoPaymentHandler ¶
func NewCryptoPaymentHandler( client CryptoPaymentClient, storage KeyAccessProvider, auth Authenticator, mutexes MutexHandler, ) (*cryptoPaymentHandler, error)
NewCryptoPaymentHandler creates a new cryptoPaymentHandler instance
func NewGatewayTester ¶
func NewGatewayTester() *gatewayTester
NewGatewayTester returns an instance of type gatewayTester
func NewJWTAuthenticator ¶
func NewJWTAuthenticator(key string) *jwtAuthenticator
NewJWTAuthenticator creates a new jwtAuthenticator instance
func NewLoginHandler ¶
func NewLoginHandler(provider KeyAccessProvider, auth Authenticator) (*loginHandler, error)
NewLoginHandler creates a new login handler
func NewPerformanceHandler ¶
func NewPerformanceHandler(keyAccessProvider KeyAccessProvider, auth Authenticator) (*performanceHandler, error)
NewPerformanceHandler creates a new performanceHandler instance
func NewRegistrationHandler ¶
func NewRegistrationHandler( keyAccessProvider KeyAccessProvider, emailSender EmailSender, appDomainsConfig config.AppDomainsConfig, captchaHandler CaptchaHandler, htmlTemplate string, ) (*registrationHandler, error)
NewRegistrationHandler creates a new registrationHandler instance
func NewUserCredentialsHandler ¶
func NewUserCredentialsHandler( keyAccessProvider KeyAccessProvider, emailSender EmailSender, appDomainsConfig config.AppDomainsConfig, htmlTemplate string, auth Authenticator, ) (*userCredentialsHandler, error)
NewUserCredentialsHandler creates a new userCredentialsHandler instance
func NewUsersHandler ¶
func NewUsersHandler(keyAccessProvider KeyAccessProvider, auth Authenticator) (*usersHandler, error)
NewUsersHandler creates a new usersHandler instance
Types ¶
type Authenticator ¶
type Authenticator interface {
GenerateToken(username string, isAdmin bool) (string, error)
CheckAuth(r *http.Request) (*common.Claims, error)
IsInterfaceNil() bool
}
Authenticator defines the behavior for authentication
type CaptchaHandler ¶
type CaptchaHandler interface {
VerifyString(id string, digits string) bool
NewCaptcha() string
Reload(id string)
WriteNoError(w io.Writer, id string)
IsInterfaceNil() bool
}
CaptchaHandler defines the operations supported by a component able to generate & test captchas
type CaptchaResponse ¶
type CaptchaResponse struct {
CaptchaId string `json:"captchaId"`
}
CaptchaResponse holds the captcha ID
type CryptoPaymentClient ¶
type CryptoPaymentClient interface {
GetConfig() (*common.CryptoPaymentConfig, error)
CreateAddress() (*common.CreateAddressResponse, error)
GetAccount(paymentID uint64) (*common.AccountInfo, error)
IsInterfaceNil() bool
}
CryptoPaymentClient handles communication with the crypto-payment service
type EmailSender ¶
type EmailSender interface {
SendEmail(to string, subject string, body any, htmlTemplate string) error
IsInterfaceNil() bool
}
EmailSender defines the operations supported by a component able to send emails
type KeyAccessProvider ¶
type KeyAccessProvider interface {
AddUser(username string, password string, isAdmin bool, maxRequests uint64, isPremium bool, isActive bool, activationToken string) error
ActivateUser(token string) error
GetAllUsers() (map[string]common.UsersDetails, error)
IsKeyAllowed(key string) (string, common.AccountType, error)
CheckUserCredentials(username string, password string) (*common.UsersDetails, error)
GetAllKeys(username string) (map[string]common.AccessKeyDetails, error)
AddKey(username string, key string) error
RemoveKey(username string, key string) error
RemoveUser(username string) error
UpdateUser(username string, password string, isAdmin bool, maxRequests uint64, isPremium bool) error
GetUser(username string) (*common.UsersDetails, error)
GetPerformanceMetrics() (map[string]uint64, error)
UpdatePassword(username string, password string) error
RequestEmailChange(username string, newEmail string, token string) error
ConfirmEmailChange(token string) (string, error)
SetCryptoPaymentID(username string, paymentID uint64) error
Close() error
IsInterfaceNil() bool
}
KeyAccessProvider can decide if a provided key has or not query access