TAFJ-Secure-Authentication-Using-Keycloak
TAFJ-Secure-Authentication-Using-Keycloak
Keycloak
R22
Document History
1 31st March 2021 Riswana Secure TAFJ Entry Points using KeyCloak
Copyright
Please include your name, company, address, and telephone and fax numbers, and email
address if applicable. [email protected]
Table of Contents
Document History 2
Copyright 3
Errata and Comments 3
Overview 5
KeyCloak Configuration 5
Create Realm............................................................................................................................. 5
Create Client.............................................................................................................................. 6
Create Group TAFJAdmin............................................................................................................ 8
Create Roles TAFJAdmin............................................................................................................. 9
Add Mapper for TAFJClient........................................................................................................ 10
Create User with Group TAFJAdmin.......................................................................................... 11
TAFJEE.ear Configuration 12
Jboss........................................................................................................................................ 12
Install adapter in Jboss.......................................................................................................... 12
Configuration........................................................................................................................ 12
WebSphere Liberty................................................................................................................... 13
Configuration........................................................................................................................ 13
DBTools Authentication with Keycloak 14
Console.................................................................................................................................... 14
Servlet..................................................................................................................................... 14
Overview
Keycloak is an Open Source Identity and Access Management solution for modern Applications
and Services. In this document, the configuration of keycloak to access TAFJ entry points is
detailed.
KeyCloak Configuration
Start Keycloak server. Find below command to start keycloak server using docker
Create Realm
Access the Keycloak URL http://localhost:8180/auth
Create Client
Incase of Websphere Liberty where openidConnectClient is used, set the Root URL to the root
and Valid Redirect URIs as “https://<IP_Address:port>/oidcclient/redirect/*”
Settings → Change Access type as Confidential and set the Direct Grant Workflow as "direct
grant"
Change the client's credentials in the Client Authenticator field to Client Id and Secret
Select the newly created Client role (TAFJClient) then select the Available role and use the Add
selected button to move Assigned Roles.
Then do the same for the realm-management client role in that select all available roles and
move
Evaluate TAFJClient to find if the groupof mapper is getting passed in the token
TAFJEE.ear Configuration
Change the auth-method in web.xml as KEYCLOAK
<login-config>
<auth-method>KEYCLOAK</auth-method>
<realm-name>TAFJRealm</realm-name>
</login-config>
Refer https://www.keycloak.org/documentation
Configuration
Add below extension inside <extensions> in Standalone.xml
<extension module="org.keycloak.keycloak-adapter-subsystem"/>
From Keycloak Server → Clients→ Installation Tab, download/copy the configuration in the
required format.
o Copy the Installation information in subsystem format and add sub system in
standalone.xml as below
<subsystem xmlns="urn:jboss:domain:keycloak:1.1">
<secure-deployment name="TAFJEE.war">
<realm>TAFJRealm</realm>
<auth-server-url>http://localhost:8180/auth/</auth-server-url>
WebSphere Liberty
Configuration
Add below features in server.xml.
<featureManager>
….
<feature>transportSecurity-1.0</feature>
<feature>openidConnectClient-1.0</feature>
</featureManager>
Console
Add -keycloak with DBTools command to authenticate with Keycloak
DBTools -u <usename> -p <password> -keycloak
Servlet
Add DBTools.jar to module.xml to enable DBTools in servlet.
<dependencies>
....
<module name="org.apache.httpcomponents"/>
</dependencies>