Skip to content

Commit

Permalink
Fix: Handle errors and abort on temp auth failure
Browse files Browse the repository at this point in the history
Added an error handler for unknown causes in `hydra.go` to ensure consistent error handling. In `http.go`, introduced logic to manage temporary authentication failures, calling specific functions and aborting the context to prevent further processing.

Signed-off-by: Christian Roessner <c@roessner.co>
  • Loading branch information
Christian Roessner committed Oct 21, 2024
1 parent 9f520c0 commit ab7c23b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions server/core/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,11 @@ func protectEndpointMiddleware() gin.HandlerFunc {
case global.AuthResultOK:
case global.AuthResultFail:
case global.AuthResultTempFail:
auth.postLuaAction(&PassDBResult{})
auth.authTempFail(ctx, global.TempFailDefault)
ctx.Abort()

return
case global.AuthResultEmptyUsername:
case global.AuthResultEmptyPassword:
}
Expand Down
1 change: 1 addition & 0 deletions server/core/hydra.go
Original file line number Diff line number Diff line change
Expand Up @@ -1715,6 +1715,7 @@ func loginPOSTHandler(ctx *gin.Context) {

apiConfig.logFailedLoginAndRedirect(auth)
default:
handleErr(ctx, errors.ErrUnknownCause)
ctx.AbortWithStatus(http.StatusInternalServerError)

return
Expand Down

0 comments on commit ab7c23b

Please sign in to comment.