Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Update pac4j-core to version 6.1.1 #611

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jeanbritz
Copy link

This PR is to update the jax-rs-pac4j project to be compatible with pac4j-core version 6.1.1

Changes:

  • Create new WebContextFactory implementation (called DefaultJaxRsWebContextFactory) which plugs into the existing JaxRsContextFactoryProvider - required by new pac4j framework
  • Create new SessionStoreFactory implementations (called JaxRsSessionStoreFactory, GrizzlySessionStoreFactory and ServletSessionStoreFactory) - required by new pac4j framework
  • Created new implementation of FrameworkParameters called JaxRsFrameworkParameters - required by new pac4j framework
  • Refactored Pac4jFeature (renamed to Pac4jDefaultFeature). Implementation of Pac4J feature subclasses still have the same name
  • Changed method signature AbstractFilter#filter(JaxRsContext) to AbstractFilter#filter(Config,ContainerRequestContext)
  • Added the required FrameworkAdapter.INSTANCE.applyDefaultSettingsIfUndefined(config) statement to AbstractFilter#filter(ContainerRequestContext)
  • Removed the adapt method in CallbackFilter as this is handled by DefaultJaxRsHttpActionAdapter and called within DefeaultSecurityLogic

@jeanbritz
Copy link
Author

jeanbritz commented Mar 2, 2025

Hi @leleuj
This PR is still in a WIP state as I need to figure out how to make the skipResponse feature to work with the updated pac4j-core library.
Let me know if I am on the right track, because I might want to write additional tests

@jeanbritz jeanbritz marked this pull request as draft March 2, 2025 19:26
context.getAbsolutePath(defaultUrl, false), renewSession, defaultClient);
protected void filter(Config config, ContainerRequestContext requestContext) throws IOException {
JaxRsFrameworkParameters frameworkParameters = new JaxRsFrameworkParameters(providers, requestContext);
buildLogic(config).perform(config, getAbsolutePath(requestContext, defaultUrl, false), renewSession, defaultClient, frameworkParameters);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this was already missing, but I think we also need: FrameworkAdapter.INSTANCE.applyDefaultSettingsIfUndefined(config); in the callback as well as in the logout and security filter.

localLogout, destroySession, centralLogout);
protected void filter(Config config, ContainerRequestContext requestContext) throws IOException {
JaxRsFrameworkParameters frameworkParameters = new JaxRsFrameworkParameters(providers, requestContext);
buildLogic(config).perform(config, defaultUrl, getAbsolutePath(requestContext, logoutUrlPattern, false), localLogout, destroySession, centralLogout, frameworkParameters);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same feedback here


// Note: basically, there is two possible outcomes:
// either the access is granted or there was an error or a redirect!
// For the former, we do nothing (see SecurityGrantedAccessOutcome comments)
// For the later, we interpret the error and abort the request using jax-rs
// abstractions
buildLogic(config).perform(context, sessionStore, config, new SecurityGrantedAccessOutcome(), adapter(config),
clients, authorizers, matchers);
buildLogic(config).perform(config, new SecurityGrantedAccessOutcome(), clients, authorizers, matchers, frameworkParameters);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same again here: the FrameworkAdapter.INSTANCE.applyDefaultSettingsIfUndefined(config); is only in the AbstractFilter, is it really used here? It's an initialization call which should be done "everywhere".

import org.pac4j.core.context.FrameworkParameters;
import org.pac4j.jax.rs.helpers.ProvidersContext;

public class JaxRsFrameworkParameters implements FrameworkParameters {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add some Javadoc (even obvious).

@@ -79,8 +79,8 @@
</scm>

<properties>
<pac4j.version>5.7.7</pac4j.version>
<java.version>11</java.version>
<pac4j.version>6.1.1</pac4j.version>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we upgrade pac4j release but we should also upgrade the version of library itself: v7.0.0-SNAPSHOT.

The README should be updated as well.

@leleuj
Copy link
Member

leleuj commented Mar 3, 2025

Please find a few feedbacks to help you in the migration process. Notice that the wiki: https://github.com/pac4j/jax-rs-pac4j/wiki will also need some updates (later on).

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.

2 participants