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

Using provider instead of HttpServletRequest in ServletJaxRsContextFactoryProvider #42

Merged
merged 6 commits into from
May 14, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ These filters can be directly registered by hand, or instead, the following feat
5) Container/Implementation-specific Providers and Features extend the basic functionality provided by the generic ones

- The `Pac4JValueFactoryProvider` enables injection of the security profile in resource method (for Apache Jersey <2.26, see [#30](https://github.com/pac4j/jax-rs-pac4j/issues/30))
- The `ServletJaxRsContextFactoryProvider` provides session handling (and thus indirect clients support) by replacing the generic `JaxRsContextFactoryProvider` (for Servlet-based JAX-RS implementations, e.g., Jersey on Netty or Grizzly Servlet, Resteasy on Undertow). This provider returns a RequestScoped context and so should be added as a class `ServletJaxRsContextFactoryProvider.class` instead of instance `new ServletJaxRsContextFactoryProvider()`. For RestEasy, you need to include `resteasy-cdi` support to your project. Refer to the tests in `resteasy-pac4j` module.
- The `ServletJaxRsContextFactoryProvider` provides session handling (and thus indirect clients support) by replacing the generic `JaxRsContextFactoryProvider` (for Servlet-based JAX-RS implementations, e.g., Jersey on Netty or Grizzly Servlet, Resteasy on Undertow).
- The `GrizzlyJaxRsContextFactoryProvider` provides session handling (and thus indirect clients support) by replacing the generic `JaxRsContextFactoryProvider` (for Grizzly2 without Servlet support).

---
Expand All @@ -50,7 +50,7 @@ You need to add a dependency on:

- jax-rs-pac4j
1. for Jersey (<2.26) : the `jersey-pac4j` library (<em>groupId</em>: **org.pac4j**, *version*: **3.0.0**)
2. for Resteasy : the `resteasy-pac4j` library (<em>groupId</em>: **org.pac4j**, *version*: **3.0.0**)
2. for Resteasy : the `resteasy-pac4j` library (<em>groupId</em>: **org.pac4j**, *version*: **3.0.0**) and resteasy-cdi for CDI support
Copy link
Member

Choose a reason for hiding this comment

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

add backquotes around resteasy-cdi please

- the appropriate `pac4j` [submodules](http://www.pac4j.org/docs/clients.html) (<em>groupId</em>: **org.pac4j**, *version*: **2.1.0**): `pac4j-oauth` for OAuth support (Facebook, Twitter...), `pac4j-cas` for CAS support, `pac4j-ldap` for LDAP authentication, etc.

All released artifacts are available in the [Maven central repository](http://search.maven.org/#search%7Cga%7C1%7Cpac4j).
Expand Down Expand Up @@ -122,7 +122,7 @@ resourceConfig
For a Jersey-based and Servlet-based (e.g., Jetty or Grizzly Servlet) environment with session management, annotation support and method parameters injection:
```java
resourceConfig
.register(new ServletJaxRsContextFactoryProvider(config))
.register(ServletJaxRsContextFactoryProvider.class)
.register(new Pac4JSecurityFeature(config))
.register(new Pac4JValueFactoryProvider.Binder());
```
Expand All @@ -144,13 +144,20 @@ For a Resteasy-based and Servlet-based (e.g., Undertow) environment with session
public Set<Object> getSingletons() {
Config config = getConfig();
Set<Object> singletons = new HashSet<>();
singletons.add(new ServletJaxRsContextFactoryProvider(config));
singletons.add(new Pac4JSecurityFeature(config));
singletons.add(new Pac4JProfileInjectorFactory());
return singletons;
}

@Override
public Set<Class<?>> getClasses() {
Set<Class<?>> classes = new HashSet<>();
classes.add(ServletJaxRsContextFactoryProvider.class);
Copy link
Member

Choose a reason for hiding this comment

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

Pac4JProfileInjectorFactory needs to be moved too, I tested and it doesn't work without it

return classes;
}
}
```
For RestEasy, you need to include `resteasy-cdi` support to your project to ensure that dependencies are injected at runtime. Refer to the tests in `resteasy-pac4j` module.

Note that a default value for the `clients` parameter of the `@Pac4JSecurity`
annotation can be passed to the constructor of `Pac4JSecurityFeature`.
Expand Down