I need to apply an authentication filter to just some methods of servlets. The filter checks the validity of a JWT passed as a header key in the request.
For example, the session endpoint has a POST (log in, public) and a DELETE (log out, needs auth) method. Maybe I can split this two into a logout and login servlet but in the case I have resource endpoints that need auth to POST (create) and don't need auth to GET, a filter is impossible to apply and creating two separate servlets for each method is a pain to manage in a large scale app.
Is there a solution to this by just using servlets without any framework?
Apart from this, in the case I would apply the filter to "/secure" path, isn't this really user unfriendly? (To access a url that says "secure" or "public").