views:

32

answers:

1

Hi I am going to do a web service. Now our customers are going to be able to call the method from their interface. I been thinking what I should do for authentication, I been reading and can not really decide. I want to pass username and password to the method.

Do you got any advice?

+1  A: 

Common authentication schemes are well-defined and, while not perfect, are known entities. The worst thing you can do is "roll your own" in security.

I assume by your comment "pass username and password to the method", you mean you would like to have access to the credentials used to access your web service. This is fine, but don't pass credentials as parameters to your method.

Based on your description, basic authentication over SSL should provide you sufficient protection for your application. This would work in a non-trusted environment (i.e. across unknown networks) and should be easy enough to implement on the client-side.

jro
So the basic authentication with the SSL certificate instead of the passing credentials to the method? Why should I not pass credentials to the method? Thanks for answer jro
Dejan.S
Passing credentials to the method causes unmasked credentials in either the body of the message (if it's a POST) or as parameters on the URL itself (if it's a GET). In both cases, the information is being sent in the clear and is bad form. Basic auth at least gets you some level of encoding (not encryption, mind you) and embeds the credentials in headers to the request.
jro
Ok but I have to somehow find out what user is it that request the web service in order to return the right info for each user. Would it be a good idea maybe to pass a guid/encrypted pass and then I do a for each on all the users to find the right match and that way to get the right info?
Dejan.S
Depends on your implementation. I assume from your tags that this is built in asp.net. You have 3 options: ASMX (legacy), WCF, or roll-your-own (don't do this.) My suggestion: go with WCF. ASMX will be "easier" to understand out of the gate, but WCF is where you should spend your time. Read up on "transport authentication" in WCF. That should get you started.
jro