首页 > 解决方案 > 如何仅在 redmine 应用程序中允许某些用户远程登录(不在办公室 IP)?

问题描述

有没有办法允许一组用户从任何 IP 访问 redmine,而其他用户只能从一组 IP 登录

标签: redmine

解决方案


目前(Redmine 4.1),没有这样的功能,但是它是一个开源软件,欢迎您在他们的跟踪器上请求这样的功能或开发自己的代码。因此,如果您很快需要解决方案,则有几种选择:

方法 1: 您可以通过让远程用户通过 VPN 连接来解决问题,这将使他们拥有来自给定 IP 集的 IP。

方法2: 开发特殊的认证插件,让您能够选择IP的用户可以登录。

方法3: 修改Redmine的核心文件和数据库或通过修改/mode/user.rb文件创建包含用户批准IP地址或范围的自定义字段

所以你应该添加如下内容:

return nil unless IPAddr.new(user.permitted_ip).include? request.env['HTTP_X_REAL_IP'] || request.env['REMOTE_ADDR']

 # Returns the user that matches provided login and password, or nil
  def self.try_to_login(login, password, active_only=true)
    login = login.to_s.strip
    password = password.to_s

    # Make sure no one can sign in with an empty login or password
    return nil if login.empty? || password.empty?
    user = find_by_login(login)
    if user
    # user is already in local database
      return nil unless user.check_password?(password)
      return nil if !user.active? && active_only

(如果您不使用外部身份验证源,上面的代码应该可以工作)


推荐阅读