在Auth0规则

时间:2018-01-24 08:57:57

标签: auth0

我想将自定义标识符传递到Auth0授权端点。该值是一个标识数据库中用户的guid。

我在Auth0.js授权函数的state参数中传递它。

    this.auth0.authorize({
        initial_screen: 'signUp',
        lead_guid: leadGuid,
        state: leadGuid
    });

我可以在规则中看到state的值,但它已被编码。文档表明它是base64但它不解码。

在规则之前,在托管登录页面中,如果我抓住配置,我会得到以下值:

  "extraParams": {
    "initial_screen": "signUp",
    "lead_guid": "33071cf4-17c4-44fe-b573-fc86dfa7e413",
    "state": "ll8tw5lkrSELOf1cnTygwBlewWrRK_Zo"
  },
  "internalOptions": {
    "initial_screen": "signUp",
    "lead_guid": "33071cf4-17c4-44fe-b573-fc86dfa7e413",
    "state": "ll8tw5lkrSELOf1cnTygwBlewWrRK_Zo",
  },

lead_guid即将发送到extraParamsinternalOptions,但状态值未设置。

如果我将对象中的值设置为以Auth参数传递给Lock:

if (leadGuid) {
  config.extraParams.state = leadGuid;
  config.internalOptions.state = leadGuid;
}

var lock = new Auth0Lock(config.clientID, config.auth0Domain, {
  auth: {
    redirectUrl: config.callbackURL,
    responseType: (config.internalOptions || {}).response_type ||
      config.callbackOnLocationHash ? 'token' : 'code',
    params: config.internalOptions
  },

当我尝试注册时,我收到此错误:

  

您可能已按下后退按钮,在登录时刷新,打开   因为我们,登录对话框太多,或者存在cookie问题   无法找到你的会话。尝试从应用程序再次登录   如果问题仍然存在,请联系管理员。

如果我使用自定义状态初始化auto0.WebAuth:

auth0 = new auth0.WebAuth({
    clientID: environment.auth0.clientId,
    domain: environment.auth0.domain,
    responseType: 'token id_token',
    audience: environment.auth0.audience,
    redirectUri: environment.auth0.interactiveRedirectUri,
    scope: 'openid profile email',
    state: 'anthony'
});

然后获取AuthResult状态,我可以看到我的自定义值。规则记录的值似乎是内部Auth0状态。

Auth0规则是否有可能以明文形式获取状态值,以便将其传递给webhook?

1 个答案:

答案 0 :(得分:0)

将通话更改为

this.auth0.authorize({
    initial_screen: 'signUp',
    lead_guid: leadGuid,
});

使用lead_guid

在Auth0规则中提供context.request.query.lead_guid