如何集成Ember.JS和Keycloak SSO系统 [英] How to integrate Ember.JS and Keycloak SSO system
问题描述
我的问题很简单:是否有人知道如何集成Ember.JS和Keycloak(SSO系统)?我们目前使用Keycloak JS Bower库( https://github.com/keycloak/keycloak)遇到问题-js-bower )将用户重定向到Keycloak自己的登录页面,并通常将Ember.JS与Keycloak集成在一起.我们的问题是:
My question is quite simple : does anybody know how to integrate Ember.JS and Keycloak (the SSO system) ? We currently face a problem using the Keycloak JS Bower library (https://github.com/keycloak/keycloak-js-bower) to redirect users to Keycloak own login page, and to generally integrate Ember.JS with Keycloak. Our problems are :
重新加载页面时重新加载页面,
Double page reload on page reloading,
登录到Ember App的401未经授权的HTTP代码.
401 unauthorized HTTP code on login to the Ember App.
感谢您的(宝贵)支持.
Thanks for your (precious) support.
推荐答案
您可以使用脚本JS:
检查密钥斗篷中是否包含脚本:https://yourdoamin.com/auth/js/keycloak.js
You can use script JS:
Check that you have script in your keycloak: https://yourdoamin.com/auth/js/keycloak.js
如果有,请将此代码添加到您的登录页面:
If you have, add this code to your login page:
<head>
<script src="https://yourdoamin.com/auth/js/keycloak.js"></script>
<script>
var keycloak = Keycloak({
"realm": "relam_name",
"url": "https://yourdomain.com/auth",
"ssl-required": "external",
"resource": "client_id",
"verify-token-audience": true,
"credentials": {
"secret": "secret_code"
},
"use-resource-role-mappings": true,
"confidential-port": 0,
"policy-enforcer": {},
"onLoad":'login-required',
"clientId": "client_id"
});
var keycloak = Keycloak();
keycloak.init().success(function(authenticated) {
console.log(keycloak);
alert(authenticated ? 'authenticated' : 'not authenticated');
}).error(function() {
alert('failed to initialize');
});
</script>
</head>
在console.log(keycloak);
密钥库返回令牌和有关用户的其他信息中.
In console.log(keycloak);
Keycloak return token and other information about user.
更多信息:
用于获取当前登录用户的Keycloak JavaScript API
使用Keycloak和React进行MicroProfile JWT身份验证
这篇关于如何集成Ember.JS和Keycloak SSO系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!