Skip to content

Commit

Permalink
Fixed user session initialization on login with reverse proxy header
Browse files Browse the repository at this point in the history
Gitea does not initialize user session after login using
reverse proxy header. This fixes it.

Fixes: 27dc5a1
Author-Change-Id: IB#1104925
  • Loading branch information
pboguslawski committed Oct 20, 2020
1 parent 27dc5a1 commit 45ea55d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions modules/auth/sso/reverseproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,17 @@ func (r *ReverseProxy) VerifyAuthData(ctx *macaron.Context, sess session.Store)
}
}

ctx.SetCookie("lang", user.Language, nil, setting.AppSubURL, setting.SessionConfig.Domain, setting.SessionConfig.Secure, true)

// Clear whatever CSRF has right now, force to generate a new one.
ctx.SetCookie(setting.CSRFCookieName, "", -1, setting.AppSubURL, setting.SessionConfig.Domain, setting.SessionConfig.Secure, true)

// Register last login.
user.SetLastLogin()
if err = models.UpdateUserCols(user, false, "last_login_unix"); err != nil {
log.Error(fmt.Sprintf("VerifyAuthData: error updating user last login time [user: %d]", user.ID))
}

return user
}

Expand Down

0 comments on commit 45ea55d

Please sign in to comment.