You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Vincent Massol <vm...@octo.com> on 2002/01/03 20:17:27 UTC
[HttpClient] Support for Basic and Form-based authentication ?
Hi,
I'd like to know if HttpClient currently supports any authentication
scheme (basic, form-based) ? If not, is someone working on this ? If no,
do you think it would be good to add it ?
The end story is that I need to add basic and form-authentication to
Cactus (We actually have the code for it as Jason Robertson has
submitted it on the Cactus mailing-list) but I also wanted to move the
HTTP connection to HttpClient (instead of using HttpURLConnection and my
own code on top of it). Of course, I would prefer not to reinvent the
wheel and have a clean separation of concerns, which is why I am asking
this here: Do you think authentication is too application-centric for
HttpClient or do you think it is in scope ?
Thanks
-Vincent
_______________________
Vincent Massol
Managing Director
OCTO Technology UK Ltd
www.octo.com
vmassol@octo.com
Tel: (020) 8996 9540
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: [HttpClient] Support for Basic and Form-based authentication ?
Posted by "Paul C. Bryan" <em...@pbryan.net>.
Vincent Massol wrote:
> I think I agree with you ... ;-). Let's keep it outside of HttpClient
> (unless other chime in and think it should be in in which case we could
> reopen the discussion).
:)
> However, what would be nice is to provide authentication interfaces so
> that it is possible for an application to plug in its own authentication
> scheme.
I have implemented a number of authentication schemes around the
HttpClient library -- for Lotus Domino, WebLogic and iPlanet Software.
Domino and iPlanet were configured to use form-based authentication,
while WebLogic was configured to use HTTP basic.
Unfortunately, my work was performed under contract, and I am not at
liberty to disclose it, otherwise, I would have been happy to share it
here as a reference.
Building custom authentication modules is relatively easy -- simply code
that makes an HTTP request to a particular URL with parameters in the
query string, and some simple code to verify whether the authentication
was successful or not.
I can envision a library that wraps the HttpClient library to provide
this feature, allowing the context of the resulting session to be
represented through cookie(s) in the HttpState object. This would not be
too complicated to implement.
> Do you know If this already exists ? If so, is there some documentation
> or could you explain in a few words how I would plug in my own
> authentication scheme ?
I'm not aware of any other implementations. Perhaps others may mention
one here in this list.
Performing form-based authentication is as simple as establishing a
connection to a server, making a request with the right credential
parameters, and parsing the response to ensure successful
authentication. If cookies are used for further session identification,
the HttpClient will take care of the rest automagically.
HTTP basic authentication is even easier, because you simply set the
credentials in the HttpState object before using it in a method (such as
GetMethod). You can leave the HTTP credentials set in the HttpState
object, which you should use in each subsequent request. If
authentication fails, then it's evident in the response code.
Yours truly,
Paul C. Bryan <em...@pbryan.net>
http://pbryan.net/
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: [HttpClient] Support for Basic and Form-based authentication ?
Posted by Vincent Massol <vm...@octo.com>.
> -----Original Message-----
> From: Paul C. Bryan [mailto:email@pbryan.net]
> Sent: 03 January 2002 22:20
> To: Jakarta Commons Developers List
> Subject: Re: [HttpClient] Support for Basic and Form-based
authentication
> ?
>
> Vincent Massol wrote:
>
> > Is the following algorithm non-standard ? :
> >
> > * Try to call a given secured page
> > * In the HTTP response, check if a Location header field matching a
> > given page (the login page) has been returned. If so, it means we
need
> > to log the user
> > * Get the jsession id cookie from the returned response
> > * Send a POST request to j_security_check, passing the following in
the
> > request :
> > - jsession id cookie,
> > - j_username POST parameter,
> > - j_password POST parameter
> > * Retry the original URL
> >
> > In the end, the user either get the requested page or some failure
page
> > defined by the application (we could decide not to handle failure
page
> > in HttpClient or we could handle it).
> >
> > In summary the parameters to pass to HttpClient from the application
> > would be :
> > - login page
> > - servername + contextRoot (for building the j_security_check URL :
> > http:// + serverName + contextRoot. Ex:
http://my.server:8080/mywebapp)
> > - user name
> > - password
> >
> > Am I missing something ? From your list of issues, ack and failure
could
> > be left to applicationm, state mechanism is standard for Servlets
API
> > .... ahah maybe here is the trick. What you are saying is that it is
non
> > standard across technologies. Right, but at least it is standard in
a
> > given technology, like Servlets, so maybe we could provide a
> > ServletFormAuthentication that would extend FormAuthentication
(which
> > would have a setUserNameParameterName(), setPasswordNameParameter(),
> > setSecurityCheckURL() and setSessionCookieName()), which would
itself
> > extend Authentication (which would have the notion of username,
password
> > of the client side API and validation of username/password, HTTP
> > configuration and response handling on the SPI side ?
>
>
> The purpose of the HttpClient library is to provide a full client
> implementation of the HTTP protocol, such that any application can use
> it to implement an HTTP client.
>
> What you are proposing is the addition of application-specific support
> for authentication with a Java Servlet using form-based
authentication.
> In my opinion, this is outside the scope of the HttpClient.
>
> Such a library could be built using the HttpClient library, extending
it
> to support server-specific authentication methods using a flexible and
> extensible architecture.
>
> Such a library should remain separate and distinct from HttpClient
IMHO.
>
> If, sometime in the future, an HTTP standard emerges that provides
> form-based authentication, I'd be supportive of its inclusion in the
> HttpClient library.
>
I think I agree with you ... ;-). Let's keep it outside of HttpClient
(unless other chime in and think it should be in in which case we could
reopen the discussion).
However, what would be nice is to provide authentication interfaces so
that it is possible for an application to plug in its own authentication
scheme.
Do you know If this already exists ? If so, is there some documentation
or could you explain in a few words how I would plug in my own
authentication scheme ?
Thanks Bryan. I appreciate your help.
-Vincent
> Yours truly,
>
> Paul C. Bryan <em...@pbryan.net>
> http://pbryan.net/
>
>
> --
> To unsubscribe, e-mail: <mailto:commons-dev-
> unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:commons-dev-
> help@jakarta.apache.org>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: [HttpClient] Support for Basic and Form-based authentication ?
Posted by "Paul C. Bryan" <em...@pbryan.net>.
Vincent Massol wrote:
> Is the following algorithm non-standard ? :
>
> * Try to call a given secured page
> * In the HTTP response, check if a Location header field matching a
> given page (the login page) has been returned. If so, it means we need
> to log the user
> * Get the jsession id cookie from the returned response
> * Send a POST request to j_security_check, passing the following in the
> request :
> - jsession id cookie,
> - j_username POST parameter,
> - j_password POST parameter
> * Retry the original URL
>
> In the end, the user either get the requested page or some failure page
> defined by the application (we could decide not to handle failure page
> in HttpClient or we could handle it).
>
> In summary the parameters to pass to HttpClient from the application
> would be :
> - login page
> - servername + contextRoot (for building the j_security_check URL :
> http:// + serverName + contextRoot. Ex: http://my.server:8080/mywebapp)
> - user name
> - password
>
> Am I missing something ? From your list of issues, ack and failure could
> be left to applicationm, state mechanism is standard for Servlets API
> .... ahah maybe here is the trick. What you are saying is that it is non
> standard across technologies. Right, but at least it is standard in a
> given technology, like Servlets, so maybe we could provide a
> ServletFormAuthentication that would extend FormAuthentication (which
> would have a setUserNameParameterName(), setPasswordNameParameter(),
> setSecurityCheckURL() and setSessionCookieName()), which would itself
> extend Authentication (which would have the notion of username, password
> of the client side API and validation of username/password, HTTP
> configuration and response handling on the SPI side ?
The purpose of the HttpClient library is to provide a full client
implementation of the HTTP protocol, such that any application can use
it to implement an HTTP client.
What you are proposing is the addition of application-specific support
for authentication with a Java Servlet using form-based authentication.
In my opinion, this is outside the scope of the HttpClient.
Such a library could be built using the HttpClient library, extending it
to support server-specific authentication methods using a flexible and
extensible architecture.
Such a library should remain separate and distinct from HttpClient IMHO.
If, sometime in the future, an HTTP standard emerges that provides
form-based authentication, I'd be supportive of its inclusion in the
HttpClient library.
Yours truly,
Paul C. Bryan <em...@pbryan.net>
http://pbryan.net/
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: [HttpClient] Support for Basic and Form-based authentication ?
Posted by Vincent Massol <vm...@octo.com>.
> -----Original Message-----
> From: Paul C. Bryan [mailto:email@pbryan.net]
> Sent: 03 January 2002 20:12
> To: Jakarta Commons Developers List
> Subject: Re: [HttpClient] Support for Basic and Form-based
authentication
> ?
>
> Vincent Massol wrote:
>
> > I'd like to know if HttpClient currently supports any authentication
> > scheme (basic, form-based) ? If not, is someone working on this ? If
no,
> > do you think it would be good to add it ?
>
>
> The HttpClient library currently supports HTTP basic authentication.
>
> As there are no standards for form-based authentication
(acknowledgement
> of success, failure, state mechanisms, and so on), it is up to the
> application to implement site-specific form-based authentication
schemes.
Is the following algorithm non-standard ? :
* Try to call a given secured page
* In the HTTP response, check if a Location header field matching a
given page (the login page) has been returned. If so, it means we need
to log the user
* Get the jsession id cookie from the returned response
* Send a POST request to j_security_check, passing the following in the
request :
- jsession id cookie,
- j_username POST parameter,
- j_password POST parameter
* Retry the original URL
In the end, the user either get the requested page or some failure page
defined by the application (we could decide not to handle failure page
in HttpClient or we could handle it).
In summary the parameters to pass to HttpClient from the application
would be :
- login page
- servername + contextRoot (for building the j_security_check URL :
http:// + serverName + contextRoot. Ex: http://my.server:8080/mywebapp)
- user name
- password
Am I missing something ? From your list of issues, ack and failure could
be left to applicationm, state mechanism is standard for Servlets API
.... ahah maybe here is the trick. What you are saying is that it is non
standard across technologies. Right, but at least it is standard in a
given technology, like Servlets, so maybe we could provide a
ServletFormAuthentication that would extend FormAuthentication (which
would have a setUserNameParameterName(), setPasswordNameParameter(),
setSecurityCheckURL() and setSessionCookieName()), which would itself
extend Authentication (which would have the notion of username, password
of the client side API and validation of username/password, HTTP
configuration and response handling on the SPI side ?
Examples attached (provided by Jason).
Thanks
-Vincent
>
> > The end story is that I need to add basic and form-authentication to
> > Cactus (We actually have the code for it as Jason Robertson has
> > submitted it on the Cactus mailing-list) but I also wanted to move
the
> > HTTP connection to HttpClient (instead of using HttpURLConnection
and my
> > own code on top of it). Of course, I would prefer not to reinvent
the
> > wheel and have a clean separation of concerns, which is why I am
asking
> > this here: Do you think authentication is too application-centric
for
> > HttpClient or do you think it is in scope ?
>
>
> IMHO, I think form-based authentication is too application-centric for
> HttpClient, therefore out of scope. However, HTTP authentication is in
> HttpClient, right where it belongs.
>
> Yours truly,
>
> Paul C. Bryan <em...@pbryan.net>
> http://pbryan.net/
>
>
> --
> To unsubscribe, e-mail: <mailto:commons-dev-
> unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:commons-dev-
> help@jakarta.apache.org>
>
Re: [HttpClient] Support for Basic and Form-based authentication ?
Posted by "Paul C. Bryan" <em...@pbryan.net>.
Vincent Massol wrote:
> I'd like to know if HttpClient currently supports any authentication
> scheme (basic, form-based) ? If not, is someone working on this ? If no,
> do you think it would be good to add it ?
The HttpClient library currently supports HTTP basic authentication.
As there are no standards for form-based authentication (acknowledgement
of success, failure, state mechanisms, and so on), it is up to the
application to implement site-specific form-based authentication schemes.
> The end story is that I need to add basic and form-authentication to
> Cactus (We actually have the code for it as Jason Robertson has
> submitted it on the Cactus mailing-list) but I also wanted to move the
> HTTP connection to HttpClient (instead of using HttpURLConnection and my
> own code on top of it). Of course, I would prefer not to reinvent the
> wheel and have a clean separation of concerns, which is why I am asking
> this here: Do you think authentication is too application-centric for
> HttpClient or do you think it is in scope ?
IMHO, I think form-based authentication is too application-centric for
HttpClient, therefore out of scope. However, HTTP authentication is in
HttpClient, right where it belongs.
Yours truly,
Paul C. Bryan <em...@pbryan.net>
http://pbryan.net/
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>