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

Mechanism to define security interceptors using *AuthenticationMechanismDefinition #200

Open
arjantijms opened this issue Sep 23, 2021 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@arjantijms
Copy link
Contributor

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:

@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:

@BasicAuthenticationMechanismDefinition(
    realmName="test",
    interceptors = "#{self.interceptors}"
)
@WebServlet("/servlet")
public class Servlet extends HttpServlet {

    List<Annotation> getInterceptors() {
        return List.of(
             RememberMe.Literal.of(
                86400, "",
                false, "",
                true, "",
                "JREMEMBERMEID",
                true, "#{not empty httpMessageContext.request.getParameter('rememberme')}"
            ));
    }
   
}
@arjantijms arjantijms added the enhancement New feature or request label Sep 23, 2021
@arjantijms arjantijms added this to the 3.0 milestone Sep 23, 2021
@arjantijms arjantijms self-assigned this Sep 23, 2021
@arjantijms arjantijms modified the milestones: 3.0, 3.1 Jun 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant