ASP.NET Login to web service using username and password for the first time

The first time I log into my webservice, I want to use FormsAuthentication for example.

myService.ClientCredentials.UserName.UserName = "name";
myService.ClientCredentials.UserName.Password = "password";

      

but once the user is logged into my web application, I don't want to know about his password, so I would like to be able to connect to the web service as that user without knowing his password. Is it possible?

0


a source to share


3 answers


I would store the password on either front end while accessing the web service and then pass it behind the scenes whenever the user invokes the web service.

So, create your webservice always with a password, but before doing that, cache the password in such a way that the password is entered by the user, the front end does not ask again.



Be warned, there may be a security issue in keeping the password cached as I believe this will be part of the session. I don't know how .net works, but you might want to look into hashing .

0


a source


You should be able to do this, but there are several issues to consider. Forms Based Authentication (FBA) typically uses a cookie to track authentication.



  • Security - Configure the web application and web service to use the same FBA database.

  • Domain - As long as the web service is in the same domain as the application's website, the web service can use the same cookie for authentication. If the client has cookies disabled, then this may not work.

  • Cookie Exposure - You need to configure the authentication duration to an acceptable duration (30 minutes, 1 hour, 1 day or more) in your web.config file. This will allow the user to access the web service within the proper time frame after he or she is logged in.

0


a source


you can enable sessions in your webservice. There is a simple token that you add at the beginning of the service declaration.

<WebMethod(True)> Method Name

      

0


a source







All Articles