diff --git a/ChangeLog.md b/ChangeLog.md
index 880da8f4df..595a53b3ee 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -17,6 +17,12 @@ specific language governing permissions and limitations
under the License.
-->
+**2026-11-18 Arturo Bernal (abernal AT apache DOT org)**
+
+* _3.0.1-git-10_
+
+* Fix for [JSPWIKI-94](https://issues.apache.org/jira/browse/JSPWIKI-94): the new module jspwiki-oidc logs users in with OpenID Connect, with the pac4j filters, and presents them to the wiki as users authenticated by the container, including their roles and the logout. It is not included in the war unless it is built with the profile oidc, and its filters are disabled in web.xml
+
**2026-11-14 Multiple authors**
* _3.0.1-git-09
diff --git a/jspwiki-api/src/main/java/org/apache/wiki/api/Release.java b/jspwiki-api/src/main/java/org/apache/wiki/api/Release.java
index 7128b9933e..a588475922 100644
--- a/jspwiki-api/src/main/java/org/apache/wiki/api/Release.java
+++ b/jspwiki-api/src/main/java/org/apache/wiki/api/Release.java
@@ -69,7 +69,7 @@ public final class Release {
*
* If the build identifier is empty, it is not added.
*/
- public static final String BUILD = "9";
+ public static final String BUILD = "10";
/**
* This is the generic version string you should use when printing out the version. It is of
diff --git a/jspwiki-oidc/README.md b/jspwiki-oidc/README.md
new file mode 100644
index 0000000000..5b10f2bf37
--- /dev/null
+++ b/jspwiki-oidc/README.md
@@ -0,0 +1,54 @@
+
+
+
+# jspwiki-oidc
+
+Logs users in with OpenID Connect, using the pac4j filters, and presents them to the wiki as users authenticated by the
+container. It has been tried with Keycloak, see [JSPWIKI-94](https://issues.apache.org/jira/browse/JSPWIKI-94).
+
+## Enabling it
+
+1. Build the war with `mvn package -Poidc`, or add this module and its dependencies to `WEB-INF/lib`.
+2. Create `WEB-INF/classes/jspwiki-oidc.properties`:
+
+ ```
+ oidc.clientId=jspwiki-client
+ oidc.secret=the client secret
+ oidc.scope=openid email profile
+ oidc.realm=jspwiki
+ oidc.baseUri=https://keycloak.example.org
+ oidc.discoveryUri=https://keycloak.example.org/realms/jspwiki/.well-known/openid-configuration
+ oidc.callbackUrl=/oidc/callback
+ ```
+
+3. Add to `WEB-INF/classes/jspwiki-custom.properties`:
+
+ ```
+ jspwiki.authorizer = org.apache.wiki.oidc.OidcAuthorizer
+ ```
+
+ The roles the wiki takes from the identity provider are `Admin` and `Authenticated`. Change them with the property
+ `jspwiki.oidc.roles`, a comma separated list.
+4. In `WEB-INF/web.xml`, remove the comment marks around the OpenID Connect filters.
+5. In Keycloak, create a confidential client whose valid redirect URIs and post logout redirect URIs include the address of the wiki,
+ and the realm roles `Admin` and `Authenticated`, which are assigned to the users.
+
+The links to log in and out of the wiki then use the identity provider: `Login.jsp` sends the user to it, and `Logout.jsp` ends the
+session of the wiki and of the identity provider. The wiki is not asked for passwords, and its own user profiles are not used.
diff --git a/jspwiki-oidc/pom.xml b/jspwiki-oidc/pom.xml
new file mode 100644
index 0000000000..a49b56d242
--- /dev/null
+++ b/jspwiki-oidc/pom.xml
@@ -0,0 +1,86 @@
+
+
+
+
+
+ org.apache.jspwiki
+ jspwiki-builder
+ 3.0.1-SNAPSHOT
+
+
+ 4.0.0
+ jspwiki-oidc
+ Apache JSPWiki OpenID Connect login
+
+
+ 6.5.5
+ 8.0.3
+
+
+
+
+ org.pac4j
+ jakartaee-pac4j
+ ${jakartaee-pac4j.version}
+
+
+
+ org.pac4j
+ pac4j-oidc
+ ${pac4j.version}
+
+
+
+ ${project.groupId}
+ jspwiki-main
+ ${project.version}
+ provided
+
+
+
+ org.slf4j
+ slf4j-api
+
+
+
+ jakarta.servlet
+ jakarta.servlet-api
+ provided
+
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ test
+
+
+
+ org.mockito
+ mockito-core
+ test
+
+
+
diff --git a/jspwiki-oidc/src/main/java/org/apache/wiki/oidc/OidcAuthorizer.java b/jspwiki-oidc/src/main/java/org/apache/wiki/oidc/OidcAuthorizer.java
new file mode 100644
index 0000000000..985fe9dca2
--- /dev/null
+++ b/jspwiki-oidc/src/main/java/org/apache/wiki/oidc/OidcAuthorizer.java
@@ -0,0 +1,52 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+package org.apache.wiki.oidc;
+
+import java.util.Arrays;
+import java.util.Properties;
+
+import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.auth.authorize.Role;
+import org.apache.wiki.auth.authorize.WebContainerAuthorizer;
+
+/**
+ * Authorizer for wikis whose users log in with OpenID Connect. The login is done by filters and not by constraints of the web
+ * application descriptor, so this authorizer declares that the container handles the login, and takes the names of the roles
+ * from the property {@code jspwiki.oidc.roles}, a comma separated list that defaults to {@code Admin,Authenticated}.
+ */
+public class OidcAuthorizer extends WebContainerAuthorizer {
+
+ /** Property with the comma separated names of the roles the identity provider may grant. */
+ public static final String PROP_ROLES = "jspwiki.oidc.roles";
+
+ private static final String DEFAULT_ROLES = "Admin,Authenticated";
+
+ /** {@inheritDoc} */
+ @Override
+ public void initialize( final Engine engine, final Properties props ) {
+ super.initialize( engine, props );
+ m_containerAuthorized = true;
+ m_containerRoles = Arrays.stream( props.getProperty( PROP_ROLES, DEFAULT_ROLES ).split( "," ) )
+ .map( String::trim )
+ .filter( name -> !name.isEmpty() )
+ .map( Role::new )
+ .toArray( Role[]::new );
+ }
+
+}
diff --git a/jspwiki-oidc/src/main/java/org/apache/wiki/oidc/OidcConfigFactory.java b/jspwiki-oidc/src/main/java/org/apache/wiki/oidc/OidcConfigFactory.java
new file mode 100644
index 0000000000..ff031472f7
--- /dev/null
+++ b/jspwiki-oidc/src/main/java/org/apache/wiki/oidc/OidcConfigFactory.java
@@ -0,0 +1,87 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+package org.apache.wiki.oidc;
+
+import java.io.InputStream;
+import java.util.Properties;
+
+import com.nimbusds.oauth2.sdk.auth.ClientAuthenticationMethod;
+import org.pac4j.core.client.Clients;
+import org.pac4j.core.config.Config;
+import org.pac4j.core.client.Client;
+import org.pac4j.core.config.ConfigFactory;
+import org.pac4j.core.context.CallContext;
+import org.pac4j.core.engine.DefaultLogoutLogic;
+import org.pac4j.core.http.url.DefaultUrlResolver;
+import org.pac4j.core.http.url.UrlResolver;
+import org.pac4j.oidc.authorization.generator.KeycloakRolesAuthorizationGenerator;
+import org.pac4j.oidc.client.KeycloakOidcClient;
+import org.pac4j.oidc.config.KeycloakOidcConfiguration;
+
+/**
+ * Builds the pac4j configuration from {@code jspwiki-oidc.properties}, which has to be in the classpath of the web application.
+ */
+public class OidcConfigFactory implements ConfigFactory {
+
+ static final String CONFIG_FILE = "/jspwiki-oidc.properties";
+
+ /** {@inheritDoc} */
+ @Override
+ public Config build( final Object... parameters ) {
+ final Properties props = new Properties();
+ try( InputStream in = OidcConfigFactory.class.getResourceAsStream( CONFIG_FILE ) ) {
+ if( in == null ) {
+ throw new IllegalStateException( CONFIG_FILE + " not found in the classpath" );
+ }
+ props.load( in );
+ } catch( final java.io.IOException e ) {
+ throw new IllegalStateException( "Could not read " + CONFIG_FILE, e );
+ }
+ final KeycloakOidcConfiguration oidc = new KeycloakOidcConfiguration();
+ oidc.setClientId( required( props, "oidc.clientId" ) );
+ oidc.setSecret( required( props, "oidc.secret" ) );
+ oidc.setScope( props.getProperty( "oidc.scope", "openid email profile" ) );
+ oidc.setClientAuthenticationMethod( ClientAuthenticationMethod.CLIENT_SECRET_BASIC );
+ oidc.setRealm( required( props, "oidc.realm" ) );
+ oidc.setBaseUri( required( props, "oidc.baseUri" ) );
+ oidc.setDiscoveryURI( required( props, "oidc.discoveryUri" ) );
+ final KeycloakOidcClient client = new KeycloakOidcClient( oidc );
+ client.addAuthorizationGenerator( new KeycloakRolesAuthorizationGenerator() );
+ final UrlResolver urlResolver = new DefaultUrlResolver( true );
+ client.setUrlResolver( urlResolver );
+ final Config config = new Config( new Clients( required( props, "oidc.callbackUrl" ), client ) );
+ // the identity provider needs an absolute URL to return to after the logout
+ config.setLogoutLogic( new DefaultLogoutLogic() {
+ @Override
+ protected String enhanceRedirectUrl( final CallContext ctx, final Config config, final Client client, final String redirectUrl ) {
+ return urlResolver.compute( redirectUrl, ctx.webContext() );
+ }
+ } );
+ return config;
+ }
+
+ private static String required( final Properties props, final String key ) {
+ final String value = props.getProperty( key );
+ if( value == null || value.isBlank() ) {
+ throw new IllegalStateException( CONFIG_FILE + " does not define " + key );
+ }
+ return value;
+ }
+
+}
diff --git a/jspwiki-oidc/src/main/java/org/apache/wiki/oidc/OidcIdentityFilter.java b/jspwiki-oidc/src/main/java/org/apache/wiki/oidc/OidcIdentityFilter.java
new file mode 100644
index 0000000000..f40dde999a
--- /dev/null
+++ b/jspwiki-oidc/src/main/java/org/apache/wiki/oidc/OidcIdentityFilter.java
@@ -0,0 +1,64 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+package org.apache.wiki.oidc;
+
+import java.io.IOException;
+import java.util.Optional;
+import java.util.Set;
+
+import org.pac4j.core.profile.ProfileManager;
+import org.pac4j.core.profile.UserProfile;
+import org.pac4j.jee.context.JEEContext;
+import org.pac4j.jee.context.session.JEESessionStore;
+
+import jakarta.servlet.Filter;
+import jakarta.servlet.FilterChain;
+import jakarta.servlet.ServletException;
+import jakarta.servlet.ServletRequest;
+import jakarta.servlet.ServletResponse;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+
+/**
+ * Hands the user logged in with OpenID Connect to the wiki. It has to run before {@code WikiServletFilter}, which takes
+ * the user from {@code getRemoteUser()} and {@code getUserPrincipal()} of the request, as it does with a container login.
+ */
+public class OidcIdentityFilter implements Filter {
+
+ /** {@inheritDoc} */
+ @Override
+ public void doFilter( final ServletRequest request, final ServletResponse response, final FilterChain chain ) throws IOException, ServletException {
+ final HttpServletRequest req = ( HttpServletRequest )request;
+ if( req.getSession( false ) == null ) {
+ chain.doFilter( request, response );
+ return;
+ }
+ final JEEContext context = new JEEContext( req, ( HttpServletResponse )response );
+ final ProfileManager profiles = new ProfileManager( context, new JEESessionStore() );
+ final Optional< UserProfile > profile = profiles.getProfile();
+ if( profile.isPresent() ) {
+ final UserProfile user = profile.get();
+ final String name = user.getUsername() != null ? user.getUsername() : user.getId();
+ chain.doFilter( new OidcRequestWrapper( req, name, Set.copyOf( user.getRoles() ) ), response );
+ } else {
+ chain.doFilter( request, response );
+ }
+ }
+
+}
diff --git a/jspwiki-oidc/src/main/java/org/apache/wiki/oidc/OidcRequestWrapper.java b/jspwiki-oidc/src/main/java/org/apache/wiki/oidc/OidcRequestWrapper.java
new file mode 100644
index 0000000000..527ba11417
--- /dev/null
+++ b/jspwiki-oidc/src/main/java/org/apache/wiki/oidc/OidcRequestWrapper.java
@@ -0,0 +1,59 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+package org.apache.wiki.oidc;
+
+import java.security.Principal;
+import java.util.Set;
+
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletRequestWrapper;
+
+/**
+ * Presents the identity of an OpenID Connect login to the wiki as if the container had authenticated the user.
+ */
+class OidcRequestWrapper extends HttpServletRequestWrapper {
+
+ private final Principal principal;
+ private final Set< String > roles;
+
+ OidcRequestWrapper( final HttpServletRequest request, final String name, final Set< String > roles ) {
+ super( request );
+ this.principal = () -> name;
+ this.roles = roles;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public String getRemoteUser() {
+ return principal.getName();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Principal getUserPrincipal() {
+ return principal;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public boolean isUserInRole( final String role ) {
+ return roles.contains( role ) || super.isUserInRole( role );
+ }
+
+}
diff --git a/jspwiki-oidc/src/test/java/org/apache/wiki/oidc/OidcAuthorizerTest.java b/jspwiki-oidc/src/test/java/org/apache/wiki/oidc/OidcAuthorizerTest.java
new file mode 100644
index 0000000000..3fd7eb0732
--- /dev/null
+++ b/jspwiki-oidc/src/test/java/org/apache/wiki/oidc/OidcAuthorizerTest.java
@@ -0,0 +1,57 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+package org.apache.wiki.oidc;
+
+import java.util.Arrays;
+import java.util.Properties;
+import java.util.stream.Collectors;
+
+import org.apache.wiki.api.core.Engine;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+
+class OidcAuthorizerTest {
+
+ private OidcAuthorizer initialized( final Properties props ) {
+ final OidcAuthorizer authorizer = new OidcAuthorizer();
+ authorizer.initialize( Mockito.mock( Engine.class ), props );
+ return authorizer;
+ }
+
+ @Test
+ void declaresThatTheContainerHandlesTheLogin() {
+ Assertions.assertTrue( initialized( new Properties() ).isContainerAuthorized() );
+ }
+
+ @Test
+ void knowsAdminAndAuthenticatedByDefault() {
+ final String names = Arrays.stream( initialized( new Properties() ).getRoles() ).map( r -> r.getName() ).sorted().collect( Collectors.joining( "," ) );
+ Assertions.assertEquals( "Admin,Authenticated", names );
+ }
+
+ @Test
+ void takesTheRolesFromTheProperty() {
+ final Properties props = new Properties();
+ props.setProperty( OidcAuthorizer.PROP_ROLES, " Editors , Admin ,," );
+ final String names = Arrays.stream( initialized( props ).getRoles() ).map( r -> r.getName() ).sorted().collect( Collectors.joining( "," ) );
+ Assertions.assertEquals( "Admin,Editors", names );
+ }
+
+}
diff --git a/jspwiki-oidc/src/test/java/org/apache/wiki/oidc/OidcRequestWrapperTest.java b/jspwiki-oidc/src/test/java/org/apache/wiki/oidc/OidcRequestWrapperTest.java
new file mode 100644
index 0000000000..76b2149107
--- /dev/null
+++ b/jspwiki-oidc/src/test/java/org/apache/wiki/oidc/OidcRequestWrapperTest.java
@@ -0,0 +1,52 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+package org.apache.wiki.oidc;
+
+import java.util.Set;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+
+import jakarta.servlet.http.HttpServletRequest;
+
+class OidcRequestWrapperTest {
+
+ private final HttpServletRequest request = Mockito.mock( HttpServletRequest.class );
+ private final OidcRequestWrapper wrapper = new OidcRequestWrapper( request, "kcuser", Set.of( "Authenticated" ) );
+
+ @Test
+ void presentsTheLoggedInUserAsContainerUser() {
+ Assertions.assertEquals( "kcuser", wrapper.getRemoteUser() );
+ Assertions.assertEquals( "kcuser", wrapper.getUserPrincipal().getName() );
+ }
+
+ @Test
+ void grantsTheRolesOfTheIdentityProvider() {
+ Assertions.assertTrue( wrapper.isUserInRole( "Authenticated" ) );
+ Assertions.assertFalse( wrapper.isUserInRole( "Admin" ) );
+ }
+
+ @Test
+ void keepsTheRolesOfTheWrappedRequest() {
+ Mockito.when( request.isUserInRole( "Admin" ) ).thenReturn( true );
+ Assertions.assertTrue( wrapper.isUserInRole( "Admin" ) );
+ }
+
+}
diff --git a/jspwiki-oidc/src/test/resources/WEB-INF/web.xml b/jspwiki-oidc/src/test/resources/WEB-INF/web.xml
new file mode 100644
index 0000000000..703b4cb02b
--- /dev/null
+++ b/jspwiki-oidc/src/test/resources/WEB-INF/web.xml
@@ -0,0 +1,24 @@
+
+
+
+ jspwiki-oidc test
+
diff --git a/jspwiki-war/pom.xml b/jspwiki-war/pom.xml
index 2bfaa2ccea..9007912542 100644
--- a/jspwiki-war/pom.xml
+++ b/jspwiki-war/pom.xml
@@ -270,4 +270,18 @@
+
+
+
+
+ oidc
+
+
+ ${project.groupId}
+ jspwiki-oidc
+ ${project.version}
+
+
+
+
diff --git a/jspwiki-war/src/main/webapp/WEB-INF/web.xml b/jspwiki-war/src/main/webapp/WEB-INF/web.xml
index afce534d0d..ff5cea2ffb 100644
--- a/jspwiki-war/src/main/webapp/WEB-INF/web.xml
+++ b/jspwiki-war/src/main/webapp/WEB-INF/web.xml
@@ -74,6 +74,86 @@
org.apache.wiki.ui.WikiJSPFilter
+
+
+
WikiServletFilter
/attach/*
diff --git a/pom.xml b/pom.xml
index e4f24c55df..997fec5399 100644
--- a/pom.xml
+++ b/pom.xml
@@ -146,6 +146,7 @@
jspwiki-http
jspwiki-wysiwyg
jspwiki-main
+ jspwiki-oidc
jspwiki-markdown
jspwiki-tika-searchprovider
jspwiki-kendra-searchprovider