Skip to content

Commit

Permalink
fix: do not require jwt for oauth callback, disable service worker (#465
Browse files Browse the repository at this point in the history
)

* fix: do not require jwt for oauth callback, disable service worker

* fix: remove debug log

* fix: comment
  • Loading branch information
rolznz authored Aug 13, 2024
1 parent d08b1e2 commit 774c45b
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 54 deletions.
5 changes: 2 additions & 3 deletions frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export default defineConfig(({ command }) => ({
tsconfigPaths(),
VitePWA({
registerType: "autoUpdate",
// disable service worker - Alby Hub cannot be used offline (and also breaks oauth callback)
injectRegister: false,
includeAssets: [
"favicon.ico",
"robots.txt",
Expand Down Expand Up @@ -41,9 +43,6 @@ export default defineConfig(({ command }) => ({
theme_color: "#000000",
background_color: "#ffffff",
},
workbox: {
globPatterns: ["**/*.{js,css,html,png,svg,ico}"],
},
}),
...(command === "serve" ? [insertDevCSPPlugin] : []),
],
Expand Down
18 changes: 9 additions & 9 deletions http/alby_http_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ func NewAlbyHttpService(svc service.Service, albyOAuthSvc alby.AlbyOAuthService,
}
}

func (albyHttpSvc *AlbyHttpService) RegisterSharedRoutes(r *echo.Group) {
r.GET("/api/alby/callback", albyHttpSvc.albyCallbackHandler)
r.GET("/api/alby/me", albyHttpSvc.albyMeHandler)
r.GET("/api/alby/balance", albyHttpSvc.albyBalanceHandler)
r.POST("/api/alby/pay", albyHttpSvc.albyPayHandler)
r.POST("/api/alby/drain", albyHttpSvc.albyDrainHandler)
r.POST("/api/alby/link-account", albyHttpSvc.albyLinkAccountHandler)
r.POST("/api/alby/auto-channel", albyHttpSvc.autoChannelHandler)
r.POST("/api/alby/unlink-account", albyHttpSvc.unlinkHandler)
func (albyHttpSvc *AlbyHttpService) RegisterSharedRoutes(restrictedGroup *echo.Group, e *echo.Echo) {
e.GET("/api/alby/callback", albyHttpSvc.albyCallbackHandler)
restrictedGroup.GET("/api/alby/me", albyHttpSvc.albyMeHandler)
restrictedGroup.GET("/api/alby/balance", albyHttpSvc.albyBalanceHandler)
restrictedGroup.POST("/api/alby/pay", albyHttpSvc.albyPayHandler)
restrictedGroup.POST("/api/alby/drain", albyHttpSvc.albyDrainHandler)
restrictedGroup.POST("/api/alby/link-account", albyHttpSvc.albyLinkAccountHandler)
restrictedGroup.POST("/api/alby/auto-channel", albyHttpSvc.autoChannelHandler)
restrictedGroup.POST("/api/alby/unlink-account", albyHttpSvc.unlinkHandler)
}

func (albyHttpSvc *AlbyHttpService) autoChannelHandler(c echo.Context) error {
Expand Down
84 changes: 42 additions & 42 deletions http/http_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,48 +107,48 @@ func (httpSvc *HttpService) RegisterSharedRoutes(e *echo.Echo) {
},
SigningKey: []byte(httpSvc.cfg.GetJWTSecret()),
}
r := e.Group("")
r.Use(echojwt.WithConfig(jwtConfig))

r.GET("/api/apps", httpSvc.appsListHandler)
r.GET("/api/apps/:pubkey", httpSvc.appsShowHandler)
r.PATCH("/api/apps/:pubkey", httpSvc.appsUpdateHandler)
r.DELETE("/api/apps/:pubkey", httpSvc.appsDeleteHandler)
r.POST("/api/apps", httpSvc.appsCreateHandler)
r.POST("/api/mnemonic", httpSvc.mnemonicHandler)
r.PATCH("/api/backup-reminder", httpSvc.backupReminderHandler)
r.GET("/api/channels", httpSvc.channelsListHandler)
r.POST("/api/channels", httpSvc.openChannelHandler)
r.GET("/api/channels/suggestions", httpSvc.channelPeerSuggestionsHandler)
r.POST("/api/lsp-orders", httpSvc.newInstantChannelInvoiceHandler)
r.GET("/api/node/connection-info", httpSvc.nodeConnectionInfoHandler)
r.GET("/api/node/status", httpSvc.nodeStatusHandler)
r.GET("/api/node/network-graph", httpSvc.nodeNetworkGraphHandler)
r.GET("/api/peers", httpSvc.listPeers)
r.POST("/api/peers", httpSvc.connectPeerHandler)
r.DELETE("/api/peers/:peerId", httpSvc.disconnectPeerHandler)
r.DELETE("/api/peers/:peerId/channels/:channelId", httpSvc.closeChannelHandler)
r.PATCH("/api/peers/:peerId/channels/:channelId", httpSvc.updateChannelHandler)
r.GET("/api/wallet/address", httpSvc.onchainAddressHandler)
r.POST("/api/wallet/new-address", httpSvc.newOnchainAddressHandler)
r.POST("/api/wallet/redeem-onchain-funds", httpSvc.redeemOnchainFundsHandler)
r.POST("/api/wallet/sign-message", httpSvc.signMessageHandler)
r.POST("/api/wallet/sync", httpSvc.walletSyncHandler)
r.GET("/api/wallet/capabilities", httpSvc.capabilitiesHandler)
r.POST("/api/payments/:invoice", httpSvc.sendPaymentHandler)
r.POST("/api/invoices", httpSvc.makeInvoiceHandler)
r.GET("/api/transactions", httpSvc.listTransactionsHandler)
r.GET("/api/transactions/:paymentHash", httpSvc.lookupTransactionHandler)
r.GET("/api/balances", httpSvc.balancesHandler)
r.POST("/api/reset-router", httpSvc.resetRouterHandler)
r.POST("/api/stop", httpSvc.stopHandler)
r.GET("/api/mempool", httpSvc.mempoolApiHandler)
r.POST("/api/send-payment-probes", httpSvc.sendPaymentProbesHandler)
r.POST("/api/send-spontaneous-payment-probes", httpSvc.sendSpontaneousPaymentProbesHandler)
r.GET("/api/log/:type", httpSvc.getLogOutputHandler)
r.POST("/api/backup", httpSvc.createBackupHandler)

httpSvc.albyHttpSvc.RegisterSharedRoutes(r)
restrictedGroup := e.Group("")
restrictedGroup.Use(echojwt.WithConfig(jwtConfig))

restrictedGroup.GET("/api/apps", httpSvc.appsListHandler)
restrictedGroup.GET("/api/apps/:pubkey", httpSvc.appsShowHandler)
restrictedGroup.PATCH("/api/apps/:pubkey", httpSvc.appsUpdateHandler)
restrictedGroup.DELETE("/api/apps/:pubkey", httpSvc.appsDeleteHandler)
restrictedGroup.POST("/api/apps", httpSvc.appsCreateHandler)
restrictedGroup.POST("/api/mnemonic", httpSvc.mnemonicHandler)
restrictedGroup.PATCH("/api/backup-reminder", httpSvc.backupReminderHandler)
restrictedGroup.GET("/api/channels", httpSvc.channelsListHandler)
restrictedGroup.POST("/api/channels", httpSvc.openChannelHandler)
restrictedGroup.GET("/api/channels/suggestions", httpSvc.channelPeerSuggestionsHandler)
restrictedGroup.POST("/api/lsp-orders", httpSvc.newInstantChannelInvoiceHandler)
restrictedGroup.GET("/api/node/connection-info", httpSvc.nodeConnectionInfoHandler)
restrictedGroup.GET("/api/node/status", httpSvc.nodeStatusHandler)
restrictedGroup.GET("/api/node/network-graph", httpSvc.nodeNetworkGraphHandler)
restrictedGroup.GET("/api/peers", httpSvc.listPeers)
restrictedGroup.POST("/api/peers", httpSvc.connectPeerHandler)
restrictedGroup.DELETE("/api/peers/:peerId", httpSvc.disconnectPeerHandler)
restrictedGroup.DELETE("/api/peers/:peerId/channels/:channelId", httpSvc.closeChannelHandler)
restrictedGroup.PATCH("/api/peers/:peerId/channels/:channelId", httpSvc.updateChannelHandler)
restrictedGroup.GET("/api/wallet/address", httpSvc.onchainAddressHandler)
restrictedGroup.POST("/api/wallet/new-address", httpSvc.newOnchainAddressHandler)
restrictedGroup.POST("/api/wallet/redeem-onchain-funds", httpSvc.redeemOnchainFundsHandler)
restrictedGroup.POST("/api/wallet/sign-message", httpSvc.signMessageHandler)
restrictedGroup.POST("/api/wallet/sync", httpSvc.walletSyncHandler)
restrictedGroup.GET("/api/wallet/capabilities", httpSvc.capabilitiesHandler)
restrictedGroup.POST("/api/payments/:invoice", httpSvc.sendPaymentHandler)
restrictedGroup.POST("/api/invoices", httpSvc.makeInvoiceHandler)
restrictedGroup.GET("/api/transactions", httpSvc.listTransactionsHandler)
restrictedGroup.GET("/api/transactions/:paymentHash", httpSvc.lookupTransactionHandler)
restrictedGroup.GET("/api/balances", httpSvc.balancesHandler)
restrictedGroup.POST("/api/reset-router", httpSvc.resetRouterHandler)
restrictedGroup.POST("/api/stop", httpSvc.stopHandler)
restrictedGroup.GET("/api/mempool", httpSvc.mempoolApiHandler)
restrictedGroup.POST("/api/send-payment-probes", httpSvc.sendPaymentProbesHandler)
restrictedGroup.POST("/api/send-spontaneous-payment-probes", httpSvc.sendSpontaneousPaymentProbesHandler)
restrictedGroup.GET("/api/log/:type", httpSvc.getLogOutputHandler)
restrictedGroup.POST("/api/backup", httpSvc.createBackupHandler)

httpSvc.albyHttpSvc.RegisterSharedRoutes(restrictedGroup, e)
}

func (httpSvc *HttpService) infoHandler(c echo.Context) error {
Expand Down

0 comments on commit 774c45b

Please sign in to comment.