Skip to content

Commit

Permalink
Merge pull request #126 from getAlby/pass-app-name-as-state
Browse files Browse the repository at this point in the history
Pass client app name as state parameter to oauth connection
  • Loading branch information
bumi authored Sep 11, 2023
2 parents 6b7be74 + dcba170 commit cef8fb2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion alby.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ func (svc *AlbyOAuthService) SendPaymentSync(ctx context.Context, senderPubkey,
}

func (svc *AlbyOAuthService) AuthHandler(c echo.Context) error {
appName := c.QueryParam("c") // c - for client
// clear current session
sess, _ := session.Get(CookieName, c)
if sess.Values["user_id"] != nil {
Expand All @@ -419,7 +420,7 @@ func (svc *AlbyOAuthService) AuthHandler(c echo.Context) error {
sess.Save(c.Request(), c.Response())
}

url := svc.oauthConf.AuthCodeURL("")
url := svc.oauthConf.AuthCodeURL(appName) // pass on the appName as state
return c.Redirect(302, url)
}

Expand Down
2 changes: 1 addition & 1 deletion echo_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func (svc *Service) AppsNewHandler(c echo.Context) error {
sess.Options.Domain = svc.cfg.CookieDomain
}
sess.Save(c.Request(), c.Response())
return c.Redirect(302, fmt.Sprintf("/%s/auth", strings.ToLower(svc.cfg.LNBackendType)))
return c.Redirect(302, fmt.Sprintf("/%s/auth?c=%s", strings.ToLower(svc.cfg.LNBackendType), appName))
}

//construction to return a map with all possible permissions
Expand Down

0 comments on commit cef8fb2

Please sign in to comment.