Zammad: 使用https时,Omniauth OAuth redirect_uri_mismatch

创建于 2017-02-03  ·  9评论  ·  资料来源: zammad/zammad

资讯:

  • 使用的Zammad版本:1.2.0
  • 作业系统:Ubuntu 16.04

预期行为:

  • 在github oauth的回调URL中使用https

实际行为:

  • 在github oauth的回调URL中使用http

重现行为的步骤:

  • 将http类型设置为https
  • 登出
  • 在登录页面上使用github授权

已知的解决方法

在nginx中将http重定向到https并在github oauth应用设置中使用URL的HTTP版本作为回调URL

(与#647有关)

最有用的评论

@schurig-我想我明白了! 您是否正在运行NGINX安装? 如果是这样,请更新您的配置并添加以下两行:

        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header X-Forwarded-Port 443;

就像截图中一样:
bildschirmfoto 2017-02-17 um 16 56 54

重新启动您的NGINX和Zammad,让我知道。 Apache应该是以下几行:

RequestHeader set Host zammad.example.com
RequestHeader set X-Forwarded-Proto https
RequestHeader set X-Forwarded-Port 443

作为记录:我通过一个初始化程序转储了rack.envs,覆盖了新的Rails初始化程序config/initializers/debug_ssl.rb的Omniauth ssl检测:

Rails.application.config.to_prepare do              # to_prepare ensures that the monkey patching happens before the first request
  OmniAuth::Strategy.class_eval do                  # reopen the class
    protected

    def ssl?                                        # redefine the ssl? method
      # DEBUG/CUSTOMIZATION
      File.write('/tmp/omniauth.log', request.env.inspect)
      # DEBUG/CUSTOMIZATION

      request.env['HTTPS'] == 'on' ||
        request.env['HTTP_X_FORWARDED_SSL'] == 'on' ||
        request.env['HTTP_X_FORWARDED_SCHEME'] == 'https' ||
        (request.env['HTTP_X_FORWARDED_PROTO'] && request.env['HTTP_X_FORWARDED_PROTO'].split(',')[0] == 'https') ||
        request.env['rack.url_scheme'] == 'https'
    end
  end
end

并且没有设置任何检查的变量。

所有9条评论

它为我工作。

请记住,回调URL实际上是在github而非Zammad上设置的。

这里:

screenshot_3

谢谢@ madd86

@ madd86这就是我所做的。 另一件事只是解决方法,因此它可以工作

@schurig -ups。 点击按钮以early

我分析了行为,可以重现您遇到的问题。 遗憾的是,它不在Zammad范围内(由Ominauth完成),因此我们无法提供直接修复。 但是,我们将对其进行进一步分析,以找到最佳解决方案以使其正常工作。

繁殖方法:

  • 使用反向代理(例如NGINX)运行https Zammad实例
  • 在Github / Zammad中注册Github OAuth2应用程序
  • 尝试登录Zammad,重定向到Github页面
  • 请注意,redirect_url GET参数实际上是带有http而不是https的Zammad URL

当前状态:
redirect_url来自这里:
https://github.com/intridea/omniauth-github/blob/master/lib/omniauth/strategies/github.rb#L5
https://github.com/intridea/omniauth-oauth2/blob/master/lib/omniauth/strategies/oauth2.rb#L47
https://github.com/omniauth/omniauth/blob/8098855f6b52f5f1aecbd700e7068f204adddfdd/lib/omniauth/strategy.rb#L435
https://github.com/omniauth/omniauth/blob/8098855f6b52f5f1aecbd700e7068f204adddfdd/lib/omniauth/strategy.rb#L428
https://github.com/omniauth/omniauth/blob/8098855f6b52f5f1aecbd700e7068f204adddfdd/lib/omniauth/strategy.rb#L503

似乎其中一些RACK ENV设置不正确。 应该检查是否可以通过NGINX conf来影响它,或者是否必须在Rails上下文中以某种方式来做到这一点。

@schurig-我想我明白了! 您是否正在运行NGINX安装? 如果是这样,请更新您的配置并添加以下两行:

        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header X-Forwarded-Port 443;

就像截图中一样:
bildschirmfoto 2017-02-17 um 16 56 54

重新启动您的NGINX和Zammad,让我知道。 Apache应该是以下几行:

RequestHeader set Host zammad.example.com
RequestHeader set X-Forwarded-Proto https
RequestHeader set X-Forwarded-Port 443

作为记录:我通过一个初始化程序转储了rack.envs,覆盖了新的Rails初始化程序config/initializers/debug_ssl.rb的Omniauth ssl检测:

Rails.application.config.to_prepare do              # to_prepare ensures that the monkey patching happens before the first request
  OmniAuth::Strategy.class_eval do                  # reopen the class
    protected

    def ssl?                                        # redefine the ssl? method
      # DEBUG/CUSTOMIZATION
      File.write('/tmp/omniauth.log', request.env.inspect)
      # DEBUG/CUSTOMIZATION

      request.env['HTTPS'] == 'on' ||
        request.env['HTTP_X_FORWARDED_SSL'] == 'on' ||
        request.env['HTTP_X_FORWARDED_SCHEME'] == 'https' ||
        (request.env['HTTP_X_FORWARDED_PROTO'] && request.env['HTTP_X_FORWARDED_PROTO'].split(',')[0] == 'https') ||
        request.env['rack.url_scheme'] == 'https'
    end
  end
end

并且没有设置任何检查的变量。

这就是问题所在! 谢谢!! ❤❤️

感谢您的反馈! 提交正在进行中。 🚀直至下期。

试试这个答案,它与我合作
https://stackoverflow.com/a/41466634/1770571

@salmagomaa这不能解决问题,并且是Zammad中的错误。
请尽量不要回收帖子-该问题已得到解决。

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

adonno picture adonno  ·  3评论

KoJie picture KoJie  ·  3评论

strey picture strey  ·  3评论

infestdead picture infestdead  ·  3评论

BigAndini picture BigAndini  ·  3评论