避免使用keycloak默认登录页面,而使用项目登录页面 [英] Avoid keycloak default login page and use project login page

查看:1069
本文介绍了避免使用keycloak默认登录页面,而使用项目登录页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个angular.js Web应用程序,并正在寻找如何将keycloak集成到项目中.我已经阅读并观看了许多教程,并且看到其中大多数教程都让用户通过keycloak的默认登录页面进行登录/注册,然后将其重定向到该应用程序.

I am working on creating an angular.js web application and looking for how to integrate keycloak into the project. I have read and watched many tutorials and I see that most of them have users logging/registering through the default login page of keycloak which then redirects to the app.

我设计了自己的登录和注册页面,我想使用它.如何使用它们代替默认的keycloak.有没有可以调用的API,或者后端可以做到这一点?我还阅读了有一些用于钥匙斗篷的弹簧适配器,我可以使用它们吗?指向任何示例的任何链接都是很好的.

I have designed my own login and registration page which I want to use. How do I use them instead of keycloak default. Are there any API that I can call or may be my backend would do that? I also read there are spring adapters available for keycloak, can I use them ? Any link to any example would be good.

第二个问题是我在注册时是否可以在keycloak中添加更多用户详细信息,例如地址,地址,性别?因为我的注册页面需要这些信息.

The second question I have is while registering can I add more user details like address, dob, gender in keycloak? Because my registration page requires those information.

推荐答案

扩展API角色

POST to your/keycloak/url/auth/realms/master/protocol/openid-connect/token

含数据:

{

    client_id : 'Id_of_your_client',

    username : 'your_username',
    password : '@#$%^&',
    grant_type : "password"

}

将为您提供初始访问令牌和刷新令牌

will give you the initial access token and refresh token

使用

数据:

{

    client_id : 'Id_of_your_client',

   // client_secret : 'optional depending on the type of client',

    grant_type : "refresh_token" ,

    refresh_token : refresh_token_you_got_earlier 

}

将提供新的刷新和访问令牌.这些令牌是密钥斗篷检查授权/身份验证的内容.

will give the new refresh and access tokens .These tokens are what keycloak checks for authorization/authentication.

您可以进行自己的登录,并通过REST API将凭据发送到keycloak,一旦您拥有访问令牌,只需将其作为对clocloak保护的资源的任何正在进行的请求的标头放置为

You could make your own login and send the credentials to keycloak via a REST API and once you have the access token , just put it in the header of any ongoing request to a keycloak protected resource as

headers :{

  Authorization : 'Bearer ' +  access_token_you_got

}

这篇关于避免使用keycloak默认登录页面,而使用项目登录页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