Ember.js 当登录页面位于另一个系统上时使用ember simple auth
登录到我们的应用程序的页面是托管在另一台机器上的jsp。我已通过允许调用Ember.js 当登录页面位于另一个系统上时使用ember simple auth,ember.js,ember-simple-auth,Ember.js,Ember Simple Auth,登录到我们的应用程序的页面是托管在另一台机器上的jsp。我已通过允许调用window.location.replace来修改authenticated route mixin,成功地使请求触发到此计算机,如果路由以http开头 beforeModel(transition) { if (!this.get('session.isAuthenticated')) { Ember.assert('The route configured as Configuration.au
window.location.replace
来修改authenticated route mixin
,成功地使请求触发到此计算机,如果路由以http开头
beforeModel(transition) {
if (!this.get('session.isAuthenticated')) {
Ember.assert('The route configured as Configuration.authenticationRoute cannot implement the AuthenticatedRouteMixin mixin as that leads to an infinite transitioning loop!', this.get('routeName') !== Configuration.authenticationRoute);
transition.abort();
this.set('session.attemptedTransition', transition);
debugger;
if (Configuration.authenticationRoute.startsWith('http')) {
window.location.replace(Configuration.authenticationRoute);
} else {
this.transitionTo(Configuration.authenticationRoute);
}
} else {
return this._super(...arguments);
}
}
这是可行的,但当我被重定向回我的应用程序时,ember simple auth认为我不再登录,并将我重定向回远程机器,然后以无限循环的方式将我发送回应用程序
显然,我需要设置一些东西,让ember simple auth知道它实际上已登录。为什么它不自动地这样做?我做错了什么
我对oAuth很陌生,所以我可能会错过一些基本的设置
这是网址
ENV['ember-simple-auth'] = {
authenticationRoute: 'https://our-server.com/opensso/oauth2/authorize?client_id=test-client-1&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A4200%2Fsecure'
};
与其修改
AuthenticatedRouteMixin
,我建议您在验证器中处理特定于应用程序的登录,验证器是一个关键配置原语
据我所知,在首次加载应用程序并检查用户是否经过身份验证时,Ember Simple Auth将使用还原
方法,该方法定义为Authenticator API的一部分
您可以从restore
返回一个承诺,该承诺将解析或拒绝以指示用户是否经过身份验证。如何检查这一点是auth系统的一个实现细节
我不知道您是如何在客户端上存储凭据的(如果您能提供更多详细信息,那就太好了),但下面是一个使用cookies进行身份验证的示例流程:
恢复
会话restore
向Java服务器上的安全“虚拟”资源发出一个简单的AJAX请求,并检查它是否返回200或401李>
restore
返回的承诺中拒绝李>
AuthenticatedRouteMixin
——而是在身份验证路由中使用beforeModel
钩子将用户发送到JSP登录页面restore
restore
再次ping您的Java服务器,获得200分(感谢cookie),从而解决其承诺