Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Security > form authentication and webservices

Reply
Thread Tools

form authentication and webservices

 
 
Abdullah
Guest
Posts: n/a
 
      02-09-2007
Hi..
I am using form authentication on a web site that consumes web services. Can
the identity of the user that is logged on to the web site passed to the web
services for the same authentication? if so, what would need to be
configuered?
Thanks a lot,
 
Reply With Quote
 
 
 
 
Dominick Baier
Guest
Posts: n/a
 
      02-09-2007
There is no out of the box support for FormsAuthentication for web service.
FormsAuth uses redirects and cookies - thats very non web service like.

That said you can implement that by using the FormsAuthentication API and
cookie support in the client proxy. This involves some testing and you have
to have a strategy how you handle ticket timeouts...

I would rather recommend using basic authentication or WS-Security with UsernameTokens...


-----
Dominick Baier (http://www.leastprivilege.com)

Developing More Secure Microsoft ASP.NET 2.0 Applications (http://www.microsoft.com/mspress/books/9989.asp)

> Hi.. I am using form authentication on a web site that consumes web
> services. Can the identity of the user that is logged on to the web
> site passed to the web services for the same authentication? if so,
> what would need to be configuered? Thanks a lot,
>



 
Reply With Quote
 
 
 
 
Abdullah
Guest
Posts: n/a
 
      02-09-2007
Dominick
Thanks for your prompt response.. it looks like i had a flow in my
architecture..
I will try to describe to you what I am trying to accomplish and maybe you
could guide me with an approach..

We're doing an e-business website, form authentication based on an external
active directory. On the same website, we created a bunch of webservices that
we would like them to be used only by the website. We also would like those
webservices to know the identity of the caller to perform some business
logic.

Having said all that, what would be your recommendation?
Thanks in advance for your great feedback, you just saved me a lot of
running around


"Dominick Baier" wrote:

> There is no out of the box support for FormsAuthentication for web service.
> FormsAuth uses redirects and cookies - thats very non web service like.
>
> That said you can implement that by using the FormsAuthentication API and
> cookie support in the client proxy. This involves some testing and you have
> to have a strategy how you handle ticket timeouts...
>
> I would rather recommend using basic authentication or WS-Security with UsernameTokens...
>
>
> -----
> Dominick Baier (http://www.leastprivilege.com)
>
> Developing More Secure Microsoft ASP.NET 2.0 Applications (http://www.microsoft.com/mspress/books/9989.asp)
>
> > Hi.. I am using form authentication on a web site that consumes web
> > services. Can the identity of the user that is logged on to the web
> > site passed to the web services for the same authentication? if so,
> > what would need to be configuered? Thanks a lot,
> >

>
>
>

 
Reply With Quote
 
Dominick Baier
Guest
Posts: n/a
 
      02-09-2007
Well - there are several ways to accomplish that.

The easiest is probably to configure an IP filter in IIS so that the web
services only takes requests from localhost.

You can pass the name of the authenticated client as a parameter or header.

Since you use active directory, you can also use windows authenticaiton for
the web services and restrict access to the windows identity that is used
to run the web application.


-----
Dominick Baier (http://www.leastprivilege.com)

Developing More Secure Microsoft ASP.NET 2.0 Applications (http://www.microsoft.com/mspress/books/9989.asp)

> Dominick
> Thanks for your prompt response.. it looks like i had a flow in my
> architecture..
> I will try to describe to you what I am trying to accomplish and
> maybe you
> could guide me with an approach..
> We're doing an e-business website, form authentication based on an
> external active directory. On the same website, we created a bunch of
> webservices that we would like them to be used only by the website. We
> also would like those webservices to know the identity of the caller
> to perform some business logic.
>
> Having said all that, what would be your recommendation? Thanks in
> advance for your great feedback, you just saved me a lot of running
> around
>
> "Dominick Baier" wrote:
>
>> There is no out of the box support for FormsAuthentication for web
>> service. FormsAuth uses redirects and cookies - thats very non web
>> service like.
>>
>> That said you can implement that by using the FormsAuthentication API
>> and cookie support in the client proxy. This involves some testing
>> and you have to have a strategy how you handle ticket timeouts...
>>
>> I would rather recommend using basic authentication or WS-Security
>> with UsernameTokens...
>>
>> -----
>> Dominick Baier (http://www.leastprivilege.com)
>> Developing More Secure Microsoft ASP.NET 2.0 Applications
>> (http://www.microsoft.com/mspress/books/9989.asp)
>>
>>> Hi.. I am using form authentication on a web site that consumes web
>>> services. Can the identity of the user that is logged on to the web
>>> site passed to the web services for the same authentication? if so,
>>> what would need to be configuered? Thanks a lot,
>>>



 
Reply With Quote
 
Abdullah
Guest
Posts: n/a
 
      02-09-2007
well, I think your idea about the ip filter (which I believe is the same
concept as IP tagging) will solve the authentication problem for sure. the
only missing piece of the puzzl is how to propagate the identity of the
caller (who signed in using form authentication) to the web services? The web
services logic will perform specific job based on the identity of the
caller.. plus, if an intruder managed to get control of the exposed IIS
machine, wouldn't be a trivel matter for him to call into the web services
then?
Thanks again for your time and helpfull answers..

"Dominick Baier" wrote:

> Well - there are several ways to accomplish that.
>
> The easiest is probably to configure an IP filter in IIS so that the web
> services only takes requests from localhost.
>
> You can pass the name of the authenticated client as a parameter or header.
>
> Since you use active directory, you can also use windows authenticaiton for
> the web services and restrict access to the windows identity that is used
> to run the web application.
>
>
> -----
> Dominick Baier (http://www.leastprivilege.com)
>
> Developing More Secure Microsoft ASP.NET 2.0 Applications (http://www.microsoft.com/mspress/books/9989.asp)
>
> > Dominick
> > Thanks for your prompt response.. it looks like i had a flow in my
> > architecture..
> > I will try to describe to you what I am trying to accomplish and
> > maybe you
> > could guide me with an approach..
> > We're doing an e-business website, form authentication based on an
> > external active directory. On the same website, we created a bunch of
> > webservices that we would like them to be used only by the website. We
> > also would like those webservices to know the identity of the caller
> > to perform some business logic.
> >
> > Having said all that, what would be your recommendation? Thanks in
> > advance for your great feedback, you just saved me a lot of running
> > around
> >
> > "Dominick Baier" wrote:
> >
> >> There is no out of the box support for FormsAuthentication for web
> >> service. FormsAuth uses redirects and cookies - thats very non web
> >> service like.
> >>
> >> That said you can implement that by using the FormsAuthentication API
> >> and cookie support in the client proxy. This involves some testing
> >> and you have to have a strategy how you handle ticket timeouts...
> >>
> >> I would rather recommend using basic authentication or WS-Security
> >> with UsernameTokens...
> >>
> >> -----
> >> Dominick Baier (http://www.leastprivilege.com)
> >> Developing More Secure Microsoft ASP.NET 2.0 Applications
> >> (http://www.microsoft.com/mspress/books/9989.asp)
> >>
> >>> Hi.. I am using form authentication on a web site that consumes web
> >>> services. Can the identity of the user that is logged on to the web
> >>> site passed to the web services for the same authentication? if so,
> >>> what would need to be configuered? Thanks a lot,
> >>>

>
>
>

 
Reply With Quote
 
Joe Kaplan
Guest
Posts: n/a
 
      02-09-2007
It would be easiest to do this by simply passing the user name as a
parameter in the SOAP body. However, the more "WS*" way to do it would be
with a header like Dominick suggested. Another option would be to use
Windows auth on the web services and use protocol transition logon to create
a Windows user identity for the user based on their user name and then
impersonate that.

If the web services are only going to be called by you and aren't going to
be a public API for other people, then I think I'd just pass the username as
a parameter, but it is definitely something to think about carefully. Each
approach implies different assumptions about how things will work and takes
different dependencies.

Joe K.

--
Joe Kaplan-MS MVP Directory Services Programming
Co-author of "The .NET Developer's Guide to Directory Services Programming"
http://www.directoryprogramming.net
--
"Abdullah" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> well, I think your idea about the ip filter (which I believe is the same
> concept as IP tagging) will solve the authentication problem for sure. the
> only missing piece of the puzzl is how to propagate the identity of the
> caller (who signed in using form authentication) to the web services? The
> web
> services logic will perform specific job based on the identity of the
> caller.. plus, if an intruder managed to get control of the exposed IIS
> machine, wouldn't be a trivel matter for him to call into the web services
> then?
> Thanks again for your time and helpfull answers..
>
> "Dominick Baier" wrote:
>
>> Well - there are several ways to accomplish that.
>>
>> The easiest is probably to configure an IP filter in IIS so that the web
>> services only takes requests from localhost.
>>
>> You can pass the name of the authenticated client as a parameter or
>> header.
>>
>> Since you use active directory, you can also use windows authenticaiton
>> for
>> the web services and restrict access to the windows identity that is used
>> to run the web application.
>>
>>
>> -----
>> Dominick Baier (http://www.leastprivilege.com)
>>
>> Developing More Secure Microsoft ASP.NET 2.0 Applications
>> (http://www.microsoft.com/mspress/books/9989.asp)
>>
>> > Dominick
>> > Thanks for your prompt response.. it looks like i had a flow in my
>> > architecture..
>> > I will try to describe to you what I am trying to accomplish and
>> > maybe you
>> > could guide me with an approach..
>> > We're doing an e-business website, form authentication based on an
>> > external active directory. On the same website, we created a bunch of
>> > webservices that we would like them to be used only by the website. We
>> > also would like those webservices to know the identity of the caller
>> > to perform some business logic.
>> >
>> > Having said all that, what would be your recommendation? Thanks in
>> > advance for your great feedback, you just saved me a lot of running
>> > around
>> >
>> > "Dominick Baier" wrote:
>> >
>> >> There is no out of the box support for FormsAuthentication for web
>> >> service. FormsAuth uses redirects and cookies - thats very non web
>> >> service like.
>> >>
>> >> That said you can implement that by using the FormsAuthentication API
>> >> and cookie support in the client proxy. This involves some testing
>> >> and you have to have a strategy how you handle ticket timeouts...
>> >>
>> >> I would rather recommend using basic authentication or WS-Security
>> >> with UsernameTokens...
>> >>
>> >> -----
>> >> Dominick Baier (http://www.leastprivilege.com)
>> >> Developing More Secure Microsoft ASP.NET 2.0 Applications
>> >> (http://www.microsoft.com/mspress/books/9989.asp)
>> >>
>> >>> Hi.. I am using form authentication on a web site that consumes web
>> >>> services. Can the identity of the user that is logged on to the web
>> >>> site passed to the web services for the same authentication? if so,
>> >>> what would need to be configuered? Thanks a lot,
>> >>>

>>
>>
>>



 
Reply With Quote
 
Abdullah
Guest
Posts: n/a
 
      02-11-2007
Gents,
I believe we are narrawing dowing on the following Architecture:
We will be using form autentication on the web site (users are stored in AD).
We will be using Windows Authentication on the Web Services side (same users
in AD).

We tried the following code on the web site side but it did not seem to do
the trick.. Any more great feedback? Any special setup we have to do on the
OS or IIS ?Thanks in advance..

string identity = User.Identity.Name;

int slash = identity.IndexOf( "\\" );
if (slash > 0)
{
string domain = identity.Substring(0, slash);
string user = identity.Substring(slash + 1);
identity = user + "@" + domain;
}

// The WindowsIdentity(string) constructor uses the new
// Kerberos S4U extension to get a logon for the user
// without a password.
WindowsIdentity wi = new WindowsIdentity (identity);
WindowsImpersonationContext wic = null ;
try
{
wic = wi.Impersonate();

// web service call
}
catch ( Exception ex)
{
// Ensure that an exception is not propagated higher in the call stack.
}
finally
{
// Make sure to remove the impersonation token
if ( wic != null )
wic.Undo();
}


"Joe Kaplan" wrote:

> It would be easiest to do this by simply passing the user name as a
> parameter in the SOAP body. However, the more "WS*" way to do it would be
> with a header like Dominick suggested. Another option would be to use
> Windows auth on the web services and use protocol transition logon to create
> a Windows user identity for the user based on their user name and then
> impersonate that.
>
> If the web services are only going to be called by you and aren't going to
> be a public API for other people, then I think I'd just pass the username as
> a parameter, but it is definitely something to think about carefully. Each
> approach implies different assumptions about how things will work and takes
> different dependencies.
>
> Joe K.
>
> --
> Joe Kaplan-MS MVP Directory Services Programming
> Co-author of "The .NET Developer's Guide to Directory Services Programming"
> http://www.directoryprogramming.net
> --
> "Abdullah" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > well, I think your idea about the ip filter (which I believe is the same
> > concept as IP tagging) will solve the authentication problem for sure. the
> > only missing piece of the puzzl is how to propagate the identity of the
> > caller (who signed in using form authentication) to the web services? The
> > web
> > services logic will perform specific job based on the identity of the
> > caller.. plus, if an intruder managed to get control of the exposed IIS
> > machine, wouldn't be a trivel matter for him to call into the web services
> > then?
> > Thanks again for your time and helpfull answers..
> >
> > "Dominick Baier" wrote:
> >
> >> Well - there are several ways to accomplish that.
> >>
> >> The easiest is probably to configure an IP filter in IIS so that the web
> >> services only takes requests from localhost.
> >>
> >> You can pass the name of the authenticated client as a parameter or
> >> header.
> >>
> >> Since you use active directory, you can also use windows authenticaiton
> >> for
> >> the web services and restrict access to the windows identity that is used
> >> to run the web application.
> >>
> >>
> >> -----
> >> Dominick Baier (http://www.leastprivilege.com)
> >>
> >> Developing More Secure Microsoft ASP.NET 2.0 Applications
> >> (http://www.microsoft.com/mspress/books/9989.asp)
> >>
> >> > Dominick
> >> > Thanks for your prompt response.. it looks like i had a flow in my
> >> > architecture..
> >> > I will try to describe to you what I am trying to accomplish and
> >> > maybe you
> >> > could guide me with an approach..
> >> > We're doing an e-business website, form authentication based on an
> >> > external active directory. On the same website, we created a bunch of
> >> > webservices that we would like them to be used only by the website. We
> >> > also would like those webservices to know the identity of the caller
> >> > to perform some business logic.
> >> >
> >> > Having said all that, what would be your recommendation? Thanks in
> >> > advance for your great feedback, you just saved me a lot of running
> >> > around
> >> >
> >> > "Dominick Baier" wrote:
> >> >
> >> >> There is no out of the box support for FormsAuthentication for web
> >> >> service. FormsAuth uses redirects and cookies - thats very non web
> >> >> service like.
> >> >>
> >> >> That said you can implement that by using the FormsAuthentication API
> >> >> and cookie support in the client proxy. This involves some testing
> >> >> and you have to have a strategy how you handle ticket timeouts...
> >> >>
> >> >> I would rather recommend using basic authentication or WS-Security
> >> >> with UsernameTokens...
> >> >>
> >> >> -----
> >> >> Dominick Baier (http://www.leastprivilege.com)
> >> >> Developing More Secure Microsoft ASP.NET 2.0 Applications
> >> >> (http://www.microsoft.com/mspress/books/9989.asp)
> >> >>
> >> >>> Hi.. I am using form authentication on a web site that consumes web
> >> >>> services. Can the identity of the user that is logged on to the web
> >> >>> site passed to the web services for the same authentication? if so,
> >> >>> what would need to be configuered? Thanks a lot,
> >> >>>
> >>
> >>
> >>

>
>
>

 
Reply With Quote
 
Joe Kaplan
Guest
Posts: n/a
 
      02-12-2007
In order to use S4U, you have to configure constrained delegation and make
sure the web server service account is allowed to log in via protocol
transition ("allowed to delegate with any protocol" setting in ADUC). These
are generally not enabled by default, so the expection would be that it
would not work unless someone specifically changed this.

Kerberos delegation is a good thing, but it can be a PITA to configure. MS
has written a bunch of very good (but long) documents on TechNet that
explain the configuration stuff in gory detail.

Joe K.

--
Joe Kaplan-MS MVP Directory Services Programming
Co-author of "The .NET Developer's Guide to Directory Services Programming"
http://www.directoryprogramming.net
--
"Abdullah" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Gents,
> I believe we are narrawing dowing on the following Architecture:
> We will be using form autentication on the web site (users are stored in
> AD).
> We will be using Windows Authentication on the Web Services side (same
> users
> in AD).
>
> We tried the following code on the web site side but it did not seem to do
> the trick.. Any more great feedback? Any special setup we have to do on
> the
> OS or IIS ?Thanks in advance..
>
> string identity = User.Identity.Name;
>
> int slash = identity.IndexOf( "\\" );
> if (slash > 0)
> {
> string domain = identity.Substring(0, slash);
> string user = identity.Substring(slash + 1);
> identity = user + "@" + domain;
> }
>
> // The WindowsIdentity(string) constructor uses the new
> // Kerberos S4U extension to get a logon for the user
> // without a password.
> WindowsIdentity wi = new WindowsIdentity (identity);
> WindowsImpersonationContext wic = null ;
> try
> {
> wic = wi.Impersonate();
>
> // web service call
> }
> catch ( Exception ex)
> {
> // Ensure that an exception is not propagated higher in the call
> stack.
> }
> finally
> {
> // Make sure to remove the impersonation token
> if ( wic != null )
> wic.Undo();
> }
>
>
> "Joe Kaplan" wrote:
>
>> It would be easiest to do this by simply passing the user name as a
>> parameter in the SOAP body. However, the more "WS*" way to do it would
>> be
>> with a header like Dominick suggested. Another option would be to use
>> Windows auth on the web services and use protocol transition logon to
>> create
>> a Windows user identity for the user based on their user name and then
>> impersonate that.
>>
>> If the web services are only going to be called by you and aren't going
>> to
>> be a public API for other people, then I think I'd just pass the username
>> as
>> a parameter, but it is definitely something to think about carefully.
>> Each
>> approach implies different assumptions about how things will work and
>> takes
>> different dependencies.
>>
>> Joe K.
>>
>> --
>> Joe Kaplan-MS MVP Directory Services Programming
>> Co-author of "The .NET Developer's Guide to Directory Services
>> Programming"
>> http://www.directoryprogramming.net
>> --
>> "Abdullah" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> > well, I think your idea about the ip filter (which I believe is the
>> > same
>> > concept as IP tagging) will solve the authentication problem for sure.
>> > the
>> > only missing piece of the puzzl is how to propagate the identity of the
>> > caller (who signed in using form authentication) to the web services?
>> > The
>> > web
>> > services logic will perform specific job based on the identity of the
>> > caller.. plus, if an intruder managed to get control of the exposed IIS
>> > machine, wouldn't be a trivel matter for him to call into the web
>> > services
>> > then?
>> > Thanks again for your time and helpfull answers..
>> >
>> > "Dominick Baier" wrote:
>> >
>> >> Well - there are several ways to accomplish that.
>> >>
>> >> The easiest is probably to configure an IP filter in IIS so that the
>> >> web
>> >> services only takes requests from localhost.
>> >>
>> >> You can pass the name of the authenticated client as a parameter or
>> >> header.
>> >>
>> >> Since you use active directory, you can also use windows
>> >> authenticaiton
>> >> for
>> >> the web services and restrict access to the windows identity that is
>> >> used
>> >> to run the web application.
>> >>
>> >>
>> >> -----
>> >> Dominick Baier (http://www.leastprivilege.com)
>> >>
>> >> Developing More Secure Microsoft ASP.NET 2.0 Applications
>> >> (http://www.microsoft.com/mspress/books/9989.asp)
>> >>
>> >> > Dominick
>> >> > Thanks for your prompt response.. it looks like i had a flow in my
>> >> > architecture..
>> >> > I will try to describe to you what I am trying to accomplish and
>> >> > maybe you
>> >> > could guide me with an approach..
>> >> > We're doing an e-business website, form authentication based on an
>> >> > external active directory. On the same website, we created a bunch
>> >> > of
>> >> > webservices that we would like them to be used only by the website.
>> >> > We
>> >> > also would like those webservices to know the identity of the caller
>> >> > to perform some business logic.
>> >> >
>> >> > Having said all that, what would be your recommendation? Thanks in
>> >> > advance for your great feedback, you just saved me a lot of running
>> >> > around
>> >> >
>> >> > "Dominick Baier" wrote:
>> >> >
>> >> >> There is no out of the box support for FormsAuthentication for web
>> >> >> service. FormsAuth uses redirects and cookies - thats very non web
>> >> >> service like.
>> >> >>
>> >> >> That said you can implement that by using the FormsAuthentication
>> >> >> API
>> >> >> and cookie support in the client proxy. This involves some testing
>> >> >> and you have to have a strategy how you handle ticket timeouts...
>> >> >>
>> >> >> I would rather recommend using basic authentication or WS-Security
>> >> >> with UsernameTokens...
>> >> >>
>> >> >> -----
>> >> >> Dominick Baier (http://www.leastprivilege.com)
>> >> >> Developing More Secure Microsoft ASP.NET 2.0 Applications
>> >> >> (http://www.microsoft.com/mspress/books/9989.asp)
>> >> >>
>> >> >>> Hi.. I am using form authentication on a web site that consumes
>> >> >>> web
>> >> >>> services. Can the identity of the user that is logged on to the
>> >> >>> web
>> >> >>> site passed to the web services for the same authentication? if
>> >> >>> so,
>> >> >>> what would need to be configuered? Thanks a lot,
>> >> >>>
>> >>
>> >>
>> >>

>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Webservices Basic Authentication Bottlenecks Jeremy ASP .Net Web Services 0 11-03-2004 10:07 AM
Forms authentication in WebServices and timeout j_a5 ASP .Net Web Services 0 09-29-2004 07:24 PM
Tivoli authentication, webservices and .Net Francois Vanderseypen ASP .Net Web Services 1 04-22-2004 02:50 PM
Webservices Authentication Asim Qazi ASP .Net Web Services 3 04-19-2004 09:40 AM
Windows Authentication and WebServices Kevin Harrison ASP .Net Web Services 1 09-25-2003 06:02 PM



Advertisments