简体   繁体   English

在使用Torii进行身份验证后,Ember Simple Auth会立即使会话无效

[英]Ember Simple Auth immediately invalidates the session after authenticating with Torii

I am trying to set up Torii with my own OAuth flow and Ember-Simple-Auth. 我正在尝试使用我自己的OAuth流和Ember-Simple-Auth设置Torii。 I can get a successful authentication event, but immediately after I authenticate, the invalidateSession trigger is fired causing my session to end. 我可以获得成功的身份验证事件,但在我进行身份验证后立即触发invalidateSession触发器,导致我的会话结束。 I can see this by intercepting sessionInvalidated() in /app/routes/application.js (which has the ApplicationRouteMixin ). 我可以通过截取/app/routes/application.js (具有ApplicationRouteMixin )中的sessionInvalidated()来看到这一点。

Have any of you come across this? 有没有人遇到过这个? Is there something peculiar that would cause an immediate session validation? 有什么特殊的东西会导致立即会话验证吗? Any advice would be greatly appreciated. 任何建议将不胜感激。

EDIT: I think it has to do with the torii popup code because the first return works, but the second doesn't. 编辑:我认为它与torii弹出代码有关,因为第一次返回工作,但第二次没有。 Any thoughts? 有什么想法吗?

import OAuth2 from 'torii/providers/oauth2-code';
import {configurable} from 'torii/configuration';

export default OAuth2.extend({
  name: 'api',
  init() { this.set('clientID', this.get('apiKey')); },

  baseUrl: configurable('baseUrl'),

  redirectUri: configurable('redirectUri'),
  responseParams: ['access_token', 'user_id', 'first_name'],

  requiredUrlParams: ['client_id', 'redirect_uri', 'response_type'],

  open() {
    let name        = this.get('name');
    let url         = this.buildUrl();
    let redirectUri = this.get('redirectUri');
    let responseParams = this.get('responseParams');

    // this return works
    return { 'yes' : 'no' }

    // this return causes the immediate invalidation
    return this.get('popup').open(url, responseParams).then((authData) => {
      var missingResponseParams = [];

      responseParams.forEach(function(param){
        if (authData[param] === undefined) {
          missingResponseParams.push(param);
        }
      });

      if (missingResponseParams.length){
        throw new Error("The response from the provider is missing " +
              "these required response params: " + missingResponseParams.join(', '));
      }

      return {
        access_token: authData.access_token,
        first_name: authData.first_name,
        user_id: authData.user_id,
        provider: name,
        redirectUri: redirectUri
      };
    });
  }
});

真正的答案是使用这个分支: https//github.com/simplabs/ember-simple-auth/pull/931 (希望它很快就会成为主人)。

You might have this.get('session').invalidate(); 你可能有this.get('session').invalidate(); somewhere. 某处。 Probably in one of your controllers action properties. 可能在您的一个控制器动作属性中。 You would usually put that in your actions for your logout button. 您通常会将其放入您的注销按钮的操作中。 Maybe you copy and pasted it by accident. 也许你偶然复制并粘贴它。 If you post some code I might be able to look at it some more 如果你发布一些代码,我可能会再看一些

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM