Skip to content
This repository has been archived by the owner on Jun 27, 2018. It is now read-only.

Add HTTP_X_FORWARDED support to OAuth #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/OAuth/OAuthRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,20 @@ public static function from_request($http_method = null, $http_url = null, $para
$scheme = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on")
? 'http'
: 'https';
$port = $_SERVER['SERVER_PORT'];
if ( isset($_SERVER['HTTP_X_FORWARDED_PROTO']) ) {
$scheme = $_SERVER['HTTP_X_FORWARDED_PROTO'];

if ( isset( $_SERVER['HTTP_X_FORWARDED_PORT'] ) ) {
$port = $_SERVER['HTTP_X_FORWARDED_PORT'];
} else if ( 'https' == $_SERVER['HTTP_X_FORWARDED_PROTO'] ) {
$port = 443;
}
}
$http_url = ($http_url) ? $http_url : $scheme .
'://' . $_SERVER['SERVER_NAME'] .
':' .
$_SERVER['SERVER_PORT'] .
$port .
$_SERVER['REQUEST_URI'];
$http_method = ($http_method) ? $http_method : $_SERVER['REQUEST_METHOD'];

Expand Down