# XWiki 10.8 with Keycloak as IP

**URL:** <https://forum.xwiki.org/t/xwiki-10-8-with-keycloak-as-ip/3751>\
**Category:** Help / Discuss\
**Tags:** authentication, openid\
**Created:** [October 17, 2018, 9:19pm UTC](https://forum.xwiki.org/t/xwiki-10-8-with-keycloak-as-ip/3751 "2018-10-17T21:19:50Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![frsc](https://forum.xwiki.org/letter_avatar_proxy/v4/letter/f/e19b73/32.png) [@frsc](https://forum.xwiki.org/u/frsc)\
**Post date:** [October 17, 2018, 9:19pm UTC](https://forum.xwiki.org/t/xwiki-10-8-with-keycloak-as-ip/3751/1 "2018-10-17T21:19:50Z")

</div>

Hi,

I want to set up SSO with Keycloak as authentication server.  
I tried to install the “OpenID Connect Authenticator” extension, but after that my XWiki (docker based setup) fails to restart and throws a lot of errors. I saw in the installer, that the extension depends on “oldcore 8.4” and I’m wondering if this causes the errors…

An other option would be SAML, but I can’t see any extension for that, that is not several years old.

How should I proceed?  
Thanks for any help!

---

<div class="post-metadata">

**Author:** ![tmortagne](https://forum.xwiki.org/user_avatar/forum.xwiki.org/tmortagne/32/4930_2.png) [@tmortagne](https://forum.xwiki.org/u/tmortagne)\
**Post date:** [October 18, 2018, 8:43am UTC](https://forum.xwiki.org/t/xwiki-10-8-with-keycloak-as-ip/3751/2 "2018-10-18T08:43:18Z")

</div>

> [@frsc](#):
>
> the extension depends on “oldcore 8.4”

This is just the minimum version, it does not install it since you already have it in a more recent version.

> throws a lot of errors

What kind of errors ?

---

<div class="post-metadata">

**Author:** ![frsc](https://forum.xwiki.org/letter_avatar_proxy/v4/letter/f/e19b73/32.png) [@frsc](https://forum.xwiki.org/u/frsc)\
**Post date:** [October 18, 2018, 5:04pm UTC](https://forum.xwiki.org/t/xwiki-10-8-with-keycloak-as-ip/3751/3 "2018-10-18T17:04:27Z")

</div>

> [@tmortagne](#):
>
> > the extension depends on “oldcore 8.4”
> 
> This is just the minimum version, it does not install it since you already have it in a more recent version.

Ok, the message in the installer can be misleading to a newbie.

> [@tmortagne](#):
>
> > throws a lot of errors
> 
> What kind of errors ?

Nevermind, somehow the problem was resolved when I tried again. I also did an update of the Docker image from 10.8 to 10.8.1. I still see some errors in the log on startup, but I guess these are unrelated.

Now I am stuck at a different point: I set up the oidc endpoints and the auth request seems to work fine, but XWiki sets the redirect\_uri to `https://domain.com:80/oidc/authenticator/callback`. So after sending the login I get an error in the browser, because port 80 is accessed in SSL context.

Could this be related to my setup? I’m running the XWiki docker container behind an nginx reverse proxy.

---

<div class="post-metadata">

**Author:** ![vmassol](https://forum.xwiki.org/user_avatar/forum.xwiki.org/vmassol/32/6_2.png) [@vmassol](https://forum.xwiki.org/u/vmassol)\
**Post date:** [October 18, 2018, 8:15pm UTC](https://forum.xwiki.org/t/xwiki-10-8-with-keycloak-as-ip/3751/4 "2018-10-18T20:15:47Z")

</div>

> [@frsc](#):
>
> I also did an update of the Docker image from 10.8 to 10.8.1. I still see some errors in the log on startup, but I guess these are unrelated.

Yes those logs are warnings about encoding on tomcat. See [Loading...](https://jira.xwiki.org/browse/XWIKI-14635)

---

<div class="post-metadata">

**Author:** ![frsc](https://forum.xwiki.org/letter_avatar_proxy/v4/letter/f/e19b73/32.png) [@frsc](https://forum.xwiki.org/u/frsc)\
**Post date:** [October 18, 2018, 8:30pm UTC](https://forum.xwiki.org/t/xwiki-10-8-with-keycloak-as-ip/3751/5 "2018-10-18T20:30:34Z")

</div>

> [@vmassol](#):
>
> Yes those logs are warnings about encoding on tomcat. See [Loading...](https://jira.xwiki.org/browse/XWIKI-14635)

Thank you for pointing that out. This is indeed one of the errors I see in my logs, but I also have:

`[Core extension repository updater] ERROR aultExtensionRepositoryManager - Unexpected error when trying to find extension [com.google.code.findbugs:annotations/api] in repository [store.xwiki.com:xwiki:https://store.xwiki.com/xwiki/rest]`

and another 3 or 4 warnings.

---

<div class="post-metadata">

**Author:** ![vmassol](https://forum.xwiki.org/user_avatar/forum.xwiki.org/vmassol/32/6_2.png) [@vmassol](https://forum.xwiki.org/u/vmassol)\
**Post date:** [October 18, 2018, 8:33pm UTC](https://forum.xwiki.org/t/xwiki-10-8-with-keycloak-as-ip/3751/6 "2018-10-18T20:33:13Z")

</div>

> [@frsc](#):
>
> This is indeed one of the errors I see in my logs, but I also have:
> 
> `[Core extension repository updater] ERROR aultExtensionRepositoryManager - Unexpected error when trying to find extension [com.google.code.findbugs:annotations/api] in repository [store.xwiki.com:xwiki:https://store.xwiki.com/xwiki/rest]`
> 
> and another 3 or 4 warnings.

Would be interesting to see the full log of those errors.

---

<div class="post-metadata">

**Author:** ![frsc](https://forum.xwiki.org/letter_avatar_proxy/v4/letter/f/e19b73/32.png) [@frsc](https://forum.xwiki.org/u/frsc)\
**Post date:** [October 18, 2018, 8:44pm UTC](https://forum.xwiki.org/t/xwiki-10-8-with-keycloak-as-ip/3751/7 "2018-10-18T20:44:09Z")

</div>

> [@vmassol](#):
>
> Would be interesting to see the full log of those errors.

Sure, to not mess up this thread I created a new one and uploaded the log: [Errors and Warnings in Logfile](https://forum.xwiki.org/t/errors-and-warnings-in-logfile/3764)

---

<div class="post-metadata">

**Author:** ![tmortagne](https://forum.xwiki.org/user_avatar/forum.xwiki.org/tmortagne/32/4930_2.png) [@tmortagne](https://forum.xwiki.org/u/tmortagne)\
**Post date:** [October 19, 2018, 9:44am UTC](https://forum.xwiki.org/t/xwiki-10-8-with-keycloak-as-ip/3751/8 "2018-10-19T09:44:36Z")

</div>

> [@frsc](#):
>
> Now I am stuck at a different point: I set up the oidc endpoints and the auth request seems to work fine, but XWiki sets the redirect\_uri to `https://domain.com:80/oidc/authenticator/callback` . So after sending the login I get an error in the browser, because port 80 is accessed in SSL context.

Could you check what the following:

- secure/http and port setup in your wiki descriptor ([http://domain/xwiki/view/XWiki/XWikiServerXwiki](http://domain/xwiki/view/XWiki/XWikiServerXwiki)) regarding
- `xwiki.home` property in xwiki.cfg

---

<div class="post-metadata">

**Author:** ![frsc](https://forum.xwiki.org/letter_avatar_proxy/v4/letter/f/e19b73/32.png) [@frsc](https://forum.xwiki.org/u/frsc)\
**Post date:** [October 19, 2018, 11:19am UTC](https://forum.xwiki.org/t/xwiki-10-8-with-keycloak-as-ip/3751/9 "2018-10-19T11:19:31Z")

</div>

> [@tmortagne](#):
>
> secure/http and port setup in your wiki descriptor ([http://domain/xwiki/view/XWiki/XWikiServerXwiki](http://domain/xwiki/view/XWiki/XWikiServerXwiki)) regarding

`Secure (SSL)` is set to -1 and `Port` is set to 80 in the descriptor.

> [@tmortagne](#):
>
> `xwiki.home` property in xwiki.cfg

`xwiki.home` was unset. I now set it to `https://domain.com` and I also set `xwiki.url.protocol=https`.  
With these changes the login via Keycloak is now working.

First I tried with `xwiki.home=https://domain.com/`(note the ‘/’ at the end), which caused a malformed redirection URL. So it is important to remove the trailing slash.

Is this documented somewhere? Can this be added to the docs of the OIDC extension?  
And what about the descriptor settings? Should I change them, too? If yes, how?

Thank you for helping me out. I will probably come back with more questions. 😉

---

<div class="post-metadata">

**Author:** ![tmortagne](https://forum.xwiki.org/user_avatar/forum.xwiki.org/tmortagne/32/4930_2.png) [@tmortagne](https://forum.xwiki.org/u/tmortagne)\
**Post date:** [October 19, 2018, 3:07pm UTC](https://forum.xwiki.org/t/xwiki-10-8-with-keycloak-as-ip/3751/10 "2018-10-19T15:07:20Z")

</div>

> [@frsc](#):
>
> `Secure (SSL)` is set to -1 and `Port` is set to 80 in the descriptor.

I think that’s your issue. The URL was generated based on the request URL and the port indicated in the descriptor (I fixed XWIKI-15757 to make this mix impossible even by mistake).

> I now set it to [https://domain.com](https://domain.com) and I also set xwiki.url.protocol=https.  
> With these changes the login via Keycloak is now working.

You should not use those properties IMO.  
In recent versions it’s usually better and easier to maintain to configure the wiki descriptor properly. So for you:

- set the right domain
- enable HTTPS (secure)
- don’t put any explicit port since you want default https port

> [@frsc](#):
>
> Can this be added to the docs of the OIDC extension?

It does not really have much to do with the OIDC authenticator, what was broken was the standard external URL generation and you would have had similar issues with other features.

---

<div class="post-metadata">

**Author:** ![frsc](https://forum.xwiki.org/letter_avatar_proxy/v4/letter/f/e19b73/32.png) [@frsc](https://forum.xwiki.org/u/frsc)\
**Post date:** [October 20, 2018, 9:16pm UTC](https://forum.xwiki.org/t/xwiki-10-8-with-keycloak-as-ip/3751/11 "2018-10-20T21:16:17Z")

</div>

> [@tmortagne](#):
>
> You should not use those properties IMO.  
> In recent versions it’s usually better and easier to maintain to configure the wiki descriptor properly.

Unfortunately this doesn’t work. I tried setting up the descriptor properly, but I still get the wrong URLs redirecting to port 80. Therefore I will keep the settings in xwiki.cfg for now.

---

<div class="post-metadata">

**Author:** ![tmortagne](https://forum.xwiki.org/user_avatar/forum.xwiki.org/tmortagne/32/4930_2.png) [@tmortagne](https://forum.xwiki.org/u/tmortagne)\
**Post date:** [October 25, 2018, 9:43am UTC](https://forum.xwiki.org/t/xwiki-10-8-with-keycloak-as-ip/3751/12 "2018-10-25T09:43:54Z")

</div>

What configuration do you have exactly and what wrong URL do you end up with and in which context ?

---

<div class="post-metadata">

**Author:** ![frsc](https://forum.xwiki.org/letter_avatar_proxy/v4/letter/f/e19b73/32.png) [@frsc](https://forum.xwiki.org/u/frsc)\
**Post date:** [October 30, 2018, 7:35pm UTC](https://forum.xwiki.org/t/xwiki-10-8-with-keycloak-as-ip/3751/13 "2018-10-30T19:35:33Z")

</div>

> [@tmortagne](#):
>
> What configuration do you have exactly and what wrong URL do you end up with and in which context ?

I think I have given most of the information above. Unfortunately I currently do not have the time to revert my (working!) settings in xwiki.cfg and edit the descriptor again just for testing.  
I’m trying to get XWiki up and running to a state that is more or less suitable for production and I’m afraid there might be other pitfalls coming up during configuration…

---

<div class="post-metadata">

**Author:** ![frsc](https://forum.xwiki.org/letter_avatar_proxy/v4/letter/f/e19b73/32.png) [@frsc](https://forum.xwiki.org/u/frsc)\
**Post date:** [November 1, 2018, 10:56am UTC](https://forum.xwiki.org/t/xwiki-10-8-with-keycloak-as-ip/3751/14 "2018-11-01T10:56:01Z")

</div>

Now, I’m trying to sync the user groups between Keycloak and XWiki via OIDC. I set `oidc.userinfoclaims=xwiki_groups,xwiki_user_email` and create the mapping in Keycloak for `xwiki_groups`.

So far it doesn’t work and when I turn on the debug logs in the OIDC extension, I see that [`updateXWikiClaims()`](https://github.com/xwiki-contrib/oidc/blob/df84cefe1606eb940d0532859898a4ef42db1850/oidc-authenticator/src/main/java/org/xwiki/contrib/oidc/auth/internal/OIDCUserManager.java#L453) is executed, but [`syncXWikiGroupsMembership`](https://github.com/xwiki-contrib/oidc/blob/df84cefe1606eb940d0532859898a4ef42db1850/oidc-authenticator/src/main/java/org/xwiki/contrib/oidc/auth/internal/OIDCUserManager.java#L418) is not.

---

<div class="post-metadata">

**Author:** ![frsc](https://forum.xwiki.org/letter_avatar_proxy/v4/letter/f/e19b73/32.png) [@frsc](https://forum.xwiki.org/u/frsc)\
**Post date:** [November 1, 2018, 12:47pm UTC](https://forum.xwiki.org/t/xwiki-10-8-with-keycloak-as-ip/3751/15 "2018-11-01T12:47:05Z")

</div>

Ok, I think my Keycloak setup was wrong. The group assignment is working now.
