On 29/03/18 19:07, Christopher Schultz wrote:
> Rémy,
> 
> On 3/29/18 11:41 AM, Rémy Maucherat wrote:
>> On Thu, Mar 29, 2018 at 3:48 PM, Christopher Schultz <
>> ch...@christopherschultz.net> wrote:
>>
>>> All,
>>>
>>> For reference: https://bz.apache.org/bugzilla/show_bug.cgi?id=59750
>>>
>>> I've got a proposal (in patch form) attached to that BZ issue.
>>>
>>> Ralf's enhancement request is fairly terse, but this is something I'd
>>> like to have as well.
>>>
>>> The requirement is to be able to log failed authentication attempts. As
>>> it stands, using container-managed authentication does not allow this
>>> (as far as I can tell).
>>>
>>> My proposal is essentially a new listener interface that authenticator
>>> classes will invoke (if registered) when an authentication event occurs
>>> (success or failure). The Request object and username are currently
>>> arguments to the two methods on the interface.
>>>
>>> You can read the entire current path without even scrolling your screen.
>>>
>>> Before attempting to publish a more complete patch, I wanted to know if
>>> there was any appetite for this kind of thing, or any objections.

I think this is better than changing the existing Realm.authenticate(*)
methods to add Request.

My biggest concern at this point is how does the listener get
registered? Might this be better as ContainerListener and two new
events? That reduces the plumbing required to make this work.

>> Ok with the idea, but the patch is indeed very incomplete.
> 
> Absolutely. I wanted to make sure there were no -1s before I spent much
> time on it. That represents maybe 5 minutes of work :)
> 
> Some specific questions:
> 
> For FormAuthenticator: there are several calls to authenticate() in
> doAuthenticate. I chose to ignore the call at the top of the method
> because I didn't understand the purpose. Something about
> re-authentication of a previous-authentication? Would it be appropriate
> to also fire an authentication event at that time?

I don't think so.

> For Basic/DigestAuthenticator: since technically the user is being
> authenticated at *every* request, should we bother trying to avoid
> spamming the Listener, or should we let the Listener decide how to
> handle the huge number of events it will likely get? Does Tomcat know
> whether the authentication is a re-authentication or not? If so, should
> it let the Listener know this is a re-authentication?

Let the listener solve that problem. There may be different ways that
are appropriate for different use cases (client IP, session ID, etc.)

> Implementing a listener in a webapp: can a listener be registered from
> within the web application without any ClassLoader weirdness?

Yes.

> What
> options exist for writing a listener that doesn't require a compile-time
> dependency on Tomcat? (I suspect this is unavoidable, because even if
> reflection is used to invoke the listener's method by *name* and not via
> an interface-call, the Tomcat-specific Request class is a parameter to
> the interface methods.

Use HttpServletRequest? Or do you need access to Tomcat specific internals?

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to