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

查看:77
本文介绍了避免使用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 或者我的后端会这样做?我还读到有可用于 keycloak 的弹簧适配器,我可以使用它们吗?任何示例的任何链接都会很好.

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 到您的/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 

}

将提供新的刷新和访问令牌.这些令牌用于 keycloak 检查授权/身份验证.

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

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

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天全站免登陆