jakartaee / jakartaee/security

Mechanism to define security interceptors using *AuthenticationMechanismDefinition

Open
#200 0 comments 0 reactions 1 assignee View on GitHub

@arjantijms is already working on this.

Since Sep 23, 2021.

enhancement
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.