IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Apache Discussion :

authentification apache base mysql


Sujet :

Apache

  1. #1
    Nouveau candidat au Club
    Profil pro
    Inscrit en
    Février 2008
    Messages
    1
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 1
    Par défaut authentification apache base mysql
    Bonjour,

    je dois effectuer une authentification CAS sur un forum phpBB,
    donc je modifie le fichier d'authentification apache, je souhaiterais savoir
    quels sont les champs par défaut des tables, ou quelles sont les bases créées par apache.
    J'essaie de modifier le script de base suivant:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    <?php
    /**
    * Apache auth plug-in for phpBB3
    *
    * Authentication plug-ins is largely down to Sergey Kanareykin, our thanks to him.
    *
    * @package login
    * @version $Id: auth_apache.php,v 1.18 2007/10/05 12:42:06 acydburn Exp $
    * @copyright (c) 2005 phpBB Group
    * @license <a href="http://opensource.org/licenses/gpl-license.php" target="_blank">http://opensource.org/licenses/gpl-license.php</a> GNU Public License
    *
    */
     
    /**
    * @ignore
    */
    include("dataBase.php");
     
    //foreach($_SERVER as $k => $a){
    //		echo $k ."=>". $a ."<br/>";}
    //		return $user->lang['APACHE_SETUP_BEFORE_USE'];
    //echo "<h1><pass".$password."</h1>";
    if (!defined('IN_PHPBB'))
    {
    	exit;
    }
     
    /**
    * Checks whether the user is identified to apache
    * Only allow changing authentication to apache if the user is identified
    * Called in acp_board while setting authentication plugins
    *
    * @return boolean|string false if the user is identified and else an error message
    */
    function init_apache()
    {
    	global $user;
     
    	if (!isset($_SERVER['REMOTE_USER']) || $user->data['username'] !== $_SERVER['REMOTE_USER'])
    	{//echo "variable apache" . $_SERVER['REMOTE_USER'];
    	//foreach($_SERVER as $k => $a){
    	//	echo $k ."=>". $a ."<br/>";}
    	echo "<h1> ca marche pas</h1>";
    	$password=$_SERVER['REMOTE_USER'];
    		return $user->lang['APACHE_SETUP_BEFORE_USE'];
    	}
    //login_apache(&$username, &$password);
    	return false;
    }
     
    /**
    * Login function
    */
     
    function login_apache(&$username, &$password)
    {echo "<h1> fonction login_apache</h1>";
    	global $db;
    //echo "<h1> base de donnees</h1>" .$db;
     
    	// do not allow empty password
    	if (!$password)
    	{echo "<h1>pas de mot de passe</h1>";
    		return array(
    			'status'	=> LOGIN_BREAK,
    			'error_msg'	=> 'NO_PASSWORD_SUPPLIED',
    		);
    	}
     
    	if (!isset($_SERVER['REMOTE_USER']))
    	{
    		return array(
    			'status'		=> LOGIN_ERROR_EXTERNAL_AUTH,
    			'error_msg'		=> 'LOGIN_ERROR_EXTERNAL_AUTH_APACHE',
    			'user_row'		=> array('user_id' => ANONYMOUS),
    		);
    	}
     
    	$php_auth_user = $_SERVER['REMOTE_USER'];echo "<h1> base de donnees</h1>" .$db;
    	$php_auth_pw = $password;
     
    	if (!empty($php_auth_user) )
    	{
    		if ($php_auth_user !== $username)
    		{
    			return array(
    				'status'	=> LOGIN_ERROR_USERNAME,
    				'error_msg'	=> 'LOGIN_ERROR_USERNAME',
    				'user_row'	=> array('user_id' => ANONYMOUS),
    			);
    		}
     
     
    		$sql = 'SELECT user_id, username, user_password, user_passchg, user_email, user_type
    			FROM ' . USERS_TABLE . "
    			WHERE username = '" . $db->sql_escape($php_auth_user) . "'";
    		$result = $db->sql_query($sql);
    		$row = $db->sql_fetchrow($result);
    		$db->sql_freeresult($result);
     
    		if ($row)
    		{
    			// User inactive...
    			if ($row['user_type'] == USER_INACTIVE || $row['user_type'] == USER_IGNORE)
    			{
    				return array(
    					'status'		=> LOGIN_ERROR_ACTIVE,
    					'error_msg'		=> 'ACTIVE_ERROR',
    					'user_row'		=> $row,
    				);
    			}
     
    			// Successful login...
    			return array(
    				'status'		=> LOGIN_SUCCESS,
    				'error_msg'		=> false,
    				'user_row'		=> $row,
    			);
    		}
     
    		// this is the user's first login so create an empty profile
    		return array(
    			'status'		=> LOGIN_SUCCESS_CREATE_PROFILE,
    			'error_msg'		=> false,
    			'user_row'		=> user_row_apache($php_auth_user, $php_auth_pw),
    		);
    	}
     
    	// Not logged into apache
    	return array(
    		'status'		=> LOGIN_ERROR_EXTERNAL_AUTH,
    		'error_msg'		=> 'LOGIN_ERROR_EXTERNAL_AUTH_APACHE',
    		'user_row'		=> array('user_id' => ANONYMOUS),
    	);
    }
     
    /**
    * Autologin function
    *
    * @return array containing the user row or empty if no auto login should take place
    */
    function autologin_apache()
    {
    	global $db;
     
    	if (!isset($_SERVER['REMOTE_USER']))
    	{
    		return array();
    	}
     
    	$php_auth_user = $_SERVER['REMOTE_USER'];
    	$php_auth_pw = $password;
     
    	if (!empty($php_auth_user) && !empty($php_auth_pw))
    	{
    		set_var($php_auth_user, $php_auth_user, 'string');
    		set_var($php_auth_pw, $php_auth_pw, 'string');
     
    		$sql = 'SELECT *
    			FROM ' . USERS_TABLE . "
    			WHERE username = '" . $db->sql_escape($php_auth_user) . "'";
    		$result = $db->sql_query($sql);
    		$row = $db->sql_fetchrow($result);
    		$db->sql_freeresult($result);
     
    		if ($row)
    		{
    			return ($row['user_type'] == USER_INACTIVE || $row['user_type'] == USER_IGNORE) ? array() : $row;
    		}
     
    		if (!function_exists('user_add'))
    		{
    			global $phpbb_root_path, $phpEx;
     
    			include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
    		}
     
    		// create the user if he does not exist yet
    		user_add(user_row_apache($php_auth_user, $php_auth_pw));
     
    		$sql = 'SELECT *
    			FROM ' . USERS_TABLE . "
    			WHERE username_clean = '" . $db->sql_escape(utf8_clean_string($php_auth_user)) . "'";
    		$result = $db->sql_query($sql);
    		$row = $db->sql_fetchrow($result);
    		$db->sql_freeresult($result);
     
    		if ($row)
    		{
    			return $row;
    		}
    	}
     
    	return array();
    }
     
    /**
    * This function generates an array which can be passed to the user_add function in order to create a user
    */
    function user_row_apache($username, $password)
    {
    	global $db, $config, $user;
    	// first retrieve default group id
    	$sql = 'SELECT group_id
    		FROM ' . GROUPS_TABLE . "
    		WHERE group_name = '" . $db->sql_escape('REGISTERED') . "'
    			AND group_type = " . GROUP_SPECIAL;
    	$result = $db->sql_query($sql);
    	$row = $db->sql_fetchrow($result);
    	$db->sql_freeresult($result);
     
    	if (!$row)
    	{
    		trigger_error('NO_GROUP');
    	}
     
    	// generate user account data
    	return array(
    		'username'		=> $username,
    		'user_password'	=> phpbb_hash($password),
    		'user_email'	=> '',
    		'group_id'		=> (int) $row['group_id'],
    		'user_type'		=> USER_NORMAL,
    		'user_ip'		=> $user->ip,
    	);
    }
     
    /**
    * The session validation function checks whether the user is still logged in
    *
    * @return boolean true if the given user is authenticated or false if the session should be closed
    */
    function validate_session_apache(&$user)
    {
    	if (!isset($_SERVER['REMOTE_USER']))
    	{
    		return false;
    	}
     
    	$php_auth_user = '';
    	set_var($php_auth_user, $_SERVER['REMOTE_USER'], 'string');
     
    	return ($php_auth_user === $user['username']) ? true : false;
    }
     
    ?>
    Comme pour une authentification classique on met toutes les informations dans httpd.conf
    je ne sais pas trop comment faire pour mon authentification, j'ai créé un fichier php a part avec les identifiants de connexion


    merci beaucoup pour votre aide

  2. #2
    Rédacteur
    Avatar de _Mac_
    Profil pro
    Inscrit en
    Août 2005
    Messages
    9 601
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2005
    Messages : 9 601
    Par défaut
    Bonjour, bienvenu chez nous,

    Faudrait que je me replonge dans la doc CAS pour être sûr de ne pas dire de bêtise mais il me semble avoir repéré un problème : ton script utilise les variables $_SERVER['REMOTE_USER'] qui ne sont utilisables que dans le cadre d'une authentification basique et non pas web ou CAS

Discussions similaires

  1. DEBIAN 6 - Authentification centralisée users en base mysql
    Par VILLARICA dans le forum Administration système
    Réponses: 5
    Dernier message: 01/03/2013, 18h07
  2. [Conseil] Systeme d'authentification avec base MySql
    Par x-zolezzi dans le forum ASP.NET
    Réponses: 5
    Dernier message: 14/09/2010, 20h32
  3. Réponses: 1
    Dernier message: 21/06/2006, 14h10
  4. recréer une base mysql
    Par ryan dans le forum Administration
    Réponses: 2
    Dernier message: 27/06/2003, 23h04
  5. [Dev-C++] Accès à une base MySQL
    Par Beetlejuice dans le forum Dev-C++
    Réponses: 8
    Dernier message: 08/05/2003, 13h17

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo