Angular 4 Keycloak

时间:2017-10-16 11:57:02

标签: angular keycloak

我在Angular 4项目中实现了Keycloak身份验证服务。我使用服务登录,注销等。

keycloak.json

<sys/queue.h>

我的keycloak.service.ts

{
  "realm": "my-front",
  "auth-server-url": "http://127.0.0.1:8180/auth",
  "ssl-required": "external",
  "resource": "app-frontend",
  "public-client": true
}

所以,当我尝试访问我的网址http://localhost:4200时,我获得了keycloak的登录页面,但是当我尝试连接时,我得到一个重新加载页面,如: export class KeycloakService { static auth : any = {}; static init() : Promise<any>{ let keycloakAuth : any = new Keycloak('../assets/data/keycloak.json'); KeycloakService.auth.loggedIn = false; return new Promise((resolve, reject) => { keycloakAuth.init({ onLoad: 'login-required'}) .success(() => { alert(); KeycloakService.auth.loggedIn = true; KeycloakService.auth.authz = keycloakAuth; KeycloakService.auth.logoutUrl = keycloakAuth.createLogoutUrl(); resolve(null); }) .error(() => { reject(null); }); }); } getToken() : Promise<string> { alert(); return new Promise<string> ((resolve, reject) => { if(KeycloakService.auth.authz.token) { KeycloakService.auth.authz.updateToken(5) .success(function() { resolve(<string> KeycloakService.auth.authz.token); }) .error(function() { reject('Failed to refresh token'); }) } }) } }

如何显示我的主页?

0 个答案:

没有答案