title: How to prevent a DataContract's content from being modified by the client with WCF?
body: <p>I am building an application which requires the user to login at start-up.</p>
  
  <p>The authentication process is as follows:</p>
  
  <ul>
  <li>User inputs username / password.</li>
  <li>client sends username + password to Web Service.</li>
  <li>Web Service authenticates the user with hashed password from the DB.</li>
  <li><p>Web Service returns a token to the client which contains one of those three values:</p>
  
  <p>1) Username is invalid.</p>
  
  <p>2) Password is invalid.</p>
  
  <p>3) User is authenticated.</p></li>
  <li><p>The token is used by the client to determine the next course of action.</p></li>
  <li><p>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.</p></li>
  </ul>
  
  <p>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.</p>
  
  <p>How would I go about preventing clients from modifying the value of the token ? Are there any patterns that could help me here ?</p>