开发者

How to store user credentials in an ASP.NET MVC website

开发者 https://www.devze.com 2023-04-10 12:44 出处:网络
My settings is as follows: I have an MVC web application (EbWebApp) which has a service reference to an WCF service named EbServiceApp. For authentication purposes I implemented a forms authenticati

My settings is as follows:

I have an MVC web application (EbWebApp) which has a service reference to an WCF service named EbServiceApp. For authentication purposes I implemented a forms authentication scenario:

The user logs on to the web site, and then in turn I authenticate 开发者_运维百科the user to the web service (using forms authentication) too. For this I created another web service named AuthService.

Everything works just fine but when the forms authentication ticket expires for the web service I would have to relog on the user to the webservice without asking for username and password (this scenario can happen for example if I set a persistent cookie on the website for the user). I don't know how could I store the user's credentials to be available for reconnection to the web service.

Any help is appreciated.


Warning! Warning! Warning!

Whenever you think "How can i store the users credentials so i can automatically log them in later?" then you are doing something very dangerous. If you can log them in later, then someone can steal those credentials. It's ALWAYS a bad idea.

If the forms authentication ticket expires, then only the end user should be able to log himself back in. Otherwise, you're defeating the purpose of a ticket expiry. If you want the ticket to last longer, then just set its expiration to be longer.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号