forked from kanemura1206/maspen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
martinlanghoff
committed
Jan 16, 2006
1 parent
4fc8dce
commit 381ad73
Showing
2 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?PHP // $Id: config.html | ||
|
||
if ((!include_once('Auth/RADIUS.php')) or (!class_exists(Auth_RADIUS_PAP))) { // Is Auth/RADIUS really there? | ||
print '<p align="center"><font color="red"><strong>Warning: The Auth_RADIUS module does not seem to be present. Please ensure it is installed and enabled.</strong></font></p>'; | ||
} | ||
if (!isset($config->auth_radiushost)) { | ||
$config->auth_radiushost = "127.0.0.1"; | ||
} | ||
if (!isset($config->auth_radiusnasport)) { | ||
$config->auth_radiusport = "0"; | ||
} | ||
if (!isset($config->auth_radiussecret)) { | ||
$config->auth_radiussecret = ""; | ||
} | ||
?> | ||
<tr valign="top" > | ||
<td align="right"><P>auth_radiushost:</td> | ||
<td> | ||
<input name="auth_radiushost" type="text" size="30" value="<?php echo $config->auth_radiushost?>"> | ||
<?php if (isset($err["auth_radiushost"])) | ||
formerr($err["auth_radiushost"]); ?> | ||
</td> | ||
<td> | ||
<?php print_string("auth_radiushost","auth") ?> | ||
</td> | ||
</TR> | ||
|
||
<TR valign="top" > | ||
<td align="right"><P>auth_radiusnasport:</td> | ||
<td> | ||
<input name="auth_radiusport" type="text" size="6" value="<?php echo $config->auth_radiusport ?>"> | ||
<?php if (isset($err["auth_radiusnasport"])) formerr($err["auth_radiusnasport"]); ?> | ||
</td> | ||
<td> | ||
<?php print_string("auth_radiusnasport","auth") ?> | ||
</td> | ||
</TR> | ||
|
||
<TR valign="top" > | ||
<td align="right"><P>auth_radiussecret:</td> | ||
<td> | ||
<input name="auth_radiussecret" type="text" size="6" value="<?php echo $config->auth_radiussecret ?>"> | ||
<?php if (isset($err["auth_radiussecret"])) formerr($err["auth_radiussecret"]); ?> </td> | ||
<td> | ||
<?php print_string("auth_radiussecret","auth") ?> | ||
</td> | ||
</TR> | ||
|
||
<TR valign="top"> | ||
<td align="right"><P><?php print_string("instructions", "auth") | ||
?>:</td> | ||
<td> | ||
<textarea name="auth_instructions" cols="30" rows="10" wrap="virtual"><?php | ||
p($config->auth_instructions) ?></textarea> | ||
</td> | ||
<td> | ||
<?php print_string("authinstructions","auth") ?> | ||
<?php helpbutton("text", get_string("helptext")) ?> | ||
</td> | ||
</TR> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?PHP // $Id$ | ||
// Authentication by looking up a RADIUS server | ||
|
||
function auth_user_login ($username, $password) { | ||
// Returns true if the username and password work | ||
// and false if they are wrong or don't exist. | ||
|
||
require_once 'Auth/RADIUS.php'; | ||
|
||
global $CFG; | ||
|
||
// Added by Clive on 7th May for test purposes | ||
// printf("Username: $username <br>"); | ||
// printf("Password: $password <br>"); | ||
// printf("auth_radiushost: $CFG->auth_radiushost <br>"); | ||
// printf("auth_radiusnasport: $CFG->auth_radiusnasport <br>"); | ||
// printf("auth_radiussecret: $CFG->auth_radiussecret <br>"); | ||
|
||
$rauth = new Auth_RADIUS_PAP($username, $password); | ||
$rauth->addServer($CFG->auth_radiushost, $CFG->auth_radiusnasport, $CFG->auth_radiussecret); | ||
|
||
if (!$rauth->start()) { | ||
printf("Radius start: %s<br>\n", $rauth->getError()); | ||
exit; | ||
} | ||
|
||
$result = $rauth->send(); | ||
if (PEAR::isError($result)) { | ||
printf("Radius send failed: %s<br>\n", $result->getMessage()); | ||
exit; | ||
} else if ($result === true) { | ||
// printf("Radius Auth succeeded<br>\n"); | ||
return true; | ||
} else { | ||
// printf("Radius Auth rejected<br>\n"); | ||
return false; | ||
} | ||
|
||
// get attributes, even if auth failed | ||
if (!$rauth->getAttributes()) { | ||
printf("Radius getAttributes: %s<br>\n", $rauth->getError()); | ||
} else { | ||
$rauth->dumpAttributes(); | ||
} | ||
|
||
$rauth->close(); | ||
} | ||
?> | ||
|