title: Register custom credentials auth provider in ServiceStack
body: <p>I was reading this <a href="https://github.com/ServiceStack/ServiceStack/wiki/Authentication-and-authorization#custom-authentication-and-authorization" rel="nofollow">from their documentation</a> which says:</p>
  
  <blockquote>
    <p>Then you need to register your custom credentials auth provider:</p>
  </blockquote>
  
  <pre><code>  //Register all Authentication methods you want to enable for this web app.
    Plugins.Add(new AuthFeature(() =&gt; new AuthUserSession(),
        new IAuthProvider[] {
      new CustomCredentialsAuthProvider(), //HTML Form post of UserName/Password credentials
        }
    ));
  </code></pre>
  
  <p>My question is:  <strong>Where do I put this?  Also, what is meant by the comment, "HTML Form post of UserName/Password credentials?"</strong></p>
  
  <p>Currently, I have a ServiceStack service which returns JSON when called.  I want to add an Authorize attribute above it so that only authorized users will be able to access it.</p>
  
  <p>I have created a class as they suggest:</p>
  
  <pre><code>public class CustomCredentialsAuthProvider : CredentialsAuthProvider
  {
      public override bool TryAuthenticate(IServiceBase authService, string userName, string password)
      {
          //Add here your custom auth logic (database calls etc)
          //Return true if credentials are valid, otherwise false
          return false;
      }
  
      public override void OnAuthenticated(IServiceBase authService, IAuthSession session, IOAuthTokens tokens, Dictionary&lt;string, string&gt; authInfo)
      {
          //Fill the IAuthSession with data which you want to retrieve in the app eg:
          session.FirstName = "some_firstname_from_db";
          //...
  
          //Important: You need to save the session!
          authService.SaveSession(session, SessionExpiry);
      }
  }
  </code></pre>
  
  <p>How can I "register your custom credentials auth provider?"</p>