WCF Authenticate Client with database

丶灬走出姿态 提交于 2019-12-12 11:32:40

问题


I have a WCF service that supposed to provide service to several clients.

The WCF will have a Data-Access-Layer that will communicate with the database.

This is part of my design idea : My Design

As you can see - each client will connect to the 1st WCF service for pulling information (get product, update product), and also to the 2nd WCF service in a pub\sub manner, so it would be able to receive notifications about different things it wants.

I have a table in the database for 'Users' with all the users in the system. (there is an administrator, a normal user and a technician).

My question is - how do I do the 'logging' in from the client to the database ?

My current idea - have a function in the services called 'Connect ( username, password )' and when a client connects - it will pass the username and password to be authenticated in the database, and only if authenticated - the client will start sending commands.

Problem with this is - anyone can write his own client that connects to my service and runs other functions without authenticating. I can solve this by saving in the service whether or not the client has authenticated.

But is there a better solution that just having a 'Connect' function in the service ?

Hope there is something simple yet effective.


回答1:


You should create a custom user name and password validator that derives from the UserNamePasswordValidator abstract class and implements the Validate() method. Then you can validate the provided user name and password however you want. To learn more about setting this up, read this article.



来源:https://stackoverflow.com/questions/10261228/wcf-authenticate-client-with-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!