Sometime it may be possible you want to add more parameters to standard registration page of keyloak for your users and aaccess that data in your spring boot application. This artical will show step by steps on how to add such extra attributes.
What is Keycloak
Keycloak is an open source software product to allow single sign-on with Identity Management and Access Management aimed at modern applications and services, to learn more visit https://www.keycloak.org/What is Spring boot
Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can "just run". To learn more visit https://spring.io/projects/spring-bootTo add an extra attribute in keyclkoak server you will need to edit actuall html template and then registaer new attribute in json response so that it will be available on client.
Edit HTML template
Lets assume we want to add mobile number on default registration page.
- Go to Keycloak home installation directory
- edit file theme/base/login/register.ftl
- add following html in this file wherever you want to see mobile number field on the above screen.
- Note down id="user.attributes.mobile" for input tag, this is the field name for custom attribute which will be saved with user data
Edit Settings in KeyCloak Admin Panel
Now we need to map this field to rest service ourput, so that each client can access it.- Login to your KeyCloak admin panel
- Select Your realm which you may have created already
- Select Client which you may have created already from left side menu
- Select Mapper tab
- Click on create button on right
- Enter Name as "Mobile Attirbute Mapping" (basically any name which you want to)
- Select Mapper Type as "User Attribute"
- Add User Attribute as "mobile" , which is from html input tag id "user.attributes.mobile"
- Add Token Claim name as "mobile" or any other valid Json name field value, which you will read as json element in Spring boot application.
- Select Claim Json Type as "String"
- Click Save
Read Custom user attribute in Java/Spring boot
Say you have a controller like this
Note line 13 , we are reading "mobile" from map , which is same as "Token Claim" set in mapper definition.
Hi Ravi, I need some help with a keycloak deployment - is this something you can help with? Please email me if interested. Thanks!
ReplyDeleteTry Docker. Its pretty easy.!
DeleteYou have a real ability to write a content that is helpful for us. Thank you for your efforts in sharing such blogs to us. oracle fusion hcm training india
ReplyDeleteThanks for a useful Post.
ReplyDeleteCointool App Clone Script |
Sorare Clone Script
Zed Run Clone Script
Crypto Punks Clone Script |
It is really a helpful blog to find some different source to add my knowledge. Vonex dealer
ReplyDeletePretty great post. I simply stumbled upon your blog and wanted to mention that I have really loved surfing around your blog posts. Great set of tips from the master himself. Excellent ideas. Thanks for Awesome tips Keep it
ReplyDeletecracksbin.com
OpenSea Clone |
ReplyDeleteSolsea Clone |
Rarible Clone |
Axie Infinity Clone |
Cryptopunks Clone |
Zed Run Clone |
OpenSea Clone Script |
ReplyDeleteBEP20 Token Development Company |
Decentraland Clone Script |
NFT Marketplace Development Company |
NFT Marketplace Clone Script
Blockchain Game Development Company |
Smart Contract MLM Software Development |
The King Casino: Best Casino Software and Games
ReplyDeleteThe King Casino software company is well-known in the หาเงินออนไลน์ world of online communitykhabar casino games. It 바카라사이트 has ventureberg.com/ been in business since 2001, but it now https://jancasino.com/review/merit-casino/ offers live dealer casino games
Token Development Company
ReplyDeleteCryptocurrency Development
Cryptocurrency Development Company
White Paper Writing Services |
BEP20 Token Development Company |
Smart Contract Development Company
ICO Development Company
Stablecoin Development Company |
Wonderful Post!
ReplyDeleteSolana Token Development Company
ERC20 Token Development Company
Smart Contract Development Company
NFT Token Development Company
Cointool App Clone Script
Very good article! We will be linking to this particularly great post on our website. Keep up the good writing.
ReplyDeleteDriver Talent Pro Crack
Weather Pro Crack
reflector Pro Crack
keyscape Crack
ozone imager Crack
vstfull.com
I read your blog now share great information here. How To Make Crypto Punks
ReplyDelete