I have the following in my appweb.conf:
Code:
<Location />
SetHandler ejsHandler
EjsApp on
EjsSession off
EjsSessionTimeout 60
Alias / /home/chl/heating/cathheat
</Location>
<Directory /home/chl/heating/cathheat/web/Foo>
AuthDigestQop auth
AuthUserFile /home/chl/heating/cathheat/users.db
AuthMethod File
AuthName cathheat
AuthType Digest
Require valid-user
</Directory>
and I am seeking to download
/web/Foo/foo.html, which is both within the Location and within the Directory. So it knows it is within an App, and it knows that its first choice of handler is EjsHandler. But it soon realises that FileHandler is the proper thing to use for this html page. So, in
pipeline.c it has tried
findLocationHandler and then
findHandlerByExtension and, since neither has found a handler it proceeds to
mapToFile, which calls
maLookupBestDir, which discovers that this directory requires authentication and arranges to put the proper authentication filter in the pipeline, and off it goes. The browser pops up a window asking for
username and
password, and all proceeds correctly and the authentication is accepted and the page displayed. So far so good.
BUT now I try to download
/web/Foo/foo.ejs, and this time it finds, in
findHandlerByExtension, that the EjsHandler is appropriate, so it doesn't need to call
mapToFile, and therefore it never calls
maLookupBestDir (which is only ever called from
mapToFile), and hence it doesn't know that authentication is needed, and it serves up the page without it :-(.
NOT SO GOOD! A bug in fact.
ISTM that another call to
maLookupBestDir is needed somewhere (perhaps within
findHandlerByExtension), but I will leave it to you guys to fix that.
Now for the second Bug (or misfeature?). I see that, following RFC 2617 for the Digest method, it first returns a challenge with a
WWW-Authenticate header containing a nonce value. The browser returns the
username with the
password hashed using this nonce value (in an
Authorization header) which the server then compares with
users.db and, if it matches in the proper way (clearly I have simplified the precise details) it releases the page.
Again, So Far so Good, An eavesdropper cannot discover the password.
BUT the server makes no attempt to check that the nonce the browser has used in the
Authorization header is the same as the nonce that it had earlier sent in the
WWW-Authenticate header, and this is clearly contrary to the intent of RFC 2617, since it leaves the door wide open to a Replay Attack by the eavesdropper, who can now submit that same
Authorization header weeks later when the nonce is long expired, and he will be let in to view the page.
BUG, rather than Misfeature IMHO :-(.