jakartaee / jakartaee/security
Mechanism to define security interceptors using *AuthenticationMechanismDefinition
@arjantijms is already working on this.
Since Sep 23, 2021.
- Dominant language
- Java
- Stars
- 66
- Forks
- 43
- PR merge metrics
- No merged PRs in 30d
Description
In Jakarta EE security we have various interceptors that add functionality to authentication mechanisms, such as `@AutoApplySession` and `@RememberMe`. Those are easy to add to custom authentication mechanisms, but at the moment not trivial to add to the build-in ones.
#192 seeks to add interceptors fully dynamically to a bean.
Alternatively, or perhaps additionally, we can allow interceptors to be defined right away using the `*AuthenticationMechanismDefinition` such as `BasicAuthenticationMechanismDefinition`.
For instance using a type reference:
```java
@BasicAuthenticationMechanismDefinition(
realmName="test",
interceptorsFromType = Servlet.BasicInterceptors.class
)
@WebServlet("/servlet")
public class Servlet extends HttpServlet {
@RememberMe(
cookieMaxAgeSeconds = 86400,
cookieSecureOnly = false,
isRememberMeExpression ="#{self.isRememberMe(httpMessageContext)}"
)
public static Class BasicInterceptors {
public Boolean isRememberMe(HttpMessageContext httpMessageContext) {
return httpMessageContext.getRequest().getParameter("rememberme") != null;
}
}
```
Or from an EL expression:
```java
@BasicAuthenticationMechanismDefinition(
realmName="test",
interceptors = "#{self.interceptors}"
)
@WebServlet("/servlet")
public class Servlet extends HttpServlet {
List getInterceptors() {
return List.of(
RememberMe.Literal.of(
86400, "",
false, "",
true, "",
"JREMEMBERMEID",
true, "#{not empty httpMessageContext.request.getParameter('rememberme')}"
));
}
}
```
Or using stereotypes?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.