-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ensure auth redirects throw an error (#561)
* fix: ensure auth redirects throw an error * fix: add line removed by linter
- Loading branch information
1 parent
3b1232c
commit f4be542
Showing
11 changed files
with
72 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 19 additions & 3 deletions
22
api/v1/server/authn/redirect.go → ...v1/server/middleware/redirect/redirect.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,31 @@ | ||
package authn | ||
package redirect | ||
|
||
import ( | ||
"errors" | ||
|
||
"github.com/labstack/echo/v4" | ||
"github.com/rs/zerolog" | ||
) | ||
|
||
var ErrRedirect = errors.New("redirecting") | ||
|
||
func GetRedirectWithError(ctx echo.Context, l *zerolog.Logger, internalErr error, userErr string) error { | ||
l.Err(internalErr).Msgf("redirecting with error") | ||
return ctx.Redirect(302, "/auth/login?error="+userErr) | ||
err := ctx.Redirect(302, "/auth/login?error="+userErr) | ||
|
||
if err != nil { | ||
return err | ||
} | ||
|
||
return ErrRedirect | ||
} | ||
|
||
func GetRedirectNoError(ctx echo.Context, serverURL string) error { | ||
return ctx.Redirect(302, serverURL) | ||
err := ctx.Redirect(302, serverURL) | ||
|
||
if err != nil { | ||
return err | ||
} | ||
|
||
return ErrRedirect | ||
} |