Skip to content

Commit

Permalink
Adding $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW'], adding …
Browse files Browse the repository at this point in the history
…support of HTTP Basic Auth. Closes #27
  • Loading branch information
Kdecherf committed Feb 24, 2011
1 parent c55bd71 commit 6bf4217
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG
Expand Up @@ -3,6 +3,7 @@ ChangeLog for Quercus by Clever Cloud

Version cc-4.0.14.2-dev
-----------------------
- Fixing #27 (c#4403): $_SERVER["PHP_USER_AUTH"] is always empty (HTTP Basic Auth)
- GD: Fixing version and renaming 'JPG Support' to 'JPEG Support' according to PHP 5.3.0
- Moving APC Module to quercus-modules (QExt)
- Fixing #8: levenshtein: support of optional arguments
Expand Down
2 changes: 1 addition & 1 deletion modules/quercus/src/com/caucho/quercus/QuercusVersion.java
Expand Up @@ -35,6 +35,6 @@ public static String getVersionNumber() {
}

public static String getVersionDate() {
return "20110214";
return "20110224";
}
}
13 changes: 13 additions & 0 deletions modules/quercus/src/com/caucho/quercus/env/Env.java
Expand Up @@ -249,6 +249,7 @@ public enum OVERLOADING_TYPES {
private int[] _querySeparatorMap;
public static final int[] DEFAULT_QUERY_SEPARATOR_MAP;
private CharBuffer _cb = new CharBuffer();
private String[] _authRequest;

public Env(QuercusContext quercus,
QuercusPage page,
Expand Down Expand Up @@ -353,6 +354,18 @@ public Env(QuercusContext quercus,
addConstant("PHP_CONFIG_FILE_PATH", new ConstStringValue(getPwd() + "WEB-INF/"), true);
addConstant("PHP_CONFIG_FILE_SCAN_DIR", new ConstStringValue(getPwd() + "WEB-INF/"), true);

// c#0004403 - #27
String _authHeader = request.getHeader("authorization");
if (_authHeader != null) {
_authRequest = _authHeader.split(" ");
if (_authRequest[0].equals("Basic")) {
// BASIC auth
String[] _auth64 = Base64.decode(_authRequest[1]).split(":");
getGlobalVar("_SERVER").put(new ConstStringValue("PHP_AUTH_USER"), new ConstStringValue(_auth64[0]));
getGlobalVar("_SERVER").put(new ConstStringValue("PHP_AUTH_PW"), new ConstStringValue(_auth64[1]));
}
}

// STDIN, STDOUT, STDERR
// php://stdin, php://stdout, php://stderr
if (response == null) {
Expand Down

0 comments on commit 6bf4217

Please sign in to comment.