I am building an application which requires the user to login at start-up.
The authentication process is as follows:
- User inputs username / password.
- client sends username + password to Web Service.
- Web Service authenticates the user with hashed password from the DB.
Web Service returns a token to the client which contains one of those three values:
1) Username is invalid.
2) Password is invalid.
3) User is authenticated.
The token is used by the client to determine the next course of action.
The token is passed to the service with every subsequent calls made by the client. The service rejects the call if the user is not authenticated.
The token is encapsulated within a DTO, which is a DataContract. The token itself is a DataMember. DataMembers require that the property have a setter and a getter. This means that clients are now able to set a value for the token, which is bad. Clients could now technically flag themselves as authenticated.
How would I go about preventing clients from modifying the value of the token ? Are there any patterns that could help me here ?