William Gosse 5 Years Ago I should mention to access the user's roles in cloak there is one thing that must be done in order for the code I have above to work correctly. When entering the username and email address for the user in Keycloak the username must match the first portion of the address before the @ sign. This is because Liferay will use that first portion to create the user's screen name in Liferay. My code uses the screen name to call back to Keycloak in order to retrieve the roles using Keycloak's Rest API. I know its not a perfect solution and I may need to rethink this at a later date. Please sign in to reply. Reply as... Cancel
William Gosse 5 Years Ago - Edited One thing I recently became aware of is that many of the Keycloak Restful API calls have a max query parameter to limit the number a of records that the call actually returns. What the Keycloak documentation neglected to mention is that there is a default for this max parameter which seems to be normally set to 100 records. I ran into this default setting on the one call I was making in my code above: GET /{realm}/clients/{id}/roles/{role-name}/users I had to add the setting of the max query parameter to overcome this limit of 100: Map<String, String> params = new HashMap<String, String>(); params.put(MAX, AUTH_SERVICE_ROLES_MAX); String roleUserPath = AUTH_SERVICE_ROLES_PATH + SLASH + authServiceRole + USERS_PATH; Response response = client.get(AUTH_SERVICE_URL, roleUserPath, MediaType.APPLICATION_JSON, params, accessToken); It would be better if the API didn't limit the call with a default unless specified by the developer. Please sign in to reply. Reply as... Cancel
Viktoria Azrelyan 4 Years Ago - Edited Hello, thank you for this post. Did you try to use this plugin ( OpenID Connect Plugin ) with Liferay 7.1 and Keycloak 7.*? The last supported version in the list of current requirementsof this plugin in the Liferay Marketplace is Liferay DXP 7.0 GA1+. Now, I am wondering, if this plugin is compatible with liferay 7.1 and 7.2. Do you know something about it? Thanks Best regards Viktoria Please sign in to reply. Reply as... Cancel William Gosse Viktoria Azrelyan 4 Years Ago - Edited "Did you try to use this plugin ( OpenID Connect Plugin ) with Liferay 7.1 and Keycloak 7.*?" I did try this but had no luck with it. I'll admit I haven't tried any recent renditions of this plugin. We're sticking on LR 7.0 GA7 for now. Please sign in to reply. Reply as... Cancel William Gosse William Gosse 4 Years Ago - Edited I also have this thread in the forum on this topic: https://liferay.dev/forums/-/message_boards/message/111857282#_com_liferay_message_boards_web_portlet_MBPortlet_message_111857282 Please sign in to reply. Reply as... Cancel
William Gosse Viktoria Azrelyan 4 Years Ago - Edited "Did you try to use this plugin ( OpenID Connect Plugin ) with Liferay 7.1 and Keycloak 7.*?" I did try this but had no luck with it. I'll admit I haven't tried any recent renditions of this plugin. We're sticking on LR 7.0 GA7 for now. Please sign in to reply. Reply as... Cancel William Gosse William Gosse 4 Years Ago - Edited I also have this thread in the forum on this topic: https://liferay.dev/forums/-/message_boards/message/111857282#_com_liferay_message_boards_web_portlet_MBPortlet_message_111857282 Please sign in to reply. Reply as... Cancel
William Gosse William Gosse 4 Years Ago - Edited I also have this thread in the forum on this topic: https://liferay.dev/forums/-/message_boards/message/111857282#_com_liferay_message_boards_web_portlet_MBPortlet_message_111857282 Please sign in to reply. Reply as... Cancel
Mario F 4 Years Ago - Edited Hi William, thank you for this blog post.Do you know if the out-of-the-box SSO openid connect integration available in Liferay 7.3 also automatically imports users' roles at login?I have configured Liferay to use KeyCloak as SSO service and it works fine. The users stored in KeyCloak are automatically imported (created) in Liferay at login time. Now I am trying to make it also import roles.I have configured KeyCloak to make it send roles to Liferay both through the id_token (returned by /token call) and /userinfo endpoints. The roles are added in the responses of these endpoints as a JSON array assigned to an attribute named "roles" (customizable KeyCloak side). The elements of this array are simple strings corresponding to the "roles keys" as defined in Liferay (User, Owner, ...); but that doesn't seem to be enough for Liferay Do you know if Liferay requires roles to be sent in another format? Maybe with a different attribute name than "roles"'? Thank you Mario Please sign in to reply. Reply as... Cancel Kirk Stork Mario F 3 Years Ago - Edited In my experimentation, yes it does (I'm using Cognito, not Keycloak, but the integration isn't specific to any OIDC provider. The default behavior is that upon first login via OIDC, the account is created and then the user is put through the local account setup workflow -- TOS, Password establishment and password hint. So this integration will probably need some kind of post-login procedure like the one in this post to avoid all that. Please sign in to reply. Reply as... Cancel
Kirk Stork Mario F 3 Years Ago - Edited In my experimentation, yes it does (I'm using Cognito, not Keycloak, but the integration isn't specific to any OIDC provider. The default behavior is that upon first login via OIDC, the account is created and then the user is put through the local account setup workflow -- TOS, Password establishment and password hint. So this integration will probably need some kind of post-login procedure like the one in this post to avoid all that. Please sign in to reply. Reply as... Cancel
Antonio Musarra 3 Years Ago - Edited I recently realized the classic integration scenario between Liferay and Keycloak using the OpenID Connect protocol and the Liferay OOTB connector. I reported in this article How to connect Keycloak and Liferay via OpenID Connect (https://bit.ly/keycloak-liferay-openid-connect) the complete experience. Please sign in to reply. Reply as... Cancel