Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible to disable account creation #198

Merged
merged 1 commit into from Jun 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -47,6 +47,7 @@ vim .env # edit your config
+ `PROMETHEUS_PORT`: (default: 9092) Prometheus port (path: `/metrics`)
+ `WEBHOOK_URL`: Optional. Callback URL for incoming and outgoing payment events, see below.
+ `FEE_RESERVE`: (default: false) Keep fee reserve for each user
+ `ALLOW_ACCOUNT_CREATION`: (default: true) Enable creation of new accounts

## Developing

Expand Down
4 changes: 3 additions & 1 deletion legacy_endpoints.go
Expand Up @@ -13,7 +13,9 @@ import (
func RegisterLegacyEndpoints(svc *service.LndhubService, e *echo.Echo, secured *echo.Group, securedWithStrictRateLimit *echo.Group, strictRateLimitMiddleware echo.MiddlewareFunc) {
// Public endpoints for account creation and authentication
e.POST("/auth", controllers.NewAuthController(svc).Auth)
e.POST("/create", controllers.NewCreateUserController(svc).CreateUser, strictRateLimitMiddleware)
if svc.Config.AllowAccountCreation {
e.POST("/create", controllers.NewCreateUserController(svc).CreateUser, strictRateLimitMiddleware)
}
e.POST("/invoice/:user_login", controllers.NewInvoiceController(svc).Invoice, middleware.RateLimiter(middleware.NewRateLimiterMemoryStore(rate.Limit(svc.Config.DefaultRateLimit))))

// Secured endpoints which require a Authorization token (JWT)
Expand Down
1 change: 1 addition & 0 deletions lib/service/config.go
Expand Up @@ -20,4 +20,5 @@ type Config struct {
PrometheusPort int `envconfig:"PROMETHEUS_PORT" default:"9092"`
WebhookUrl string `envconfig:"WEBHOOK_URL"`
FeeReserve bool `envconfig:"FEE_RESERVE" default:"false"`
AllowAccountCreation bool `envconfig:"ALLOW_ACCOUNT_CREATION" default:"true"`
}
4 changes: 3 additions & 1 deletion v2_endpoints.go
Expand Up @@ -9,7 +9,9 @@ import (
func RegisterV2Endpoints(svc *service.LndhubService, e *echo.Echo, secured *echo.Group, securedWithStrictRateLimit *echo.Group, strictRateLimitMiddleware echo.MiddlewareFunc) {
// TODO: v2 auth endpoint: generalized oauth token generation
// e.POST("/auth", controllers.NewAuthController(svc).Auth)
e.POST("/v2/users", v2controllers.NewCreateUserController(svc).CreateUser, strictRateLimitMiddleware)
if svc.Config.AllowAccountCreation {
e.POST("/v2/users", v2controllers.NewCreateUserController(svc).CreateUser, strictRateLimitMiddleware)
}
invoiceCtrl := v2controllers.NewInvoiceController(svc)
secured.POST("/v2/invoices", invoiceCtrl.AddInvoice)
secured.GET("/v2/invoices/incoming", invoiceCtrl.GetIncomingInvoices)
Expand Down