Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Add Redis dependency and check user existence with Redis #146

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion server/core/hydra.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
openapi "github.com/ory/hydra-client-go/v2"
"github.com/pquerna/otp"
"github.com/pquerna/otp/totp"
"github.com/redis/go-redis/v9"
"github.com/spf13/viper"
"golang.org/x/text/cases"
"golang.org/x/text/language"
Expand Down Expand Up @@ -1640,6 +1641,13 @@ func (a *ApiConfig) logFailedLoginAndRedirect(auth *AuthState) {

// runLuaFilterAndPost filters and executes post-action Lua scripts based on the given post-2FA authentication result.
func runLuaFilterAndPost(ctx *gin.Context, auth *AuthState, authResult global.AuthResult) global.AuthResult {
userFound, err := auth.userExists()
if err != nil {
if !stderrors.Is(err, redis.Nil) {
level.Error(log.Logger).Log(global.LogKeyGUID, auth.GUID, global.LogKeyError, err)
}
}

passDBResult := &PassDBResult{
Authenticated: func() bool {
if authResult == global.AuthResultOK {
Expand All @@ -1648,7 +1656,7 @@ func runLuaFilterAndPost(ctx *gin.Context, auth *AuthState, authResult global.Au

return false
}(),
UserFound: auth.UserFound,
UserFound: userFound,
}

authResult = auth.filterLua(passDBResult, ctx)
Expand Down
Loading