Bonjour,
Je ne sais pas si l'intitulé de ma discussion est celui qui correspond le mieux...
Je vous explique mon problème.
Je veux mettre en place une reconnaissance automatique des utilisateurs via SSO en utilisant le module apache mod_auth_sspi (http://sourceforge.net/projects/mod-auth-sspi/).
Afin de n'identifier que certaines IP j'aimerais que l'authentification en SSO se fasse dans un sous dossier.
On aurait ainsi :
index.php : inclut le fichier fonctions.inc.php et fait l'authentification
fonction/fonctions.inc.php : fournit la fonction detectRemoteUser() qui retourne le nom de l'utilisateur reconnu (ou false).
La fonction detectRemoteUser() inclut le fichier fonction_sso.inc.php uniquement si l'utilisateur veut utiliser le SSO et si l'adresse IP de l'utilisateur est dans un tableau prédéfini d'adresse IP autorisées. Ce fichier fournit la fonction getDetectRemoteUser() qui récupère la variable contenue dans $_SERVER['REMOTE_USER'].
fonction/auth_sso/fonction_sso.inc.php : fournit la fonction getDetectRemoteUser()
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 function detectRemoteUser() { if (canUseSSO()) { include_once('auth_sso/fonctions_sso.php'); $user = getDetectRemoteUser(); return $user; } else { return false; } }
Pour cela, j'ai modifié mon httpd.conf ainsi :
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 function getDetectRemoteUser() { $remote_user = false; // retour par défaut if (isset($_SERVER['REMOTE_USER'])) { // Si l'authentification se fait avec SSPI NTLM $cred = explode('\\', $_SERVER['REMOTE_USER']); if (count($cred) == 1) array_unshift($cred, "(Pas d'information sur le domaine)"); list($domain, $remote_user) = $cred; $remote_user = strtolower($remote_user); if (is_null($remote_user) || $remote_user == '') $remote_user = false; } return $remote_user; }
Je pensais que cela marcherait ... hé bien non ! (Sinon je ne posterai pas de message ici )
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 ############################# <Directory "D:/Intranet"> # # Possible values for the Options directive are "None", "All", # or any combination of: # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews # # Note that "MultiViews" must be named *explicitly* --- "Options All" # doesn't give it to you. # # The Options directive is both complicated and important. Please see # http://httpd.apache.org/docs/2.2/mod/core.html#options # for more information. # Options Indexes FollowSymLinks # # AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # Options FileInfo AuthConfig Limit # AllowOverride None # # Controls who can get stuff from this server. # Order allow,deny Allow from all </Directory> <Directory "D:/Intranet/testldap/fonction/auth_sso/"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all ######################################################################################### ## Ajout Mikael AuthType SSPI SSPIAuth On SSPIAuthoritative On SSPIDomain dc.mydomain.fr ## Set this if you want to allow access with clients that do not support NTLM, or via proxy from outside. Don't forget to require SSL in this case! SSPIOfferBasic Off SSPIBasicPreferred On ## Set this if you have only one domain and don't want the MYDOMAIN\ prefix on each user name SSPIOmitDomain On ## AD user names are case-insensitive, so use this for normalization if your application's user names are case-sensitive SSPIUsernameCase Lower # Available only starting with 1.0.4 version of mod_auth_sspi. Probably helps with IE problems with POST if On (but it will generate 401 requests in error.log for each page request) SSPIOfferSSPI On SSPIPerRequestAuth On AuthName "Veuillez vous authentifier" Require valid-user ######################################################################################### </Directory> #############################
L'inclusion de mon fichier fonction_sso.inc.php ne fonctionne pas, et le seul moyen que j'ai trouvé afin de reconnaître mon utilisateur est de passer par une requête Ajax qui appelle un fichier script_sso.php (présent dans fonction/auth_sso/script_sso.php) affichant le nom de l'utilisateur. Je trouve cela très moyen moyen, et j'aimerai avoir une meilleure solution.
Auriez vous des idées ?
D'avance, merci pour votre aide.
Mikael
Partager