Skip to content

JSPWIKI-94 Log in with OpenID Connect through Keycloak - #643

Open
arturobernalg wants to merge 3 commits into
apache:masterfrom
arturobernalg:feature/JSPWIKI-94-oidc
Open

arturobernalg wants to merge 3 commits into
apache:masterfrom
arturobernalg:feature/JSPWIKI-94-oidc

Conversation

@arturobernalg

@arturobernalg arturobernalg commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Adds optional OpenID Connect login to JSPWiki, as asked in JSPWIKI-94, following the guide Alex attached to the ticket. It has been tried with Keycloak.

cc @spyhunter99 @juanpablo-santos, could you review it?

How it works: the pac4j filters send the user to the identity provider and receive the answer. OidcIdentityFilter runs before the filters of the wiki and presents the logged in user as a user authenticated by the container, through getRemoteUser(), getUserPrincipal() and isUserInRole(). The web.xml already documents that a filter placed before WikiServletFilter that returns these values makes the wiki treat the user as authenticated. OidcAuthorizer, an authorizer for jspwiki.authorizer, declares that the container handles the login, so Login.jsp behaves as with a container login, and takes the role names from jspwiki.oidc.roles (Admin and Authenticated by default).

What the PR contains:

  • The new module jspwiki-oidc: OidcConfigFactory (reads jspwiki-oidc.properties), OidcIdentityFilter, OidcRequestWrapper and OidcAuthorizer, with tests. Its README describes how to enable it and how to set up the client in Keycloak.
  • The filters in web.xml, commented out as the container managed section is, and the profile oidc in jspwiki-war, which includes the module. Without the profile nothing changes in the war.

I checked it with a real Keycloak and the wiki with its pages in Tomcat:

  • The Log in link of the wiki sends the user to Keycloak, and after the login the user comes back to the page the wiki was showing, as G'day, kcuser (authenticated).
  • Roles: a user with the realm role Authenticated can see a page whose ACL allows Authenticated and gets 403 on one that needs Admin. A user with the realm role Admin sees both, and the wiki shows the administrator notices.
  • Log out: it ends the session of the wiki and the one of Keycloak, and returns to the wiki. After it the wiki shows Log in again, and Keycloak asks for the credentials.

It uses the Keycloak client of pac4j, as the attachment does. It adds pac4j (pac4j-oidc 6.5.5, jakartaee-pac4j 8.0.3) as dependencies of the new module, only included in the war with the profile.

I did not try other identity providers, nor the portable build.

A new jspwiki-oidc module uses the pac4j filters to send the user to the identity provider and a filter that presents the logged in user to the wiki as a container login. The wiki recognizes the user as authenticated without changes in its authentication code. Work in progress, not ready for review.
…d a test

The filters of the proof of concept are commented out in web.xml, as the container managed authentication section is, and the war does not include the module. Adds the ChangeLog entry and a test of the request wrapper.
…onnect module

OidcAuthorizer declares that the container handles the login and takes the roles from the property jspwiki.oidc.roles, so Login.jsp and the roles of the identity provider work as with a container login. The logout filter ends the session of the identity provider and returns to the wiki. The war includes the module with the profile oidc. Adds the tests of the authorizer and a description of how to enable it.
@arturobernalg arturobernalg changed the title JSPWIKI-94 Proof of concept: log in with OpenID Connect through Keycloak JSPWIKI-94 Log in with OpenID Connect through Keycloak Nov 18, 2026
@arturobernalg
arturobernalg marked this pull request as ready for review November 18, 2026 06:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant