Answers.Body: <p>It sounds like you're not necessarily interested in authenticating against Craft's current users, but you just want <em>some</em> type of header authentication in place.</p>
  
  <p>If you set those header (via whatever means) in the API request, you can have a plugin's controller read those via <a href="https://github.com/pixelandtonic/Craft-Release/blob/master/app/helpers/HeaderHelper.php#L230" rel="nofollow">HeaderHelper::getHelper($headerName)</a> and perform whatever authentication logic that you require.</p>
  
  <p>If authentication passes, let the request go through, if not, you can <code>throw new HttpException(503);</code>.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-20T03:52:48.147Z
Answers.Text: just thought that was particularly well answered, short of writing code. There may be other evidence you think well of things, Brad ;)
Answers.UserDisplayName: narration_sd
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-21T00:47:37.253Z
Answers.LastActivityDate: 2014-12-21T00:47:37.253Z
Answers.UserDisplayName: Brad Bell
Body: <p>I'm building an API provider using Craft and need to implement some kind of client authentication. I don't need to worry about individual users, but I'd like to require that clients authenticate in some way. My current thinking is the client can pass an authorization header header of some kind, or just use basic authentication to access the content on the Craft CMS site, I'm just not sure how to consume the header on the Craft side &amp; validate it before serving the content. Can anyone offer up some tips on how to implement something like this using Craft?</p>
  
Tags: <authentication>
Title: Craft as an API provider & authenticaton
ThreadText: # Craft as an API provider & authenticaton
  
  (Asked by: username_0 on 2014-12-19)
  
  I'm building an API provider using Craft and need to implement some kind of client authentication. I don't need to worry about individual users, but I'd like to require that clients authenticate in some way. My current thinking is the client can pass an authorization header header of some kind, or just use basic authentication to access the content on the Craft CMS site, I'm just not sure how to consume the header on the Craft side & validate it before serving the content. Can anyone offer up some tips on how to implement something like this using Craft?
  
  **Tags:** authentication
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-12-21. Score: 1 | Accepted answer
  
  It sounds like you're not necessarily interested in authenticating against Craft's current users, but you just want *some* type of header authentication in place.
  
  If you set those header (via whatever means) in the API request, you can have a plugin's controller read those via [HeaderHelper::getHelper($headerName)](https://github.com/pixelandtonic/Craft-Release/blob/master/app/helpers/HeaderHelper.php#L230) and perform whatever authentication logic that you require.
  
  If authentication passes, let the request go through, if not, you can `throw new HttpException(503);`.
  
  > **Comments:**
  > **username_2**: just thought that was particularly well answered, short of writing code. There may be other evidence you think well of things, username_1 ;)  
  
  ---
  
  