• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Apache Headers on Incoming Request

I deal mostly in building API's and lately my authentication has been coming through as a Bearer Token passed in through an "Authorization" header. The problem that I have is that the IncomingRequest class currently does not load that header because it is not part of the $_SERVER array. In my Google searching I found that most people are suggesting to use apache_request_headers() to get that and I have created a way to do that in my code but I think this could be a valuable feature to add for anyone using CodeIgniter. My thought process is to add a configuration somewhere that allows a dev to tell CodeIgniter to check for apache headers when running the Message::populateHeaders method. Then if that is set, use apache_request_headers() to get those headers and add them to the headers in the request. What are your thoughts on that plan and where would you think makes sense to put that configuration?

So I actually discovered that CodeIgniter has something in place in the .htaccess to make sure that the authorization header does get passed through but for some reason in my setup that wasn't working. I did find a solution that allows me to not have to use the apache_request_headers() function. I added

SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1

to my httpd.conf file and that solved the problem. I thought I would post that here in case anyone else runs into this issue and finds this post.

Thanks for the description and sharing the solution! This was over my head but hopefully helpful to anyone else who lands here. Smile

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.