You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by Luciano Resende <lu...@gmail.com> on 2008/09/16 00:23:30 UTC
Handling user credentials, was Re: Reinstating policy handlers
If I understood it correctly from my quick review, it looks like the
user basic credentials (user name, password) is being provided in the
definitions file :
<tuscany:wsBasicAuthentication>
<tuscany:userName>myname</tuscany:userName>
<tuscany:password>mypassword</tuscany:password>
</tuscany:wsBasicAuthentication>
I have a security concern about exposing the credential in plain text,
but I guess this is just for now, right ?
And, another question is more related to how can we check the current
user access to the service (e.g current user credentials versus one
credential for all users). Thinking more towards Web 2.0/HTTP
applications, I was thinking on returning a 401 HTTP Error
(not-authenticated)if the credentials were not available on the
headers, and let the application handle how it want to retrieve the
current user credentials (either by prompting, or retrieving from some
other means), For non HTTP applications, maybe we could use some way
to signalize the application that no credentials were provided (e.g
exceptions) but this scenario needs more investigation (at least on my
side).
On Mon, Sep 15, 2008 at 1:46 AM, Simon Laws <si...@googlemail.com> wrote:
>
>
> On Thu, Sep 11, 2008 at 1:42 PM, Simon Laws <si...@googlemail.com>
> wrote:
>>
>>
>> On Wed, Sep 3, 2008 at 8:36 AM, Simon Laws <si...@googlemail.com>
>> wrote:
>>>
>>>
>>> On Tue, Sep 2, 2008 at 6:54 PM, Jean-Sebastien Delfino
>>> <js...@apache.org> wrote:
>>>>
>>>> Simon Laws wrote:
>>>>>
>>>>>
>>>>> On Tue, Sep 2, 2008 at 6:40 PM, Simon Laws <simonslaws@googlemail.com
>>>>> <ma...@googlemail.com>> wrote:
>>>>>
>>>>> snip...
>>>>>
>>>>>
>>>>>
>>>>> I'm in the process of reinstating policy handlers (they are
>>>>> currently deprecated) and updating the policy providers to
>>>>> create them. I want policy handlers to be binding or
>>>>> implementation specific. I propose we change the likes of
>>>>>
>>>>>
>>>>> Maybe I'm not understanding, but why aren't these just policy
>>>>> interceptors then?
>>>>>
>>>>>
>>>>>
>>>>> Some things that policy needs to configure are particular to the
>>>>> internals of a binding (I assume the same thing is true of
>>>>> implementations), e.g. in adding basic auth to web services I need
>>>>> to get in and set options in the axis operation client. Not the sort
>>>>> of thing I could do in an interceptor as even if I had access to the
>>>>> native message I would have access to the binding context use to
>>>>> send the message.
>>>>>
>>>>> Simon
>>>>>
>>>>>
>>>>> oops....
>>>>>
>>>>> I wouldn't have access to the binding context used to send the message.
>>>>>
>>>>> Simon
>>>>
>>>> Still not getting it, when your particular policy processing is tied to
>>>> the particular binding, why not just code it in the binding provider or
>>>> invoker then? Why would you need yet another handler concept?
>>>>
>>>> --
>>>> Jean-Sebastien
>>>
>>> Ok, well the reason I don't code it in the provider or invoker is that
>>> the code that gets hold of the username/password is not specific to the ws
>>> binding. Anyhow I think the best thing to do is for me to check the code in,
>>> if I can get trunk to compile, and we can then discuss around it. I've no
>>> problem in morphing it into something else once we agree what the good/bad
>>> bits are.
>>>
>>> Simon
>>
>> I forgot to post here that I have checked the code in. There are some
>> changes to binding-ws-axis2 and a new authentication.basic package under the
>> policy-security module. I'm now looking to apply the same pattern to a token
>> based authentication scenario to see if it still works.
>>
>> Simon
>
> I've just checked in so more code related to policy implementations.
> Following on from basic authentication set I've added a token authentication
> implementation. This raises slightly different questions as the token flows
> in the message header and I've applied it to both binding.ws and
> binding.jms. I've been looking at how easy to use the provider based plug
> points without using the old handler structures and my conclusion is
> probably 5 out of 10 at the moment. Some background...
>
> The token authentication scenario is documented at [1] (look for Policy
> Scenarios/Authentication - User Defined). I implemented binding specific
> policy for both binding.ws (Axis2TokenAuthenticationPolicy) and binding.jms
> (JMSTokenAuthenticationPolicy). This policy has the effect of installing
> reference and service interceptors to add and retrieve token headers
> to/from the Tuscany message respectively. In the latter case the token
> header is turned into a principal in the subject hanging off the QoS
> context. There is also hard coded policy processing in the bindings to
> translate the Tuscany message headers to/from native message headers. I also
> extended SecurityIdentity to add a implementation interceptor to ensure that
> the implementation gets the correct subject. The default though is to use
> the callers identity so this interceptor doesn't do anything in this
> scenario.
>
> There is a summary of how the policies in the definitions.xml file affect
> the runtime at [1] in the picture titled "Example of how binding.ws is
> configured in this scenario"
>
> There aren't too many unit tests at the momen but
> itest/policy-security-token and itest/policy-security-basicauth both
> demonstrate these policy implementations in action to the extent that they
> add and retrieve things from native and Tuscany messages. Note though that
> they don't actually do any authentication.
>
> If you look at the way that these policies work you see that the
> reference/service interceptors add/remove information from the Tuscany
> message and are pluggable. Harcoded logic in the bindings tests for the
> presence of the policy, when a specific policy is active, and translates
> between the tuscany message and the native message. In theory this sounds
> right but in practice these two pieces together feel cumbersome. This is
> mainly because there is no set interface between the pluggable bit and the
> hardcoded bit other than an assumption about what information will be found
> in the Tuscany message.
>
> My first thought is to define some more generic policies that can be applied
> to bindings, for example, I made an Axis2 header policy, but we still need a
> clear way of liking the output of the specific polices to the input of the
> generic policies or vise versa.
>
> Any comments are most welcome.
>
> Regards
>
> Simon
>
> [1] http://cwiki.apache.org/confluence/display/TUSCANYWIKI/Policy
>
--
Luciano Resende
Apache Tuscany, Apache PhotArk
http://people.apache.org/~lresende
http://lresende.blogspot.com/
Re: Handling user credentials, was Re: Reinstating policy handlers
Posted by Simon Laws <si...@googlemail.com>.
On Mon, Sep 15, 2008 at 11:23 PM, Luciano Resende <lu...@gmail.com>wrote:
> If I understood it correctly from my quick review, it looks like the
> user basic credentials (user name, password) is being provided in the
> definitions file :
>
> <tuscany:wsBasicAuthentication>
> <tuscany:userName>myname</tuscany:userName>
> <tuscany:password>mypassword</tuscany:password>
> </tuscany:wsBasicAuthentication>
>
>
> I have a security concern about exposing the credential in plain text,
> but I guess this is just for now, right ?
>
> And, another question is more related to how can we check the current
> user access to the service (e.g current user credentials versus one
> credential for all users). Thinking more towards Web 2.0/HTTP
> applications, I was thinking on returning a 401 HTTP Error
> (not-authenticated)if the credentials were not available on the
> headers, and let the application handle how it want to retrieve the
> current user credentials (either by prompting, or retrieving from some
> other means), For non HTTP applications, maybe we could use some way
> to signalize the application that no credentials were provided (e.g
> exceptions) but this scenario needs more investigation (at least on my
> side).
>
>
> On Mon, Sep 15, 2008 at 1:46 AM, Simon Laws <si...@googlemail.com>
> wrote:
> >
> >
> > On Thu, Sep 11, 2008 at 1:42 PM, Simon Laws <si...@googlemail.com>
> > wrote:
> >>
> >>
> >> On Wed, Sep 3, 2008 at 8:36 AM, Simon Laws <si...@googlemail.com>
> >> wrote:
> >>>
> >>>
> >>> On Tue, Sep 2, 2008 at 6:54 PM, Jean-Sebastien Delfino
> >>> <js...@apache.org> wrote:
> >>>>
> >>>> Simon Laws wrote:
> >>>>>
> >>>>>
> >>>>> On Tue, Sep 2, 2008 at 6:40 PM, Simon Laws <
> simonslaws@googlemail.com
> >>>>> <ma...@googlemail.com>> wrote:
> >>>>>
> >>>>> snip...
> >>>>>
> >>>>>
> >>>>>
> >>>>> I'm in the process of reinstating policy handlers (they
> are
> >>>>> currently deprecated) and updating the policy providers to
> >>>>> create them. I want policy handlers to be binding or
> >>>>> implementation specific. I propose we change the likes of
> >>>>>
> >>>>>
> >>>>> Maybe I'm not understanding, but why aren't these just policy
> >>>>> interceptors then?
> >>>>>
> >>>>>
> >>>>>
> >>>>> Some things that policy needs to configure are particular to the
> >>>>> internals of a binding (I assume the same thing is true of
> >>>>> implementations), e.g. in adding basic auth to web services I need
> >>>>> to get in and set options in the axis operation client. Not the
> sort
> >>>>> of thing I could do in an interceptor as even if I had access to
> the
> >>>>> native message I would have access to the binding context use to
> >>>>> send the message.
> >>>>>
> >>>>> Simon
> >>>>>
> >>>>>
> >>>>> oops....
> >>>>>
> >>>>> I wouldn't have access to the binding context used to send the
> message.
> >>>>>
> >>>>> Simon
> >>>>
> >>>> Still not getting it, when your particular policy processing is tied
> to
> >>>> the particular binding, why not just code it in the binding provider
> or
> >>>> invoker then? Why would you need yet another handler concept?
> >>>>
> >>>> --
> >>>> Jean-Sebastien
> >>>
> >>> Ok, well the reason I don't code it in the provider or invoker is that
> >>> the code that gets hold of the username/password is not specific to the
> ws
> >>> binding. Anyhow I think the best thing to do is for me to check the
> code in,
> >>> if I can get trunk to compile, and we can then discuss around it. I've
> no
> >>> problem in morphing it into something else once we agree what the
> good/bad
> >>> bits are.
> >>>
> >>> Simon
> >>
> >> I forgot to post here that I have checked the code in. There are some
> >> changes to binding-ws-axis2 and a new authentication.basic package under
> the
> >> policy-security module. I'm now looking to apply the same pattern to a
> token
> >> based authentication scenario to see if it still works.
> >>
> >> Simon
> >
> > I've just checked in so more code related to policy implementations.
> > Following on from basic authentication set I've added a token
> authentication
> > implementation. This raises slightly different questions as the token
> flows
> > in the message header and I've applied it to both binding.ws and
> > binding.jms. I've been looking at how easy to use the provider based plug
> > points without using the old handler structures and my conclusion is
> > probably 5 out of 10 at the moment. Some background...
> >
> > The token authentication scenario is documented at [1] (look for Policy
> > Scenarios/Authentication - User Defined). I implemented binding specific
> > policy for both binding.ws (Axis2TokenAuthenticationPolicy) and
> binding.jms
> > (JMSTokenAuthenticationPolicy). This policy has the effect of installing
> > reference and service interceptors to add and retrieve token headers
> > to/from the Tuscany message respectively. In the latter case the token
> > header is turned into a principal in the subject hanging off the QoS
> > context. There is also hard coded policy processing in the bindings to
> > translate the Tuscany message headers to/from native message headers. I
> also
> > extended SecurityIdentity to add a implementation interceptor to ensure
> that
> > the implementation gets the correct subject. The default though is to use
> > the callers identity so this interceptor doesn't do anything in this
> > scenario.
> >
> > There is a summary of how the policies in the definitions.xml file affect
> > the runtime at [1] in the picture titled "Example of how binding.ws is
> > configured in this scenario"
> >
> > There aren't too many unit tests at the momen but
> > itest/policy-security-token and itest/policy-security-basicauth both
> > demonstrate these policy implementations in action to the extent that
> they
> > add and retrieve things from native and Tuscany messages. Note though
> that
> > they don't actually do any authentication.
> >
> > If you look at the way that these policies work you see that the
> > reference/service interceptors add/remove information from the Tuscany
> > message and are pluggable. Harcoded logic in the bindings tests for the
> > presence of the policy, when a specific policy is active, and translates
> > between the tuscany message and the native message. In theory this sounds
> > right but in practice these two pieces together feel cumbersome. This is
> > mainly because there is no set interface between the pluggable bit and
> the
> > hardcoded bit other than an assumption about what information will be
> found
> > in the Tuscany message.
> >
> > My first thought is to define some more generic policies that can be
> applied
> > to bindings, for example, I made an Axis2 header policy, but we still
> need a
> > clear way of liking the output of the specific polices to the input of
> the
> > generic policies or vise versa.
> >
> > Any comments are most welcome.
> >
> > Regards
> >
> > Simon
> >
> > [1] http://cwiki.apache.org/confluence/display/TUSCANYWIKI/Policy
> >
>
>
>
> --
> Luciano Resende
> Apache Tuscany, Apache PhotArk
> http://people.apache.org/~lresende <http://people.apache.org/%7Elresende>
> http://lresende.blogspot.com/
>
Hi Luciano
Having the username/password in the policy itself is just a testing
convenience at the moment. It may be useful for some but I wouldn't
recommend it. Remeber though that with basic authentication these
credentials are only base 64 encoded on the wire so this approach is not
what you might call secure. The emphasis should be on providing a suitable
implementation of the interceptors,
BasicAuthenticationReferencePolicyInterceptor and
BasicAuthenticationServicePolicyInterceptor, where appropriate logic can be
included to call out to whatever system you need to to retrieve and
authenticate credentials.
In this basic auth case you could reasonably expect to have the HTTP service
configured to do basic authentication so maybe the service side doesn't need
to do much other than pass on the Subject (I haven't created any logic yet
to automatically configure the Tomcat/Jetty services that get created
automatically by Tuscany).
One thing that does concern my here relates to the multiplicy on
interceptors. If say I wanted a particular credential retrieveal scheme I
could build a new BasicAuthenticationReferencePolicyInterceptor
implemenation and have that added to the wire whenever
BasicAuthenticationPolicy is found. However if I need a different basic auth
credential retrieval scheme somewhere else in my domain I can't go and
create another interceptor. I still need to use BasicAuthenticationPolicyas
that is what binding.ws looks for when translating basic auth crendentials
from Tuscany messages into native messages. This is what I meant but the
provider approach feeling cumbersome.
Some solutions to this...
Put a scheme selector on the policy so the interceptor can decide what to
do
Have a binding specific policy and a generic policy and bind the two
together using BasicAuthPrincipal
Instigate some other plug point for policies (BasicAuthPolicy in this
case) that bindings can use to get the binding specific part. Implies a new
SPI
If appropriate credentials are not available when thy should be we should be
providing runtime exceptions to indicated this. On the refrence side the
interceptor would be responsbile for determining whether the source
credentials are approriate. Once the request goes out on the wire
Simon