4
votes

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

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

1 Answers

2
votes

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.