【问题标题】:FeathersJS: how to debug OAuth2 authentication process?FeathersJS:如何调试 OAuth2 身份验证过程?
【发布时间】:2019-11-24 07:18:23
【问题描述】:

我已经成功地在 FeathersJS 应用程序中使用 OAuth2 对 Facebook、Github 等进行身份验证...现在,我正在尝试使用它通过 WordPress OAuth Server 对 Wordpress 服务器进行身份验证。我已经对其进行了配置并将所有配置参数设置为我认为正确的值:

...
const OAuth2Strategy = require('passport-oauth2').Strategy;

...
app.configure(oauth2({
    name: 'wordpress',
    Strategy: OAuth2Strategy,
    authorizationURL: 'https://192.168.1.86/wp-content/plugins/miniorange-oauth-20-server/web/index.php/moserver/authorize',
    tokenURL: 'https://192.168.1.86/wp-content/plugins/miniorange-oauth-20-server/web/index.php/moserver/token',
    successRedirect: '/',
    failureRedirect: '/',
    clientID: 'CLIENT_ID',
    clientSecret: 'CLIENT_SECRET'
  }));

但 FeathersJS 服务器总是无法通过身份验证。问题是我看不到任何关于它为什么失败的信息,设置环境变量 DEBUG="feathers-authentication*" 后我得到的唯一信息是:

  feathers-authentication:express:expose-headers Exposing Express headers to hooks and services +36s
  feathers-authentication:express:expose-cookies Exposing Express cookies to hooks and services undefined +36s
  feathers-authentication:express:expose-headers Exposing Express headers to hooks and services +127ms
  feathers-authentication:express:expose-cookies Exposing Express cookies to hooks and services undefined +127ms
  feathers-authentication:middleware:failure-redirect Clearing old 'feathers-jwt' cookie +37s
  feathers-authentication:middleware:failure-redirect Redirecting to / after failed authentication. +0ms

有谁知道如何获取有关 OAuth2 身份验证失败原因的更多信息,以便我可以检查哪个配置错误?

谢谢!

【问题讨论】:

    标签: oauth-2.0 feathersjs feathers-authentication


    【解决方案1】:

    我终于知道出了什么问题...我尝试将 DEBUG 设置为 "passport" (DEBUG="passport"),然后我得到了控制台上有很多信息。我检查了该信息,发现我的问题是我为使用本地 Wordpress 服务器进行测试而颁发的自签名证书。

    对于任何需要它的人,为了避免 Passport(或其他)抱怨使用自签名证书,我添加了以下行:

    if ('development' == app.get('env')) {
      process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
    }
    

    在我最初的 .js 文件中(在我的例子中是 index.js)。这可以避免任何 SSL 调用由于自签名证书而失败,而只是一个警告。

    【讨论】:

      猜你喜欢
      • 2019-04-18
      • 2020-11-14
      • 1970-01-01
      • 2019-08-20
      • 1970-01-01
      • 2019-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多