From 977f5b56e107cc8dd75d3a4236a18e8371ff9c4e Mon Sep 17 00:00:00 2001 From: martinlanghoff Date: Wed, 14 Nov 2007 22:08:38 +0000 Subject: [PATCH] MDL-9399 auth/ldap: Add NTLM SSO pages These pages control the process of attempting an NTLM SSO login safely. This is very draft and needs real-world testing and polish. And string localisation too ;-) * If NTLM SSO is enabled, and the user's IP addr is in the right subnet, the loginpage_hook() of auth/ldap redirects to ntlmsso_attempt.php * ntlmsso_attempt.php will display a "redirect" msg with an img tag pointing to ntlmsso_magic.php, a 3s wait, and a redirect to ntlmsso_finish.php * ntlmsso_magic.php should be configured to have "Integrated Windows Authentication". If it does, it will serve a spacer gif and call ntlmsso_magic() * ntlmsso_finish.php calls ntlmsso_finish() to complete the SSO and handles failures. --- auth/ldap/ntlmsso_attempt.php | 34 +++++++++++++++++++++++++++++++ auth/ldap/ntlmsso_finish.php | 30 +++++++++++++++++++++++++++ auth/ldap/ntlmsso_magic.php | 38 +++++++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 auth/ldap/ntlmsso_attempt.php create mode 100644 auth/ldap/ntlmsso_finish.php create mode 100644 auth/ldap/ntlmsso_magic.php diff --git a/auth/ldap/ntlmsso_attempt.php b/auth/ldap/ntlmsso_attempt.php new file mode 100644 index 0000000000..1c05eb73b1 --- /dev/null +++ b/auth/ldap/ntlmsso_attempt.php @@ -0,0 +1,34 @@ +config->ntlmsso_enabled)) { + print_error('ntlmsso_isdisabled','auth'); +} + +$sesskey = sesskey(); + +//print_header("$site->fullname: $loginsite", $site->fullname, $loginsite, $focus, '', true); +$msg = '

Attempting SSO...

' + . ''; +redirect($CFG->wwwroot . '/auth/ldap/ntlmsso_finish.php', $msg, 3); + + + +?> \ No newline at end of file diff --git a/auth/ldap/ntlmsso_finish.php b/auth/ldap/ntlmsso_finish.php new file mode 100644 index 0000000000..e029c350e1 --- /dev/null +++ b/auth/ldap/ntlmsso_finish.php @@ -0,0 +1,30 @@ +config->ntlmsso_enabled)) { + print_error('ntlmsso_isdisabled','auth'); +} + +// If ntlmsso_finish() succeeds, then the code never returns, +// so we only worry about failure. +if (!$authplugin->ntlmsso_finish()) { + // Redirect to login, saying "don't try again!" + redirect($CFG->wwwroot . '/login/index.php?authldap_skipntlmsso=1', + "Single Sign On failed, proceed to normal login", 3); +} +?> \ No newline at end of file diff --git a/auth/ldap/ntlmsso_magic.php b/auth/ldap/ntlmsso_magic.php new file mode 100644 index 0000000000..624b6d8ce6 --- /dev/null +++ b/auth/ldap/ntlmsso_magic.php @@ -0,0 +1,38 @@ +config->ntlmsso_enabled)) { + print_error('ntlmsso_isdisabled','auth'); +} + +$sesskey = required_param('sesskey', PARAM_RAW); +if ($authplugin->ntlmsso_magic($sesskey)) { + // Serve GIF + $file = $CFG->dirroot . '/pix/spacer.gif'; + + // Type + header('Content-Type: image/gif'); + header('Content-Length: '.filesize($file)); + + // Output file + $handle=fopen($file,'r'); + fpassthru($handle); + fclose($handle); + exit; +} else { + print_error('ntlmsso_iwamagicnotenabled','auth'); +} + +?> \ No newline at end of file -- 2.39.5