Sab Nov 11, 2006 8:44 am
|
 |
hinoeath
Perlero Nuevo

|
Registrado: 09 Nov 2006
Mensajes: 10
Ubicación: Barranquilla-Colombia
|
|
| Autenticación Servidor de Correo |
|
|
Hola. He estado pensando en lo siguiente: digamos que tengo "mi servidor de correo" al cual me conecto a través del navegador:
http://x.com:2095/
que a veces me redirecciona a este
http://x.com:2095/webmaillogout.cgi
aunque esta opción ya casi no me gusta... al entrar, al ingresar abre el típico cuadro de dialogo que ya conocemos pidiéndome mi user y pasword, luego de ingresar correctamente los datos ya puedo revisar mi email sea con Horde o Cube... en fin no me gusta.
Ahorita pensaba en la posibilidad de poder hacer un index en mi página, un diseño algo llamativo para mi, dos campos respectivamente User and Pasword (para estar a la moda con el spanglish xD) y dependiendo de lo que retorne, si es correcta la pasword me redireccione de inmediato a la bandeja sino muestre una página o pues solamente devuelva al index.
Y esto es lo que pienso:
Implicaría pasar los datos al script encargado de la autenticación, pero realmente no se cuál, ni siquiera se si puedo acceder a él y ya he recorrido todo mi host en busca de algo como "webmaillogout.cgi" o parecido... buscando la "señal" xDD..
¿Alguno de ustedes ha hecho esto? ¿Podrían pasarme un enlace donde pueda entender mejor el funcionamiento de esto o la manera de llevar a cabo mi idea? De en medio de mi desconocimiento y optimismo xD pienso que no puede ser tan complicado.
De antemano gracias y me gustaría conocer de que manera podría hacer esto. Salu2 y gracias.  |
|
|
|

Sab Nov 11, 2006 9:33 am
|
 |
explorer
Moderador

|
Registrado: 24 Jul 2005
Mensajes: 4226
Ubicación: Valladolid, España
|
|
|
|
|
Sólo habría que llamar al script que hace la autenticación pasándole como argumentos el nombre de usuario y contraseña. Para ello debes saber cómo se llaman las cajas de diálogo del formulario de entrada, y los nombres de los botones. Ver en el código HTML si la llamada es GET o POST. Todo eso para al final hacer un GET o POST con LWP::Simple. El resultado será una página web, desde luego, pero el problema vendrá en cómo se guardará la información de la sesión (cookies o ssid).
Quizás lo más sencillo sea incorporar en el HTML de tu index un formulario con las mismas cajas y botones que en el original. Les das tus propios estilos, pero la funcionalidad será la original. No tendrás que programar nada. |
|

Sab Nov 11, 2006 1:48 pm
|
 |
hinoeath
Perlero Nuevo

