Search code examples
javaopenid-connectpac4j

How to change the name of the OIDC Client in pac4j


I am experimenting with the pac4j in order to add OIDC to a webapp. I started with the jee-pac4j-demo app.

From there I intend to go to a different OIDC Client.

  • I was also able to switch the Client to another OAuth2.0-Client-ID inside the Google Cloud. (Just by setting different Credentials)

  • I got the GoogleOidcClient working with a public hostname/ip. (Had to set the base_url of the context in some places).

  • However, I am not able to change the name of the Client.

I changed

  • the Name of the ID inside the Google Cloud Console from GoogleOidClient to Auth-Test
  • and also client_name parameter in the callback URL accordingly

I got a malformed_url error from Google.

  • then I also added oidcClient.setName("Auth-Test") to the factory.

Then I just get an "unauthorized".

Is GoogleOidcClient not supposed to be tampered with?

Is setName the wrong approach?

Is there a tutorial on how to add a "random" OIDC Client to the pac4j configuration?

Why does the logging still refer to localhost:8080?

JEE PAC4J DEMO 09:55:45.735 [http-nio-8080-exec-52] DEBUG o.p.core.engine.DefaultSecurityLogic - url: http://localhost:8080/jee-pac4j-demo/oidc/index.jsp
JEE PAC4J DEMO 09:55:45.735 [http-nio-8080-exec-52] DEBUG o.p.core.engine.DefaultSecurityLogic - clients: GoogleOidcClient | matchers: null
JEE PAC4J DEMO 09:55:45.735 [http-nio-8080-exec-52] DEBUG o.p.core.engine.DefaultSecurityLogic - currentClients: []
JEE PAC4J DEMO 09:55:45.735 [http-nio-8080-exec-52] DEBUG o.p.core.engine.DefaultSecurityLogic - Loaded profiles (from session: true): []
JEE PAC4J DEMO 09:55:45.735 [http-nio-8080-exec-52] DEBUG o.p.core.engine.DefaultSecurityLogic - unauthorized

Solution

  • To change the name of a client, client.setName("xxx"); is the appropriate thing to do.

    Sometimes, depending on the provider, there might be an issue with the fact that the client name is a request parameter. You can apply the client name on the path if need be: https://www.pac4j.org/5.7.x/docs/clients.html#3-the-callback-url