auth fixes

middleware handles logout
This commit is contained in:
jay brown
2025-04-15 12:04:54 -07:00
parent 1bbfa95a40
commit bf98a0971f
5 changed files with 59 additions and 29 deletions
+11 -6
View File
@@ -6,6 +6,9 @@ import (
"github.com/labstack/echo/v4"
)
// All of the auth related handlers that are called from the
// generated swagger code.
func (s *Controllers) Login(ctx echo.Context) error {
// Redirect to Cognito login page
// This is a placeholder implementation - you'll need to implement the actual Cognito redirect logic
@@ -16,15 +19,17 @@ func (s *Controllers) Login(ctx echo.Context) error {
func (s *Controllers) LoginCallback(ctx echo.Context, params LoginCallbackParams) error {
// Handle OAuth2 callback
// This is a placeholder implementation - you'll need to implement the actual token exchange logic
redirectURL := "https://doczy.com" // Replace with your actual redirect URL
return ctx.Redirect(http.StatusFound, redirectURL)
//redirectURL := "https://doczy.com" // Replace with your actual redirect URL
//return ctx.Redirect(http.StatusFound, redirectURL)
return ctx.JSON(http.StatusOK, map[string]string{"message": "Login callback is a no op since its handled by the middleware."})
}
// Logout is called by the swagger generated code for the logout endpoint.
func (s *Controllers) Logout(ctx echo.Context) error {
// Handle logout
// This is a placeholder implementation - you'll need to implement the actual logout logic
logoutURL := "https://doczy.auth.us-east-1.amazoncognito.com/logout"
return ctx.Redirect(http.StatusFound, logoutURL)
// the middleware will have already removed the auth cookie
// so we can just redirect to the home page after logging out.
return ctx.Redirect(http.StatusFound, "/home")
}
func (s *Controllers) GetHomePage(ctx echo.Context) error {