|
Registrado: 09 Nov 2006
Mensajes: 10
Ubicación: Barranquilla-Colombia
|
|
| Lo había logrado pero.. |
|
|
Ya tengo los ojos así jajaja y los resultados no los que he querido, lo había conseguido. Pero ahora resulta que cuando le doy al botón enviar pues de inmediato me sale un pop-up el mismo a diferencia que sale sobre la misma pagina, conectándome por VNC al servidor me he traído el código de los scripts de autenticación que usa Horde. Ya lo he probado y me funcionó una vez(aunque suene extraño... me funcionó pero luego ya no... en realidad funciona, pero el problema es que no quiero que habrá ese pop-up al darle click en el botón enviar.) Pero ahora no se. Y estoy un poco cansado, así que voy a comentar que he hecho hasta ahora...este código del form de mi index:
| HTML: | <div id="Layer1">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="55%" height="180"> </td>
<td><form id="form1" name="horde_login" method="post" action="http://hinoeath.com:2082/index.php">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="25"><img src="images/usu.jpg" width="67" height="21" /></td>
</tr>
<tr>
<td><label>
<input name="horde_user" type="text" class="Formulario" id="usuario" />
</label></td>
</tr>
<tr>
<td height="25"><img src="images/pass.jpg" width="83" height="19" /></td>
</tr>
<tr>
<td><input name="horde_pass" type="password" class="Formulario" id="contra" /></td>
</tr>
<tr>
<td height="35"><label>
<input type="image" name="images/imageField" src="images/iniciar.jpg" />
</label></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</div> |
los campos tienen los mismo nombres que recibe el script... y aquí va el código de el index.php:
| php: | <?php
@ define('AUTH_HANDLER', true);
@ define('HORDE_BASE', dirname(__FILE__));
$horde_configured = (@ file_exists(HORDE_BASE . '/config/conf.php') &&
@ file_exists(HORDE_BASE . '/config/mime_drivers.php') &&
@ file_exists(HORDE_BASE . '/config/nls.php') &&
@ file_exists(HORDE_BASE . '/config/prefs.php') &&
@ file_exists(HORDE_BASE . '/config/registry.php'));
if (! $horde_configured) {
require HORDE_BASE . '/lib/Test.php';
Horde_Test:: configFilesMissing('Horde', HORDE_BASE, 'prefs.php',
array('conf.php' => 'This is the main Horde configuration file. It contains paths and basic items that apply to the core framework and all Horde applications.',
'mime_drivers.php' => 'This file controls the global set of MIME drivers for the Horde framework, allowing applications to make use of programs such as enscript or mswordview to render content into HTML for viewing in a browser.',
'nls.php' => 'This file provides localisation support for the Horde framework.',
'registry.php' => 'The registry is how Horde applications find out how to talk to each other. You should list any installed Horde applications that you have here.'));
}
require_once HORDE_BASE . '/lib/base.php';
if ($browser-> isMobile()) {
require HORDE_BASE . '/services/portal/mobile.php';
exit;
}
$main_page = Util:: getFormData('url');
// Break up the requested URL in $main_page and run some sanity checks
// on it to prevent phishing and XSS attacks. If any of the checks
// fail, $main_page will be set to null.
if (! empty($main_page)) {
// Mute errors in case of unparseable URLs
$req = @ parse_url($main_page);
// We assume that any valid redirect URL will be in the same
// cookie domain. This helps prevent rogue off-site Horde installs
// from mimicking the real server.
if (isset($req['host'])) {
$qcookiedom = preg_quote($conf['cookie']['domain']);
if (! preg_match('/' . $qcookiedom . '$/', $req['host'])) {
$main_page = null;
}
}
// Protocol whitelist: If the URL is fully qualified, make sure it
// is either http or https.
$allowed_protocols = array('http', 'https');
if (empty($req['scheme']) ||
! in_array($req['scheme'], $allowed_protocols)) {
$main_page = null;
}
}
if (! $main_page) {
$initial_app = $prefs-> getValue('initial_application');
if (! empty($initial_app) && $registry-> hasPermission($initial_app)) {
$main_page = Horde:: url($registry-> getInitialPage($initial_app), true);
} elseif (isset($registry-> applications['horde']['initial_page'])) {
$main_page = Horde:: applicationUrl($registry-> applications['horde']['initial_page'], true);
} elseif (Auth:: getAuth()) {
$main_page = Horde:: applicationUrl('services/portal/', true);
} else {
}
}
if (!Util:: getFormData('frameset_loaded') &&
($conf['menu']['always'] ||
(Auth:: getAuth() && $prefs-> getValue('show_sidebar')))) {
if ($browser-> hasQuirk('scrollbar_in_way')) {
$scrollbar = 'yes';
} else {
$scrollbar = 'auto';
}
require HORDE_TEMPLATES . '/index/frames_index.inc';
} else {
header('Location: ' . $main_page);
}
|
y este el del login.php:
| php: | <?php
@ define('AUTH_HANDLER', true);
@ define('HORDE_BASE', dirname(__FILE__));
require_once HORDE_BASE . '/lib/base.php';
require_once 'Horde/Menu.php';
require_once 'Horde/Secret.php';
/* Initialize the Auth credentials key. */
Secret:: setKey('auth');
/* Get an Auth object. */
$auth = &Auth:: singleton($conf['auth']['driver']);
if (is_a($auth, 'PEAR_Error')) {
Horde:: fatal($auth, __FILE__, __LINE__);
}
/* Get parameters. */
$logout_reason = $auth-> getLogoutReason();
$url_param = Util:: getFormData('url');
$ie_version = Util:: getFormData('ie_version');
if ($logout_reason) {
$login_screen = $auth-> getLoginScreen();
if (Util:: getFormData('nosidebar') &&
isset($GLOBALS['notification'])) {
$url = Auth:: addLogoutParameters($login_screen);
if ($url_param) {
$url = Util:: addParameter($url, 'url', $url_param);
}
$notification-> push('window.parent.location.href = \'' . $url . '\';', 'javascript');
echo '<html><body>' . $GLOBALS['notification']-> notify(array('listeners' => array('javascript'))) . '</body></html>';
exit;
}
if (Util:: removeParameter($login_screen, array('url', 'nocache')) !=
Util:: removeParameter(Horde:: selfUrl(false, false, true), array('url', 'nocache'))) {
$url = Auth:: addLogoutParameters($login_screen);
if ($url_param) {
$url = Util:: addParameter($url, 'url', $url_param);
}
header('Location: ' . $url);
exit;
}
$language = isset($prefs) ? $prefs-> getValue('language') : NLS:: select();
$entry = sprintf('User %s [%s] logged out of Horde',
Auth:: getAuth(), $_SERVER['REMOTE_ADDR']);
Horde:: logMessage($entry, __FILE__, __LINE__, PEAR_LOG_NOTICE );
Auth:: clearAuth();
@ session_destroy();
/* Redirect the user on logout if redirection is enabled. */
if (! empty($conf['auth']['redirect_on_logout'])) {
$logout_url = $conf['auth']['redirect_on_logout'];
if (! isset($_COOKIE[session_name()])) {
$logout_url = Util:: addParameter($logout_url, session_name(), session_id());
}
header('Location: ' . $logout_url);
exit;
}
Horde:: setupSessionHandler();
@ session_start();
NLS:: setLang($language);
/* Hook to preselect the correct language in the widget. */
$_GET['new_lang'] = $language;
}
if (isset($_POST['horde_user']) && isset($_POST['horde_pass'])) {
/* Destroy any existing session on login and make sure to use a
* new session ID, to avoid session fixation issues. */
Horde:: getCleanSession();
if ($auth-> authenticate(Util:: getPost('horde_user'),
array('password' => Util:: getPost('horde_pass')))) {
$entry = sprintf('Login success for %s [%s] to Horde',
Auth:: getAuth(), $_SERVER['REMOTE_ADDR']);
Horde:: logMessage($entry, __FILE__, __LINE__, PEAR_LOG_NOTICE );
if ($ie_version) {
$browser-> setIEVersion($ie_version);
}
if ($url_param) {
$url = Horde:: url(Util:: removeParameter($url_param, session_name()), true);
$horde_url = $registry-> get('webroot', 'horde') . '/index.php';
$horde_url = Util:: addParameter($horde_url, 'url', $url);
} else {
$horde_url = Horde:: url($registry-> get('webroot', 'horde') . '/index.php');
}
$url = Horde:: applicationUrl($horde_url, true);
if ($browser-> isBrowser('msie') &&
$conf['use_ssl'] == 3 &&
strlen($url) < 160) {
header('Refresh: 0; URL=' . $url);
} else {
header('Location: ' . $url);
}
exit;
} else {
$entry = sprintf('FAILED LOGIN for %s [%s] to Horde',
Util:: getFormData('horde_user'), $_SERVER['REMOTE_ADDR']);
Horde:: logMessage($entry, __FILE__, __LINE__, PEAR_LOG_ERR );
if ($conf['menu']['always']) {
$main_page = Util:: addParameter(Horde:: selfUrl(), 'reason', $auth-> getLogoutReasonString());
if ($browser-> hasQuirk('scrollbar_in_way')) {
$scrollbar = 'yes';
} else {
$scrollbar = 'auto';
}
require HORDE_TEMPLATES . '/index/frames_index.inc';
exit;
}
}
}
if (Auth:: getAuth()) {
if ($browser-> isMobile()) {
$url = 'services/portal/mobile.php';
} else {
$url = 'services/portal/index.php';
}
require HORDE_BASE . '/' . $url;
exit;
}
/* Try transparent authentication. */
if (Auth:: isAuthenticated()) {
require HORDE_BASE . '/index.php';
exit;
}
/* Redirect the user if an alternate login page has been specified. */
if (! empty($conf['auth']['alternate_login'])) {
$url = Auth:: addLogoutParameters($conf['auth']['alternate_login']);
if (! isset($_COOKIE[session_name()])) {
$url = Util:: addParameter($url, session_name(), session_id(), false);
}
if ($url_param) {
$url = Util:: addParameter($url, 'url', $url_param, false);
}
header('Location: ' . $url);
exit;
}
$login_screen = $auth->_getLoginScreen ();
if (Util:: removeParameter($login_screen, array('url', 'nocache')) !=
Horde:: selfUrl(false, false, true)) {
if ($url_param) {
$login_screen = Util:: addParameter($login_screen, 'url', $url_param, false);
}
if ($ie_version) {
$login_screen = Util:: addParameter($login_screen, 'ie_version', $ie_version, false);
}
header('Location: ' . $login_screen);
exit;
}
if ($browser-> isMobile()) {
require_once 'Horde/Mobile.php';
require HORDE_TEMPLATES . '/login/mobile.inc';
exit;
}
/* Build the <select> widget containing the available languages. */
if (! $prefs-> isLocked('language')) {
$_SESSION['horde_language'] = NLS:: select();
$langs = '<select name="new_lang" onchange="selectLang()">';
foreach ($nls['languages'] as $key => $val) {
$sel = ($key == $_SESSION['horde_language']) ? ' selected="selected"' : '';
$langs .= "<option value=\"$key\"$sel>$val</option>";
}
$langs .= '</select>';
}
$title = _("Log in");
$notification-> push('setFocus()', 'javascript');
if ($logout_reason && $conf['menu']['always']) {
$notification-> push('if (window.parent.frames.horde_menu) window.parent.frames.horde_menu.location.href = \'' . Horde:: applicationUrl('services/portal/sidebar.php') . '\';', 'javascript');
}
$reason = $auth-> getLogoutReasonString();
/* Add some javascript. */
Horde:: addScriptFile('enter_key_trap.js', 'horde', true);
/* Do we need to do IE version detection? */
if (($browser-> getBrowser() == 'msie') && ($browser-> getMajor() >= 5)) {
$ie_clientcaps = true;
}
require HORDE_TEMPLATES . '/common-header.inc';
require HORDE_TEMPLATES . '/login/login.inc';
require HORDE_TEMPLATES . '/common-footer.inc'; |
|
|

Sab Nov 11, 2006 9:19 pm
|
 |
hinoeath
Perlero Nuevo

|
Registrado: 09 Nov 2006
Mensajes: 10
Ubicación: Barranquilla-Colombia
|
|
| Solucionado |
|
|
Sólo tenía que enviar los argumentos a login.php y no al index como venía haciéndolo... en fin la ruta quedó así: http://www.dominio.com:2082/horde/login.php (eso para que no me abriese, nuevamente la ventana pop-up de logueo).
Y no tuve problemas con las cookies chequeando el código de "login.php"... vemos que él destruye las cookies al momento de tratar de autenticarnos nuevamente...
salu2 y gracias =) misión cumplida..  |
|
Powered by phpBB © 2001, 2005 phpBB Group
|