Rev 5028 | Rev 5045 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
23 | reyssat | 1 | !if $auth_password=*wims_site_manager |
2 | !if $wims_ismanager<2 |
||
3 | auth_password= |
||
4 | !else |
||
5 | !goto auth_ok |
||
6 | !endif |
||
7 | !endif |
||
8 | |||
4360 | guerimand | 9 | !if $save_logincgu!=$empty |
10 | !if $agreecgu=yes |
||
11 | !read adm/class/userdef wimshome/log/classes,$class,$user |
||
12 | !setdef !set user_agreecgu=yes in $userdef/$save_logincgu |
||
13 | !endif |
||
14 | !reset $save_logincgu |
||
15 | !endif |
||
16 | |||
23 | reyssat | 17 | !read adm/class/authchars |
18 | auth_user=!word 1 of $auth_user |
||
19 | auth_password=!word 1 of $auth_password |
||
633 | bpr | 20 | |
5015 | bpr | 21 | # new variables to keep original data (used only in external authentication) |
633 | bpr | 22 | auth_user_connection=$auth_user |
23 | auth_password_connection=$auth_password |
||
24 | |||
4993 | bpr | 25 | ##### EXTERNAL connection - part 1 ##### |
5028 | bpr | 26 | !!default sclass=$class |
633 | bpr | 27 | |
5028 | bpr | 28 | !if ($auth_user notsametext supervisor or $class_type>0) and $auth_method isitemof $auth_method_list |
5015 | bpr | 29 | authdef=wimshome/log/classes/$superclass/.def |
5028 | bpr | 30 | |
633 | bpr | 31 | # don't use auth_user and auth_password, some characters are unvailable |
4993 | bpr | 32 | # parameters are empty for auth-cas |
633 | bpr | 33 | !readproc adm/class/auth-$auth_method $auth_user_connection,$auth_password_connection |
34 | |||
4993 | bpr | 35 | auth_user_orig=$auth_user |
36 | |||
4614 | bpr | 37 | # if ldap connection is OK, replace auth_user by $ldap_login (ie auth_test) |
4993 | bpr | 38 | !! !if ERROR notwordof $auth_test |
39 | !! !if $auth_test!=$empty |
||
40 | !! auth_test=OK |
||
41 | !! !endif |
||
42 | !! !endif |
||
633 | bpr | 43 | !endif |
4993 | bpr | 44 | ##### end of EXTERNAL connection - part 1 ##### |
633 | bpr | 45 | # now we can run the script |
5015 | bpr | 46 | !if $auth_method isitemof $auth_method_list and $auth_user!=supervisor |
47 | FIXME regarder aussi dans .teacherlist_external |
||
5034 | czzmrn | 48 | auth_user=!lookup $auth_user_orig in wimshome/log/classes/$superclass/.userlist_external |
49 | !if $auth_user=$empty |
||
50 | auth_user=!lookup $auth_user_orig in wimshome/log/classes/$superclass/.teacherlist_external |
||
51 | !endif |
||
4993 | bpr | 52 | !endif |
23 | reyssat | 53 | auth_user=!translate internal . to @ in $auth_user |
54 | auth_user=!text select $char_login in $auth_user |
||
55 | auth_password=!text select $char_passwd in $auth_password |
||
56 | now=$wims_now |
||
57 | logfile=wimshome/log/classes/$class/.log.auth |
||
58 | logfiles=wimshome/log/classes/$class/.log |
||
59 | logline=$now $auth_user $$passwd $httpd_REMOTE_ADDR |
||
60 | |||
61 | !read adm/class/userdef classes,$class,$auth_user |
||
62 | |||
63 | pass=!defof user_password in $userdef |
||
5015 | bpr | 64 | FIXME ### Have to check that sclass is no yet useful |
65 | sclass=!defof class_superclass in wimshome/log/classes/$class/.def |
||
66 | !if $superclass!=$empty and $superclass!=$class |
||
23 | reyssat | 67 | upartic=!defof user_participate in $userdef |
68 | usuperv=!defof user_supervise in $userdef |
||
69 | pclass=!defof class_parent in wimshome/log/classes/$class/.def |
||
70 | !if / isin $pclass and ../$pclass/ isin ../$class |
||
71 | ss=!defof class_ocourses in wimshome/log/classes/$pclass/.def |
||
72 | !if $ss!=$empty |
||
73 | ss=!makelist $wims_superclass/xx for xx in $ss |
||
74 | upartic=!append item $ss to $upartic |
||
75 | !endif |
||
76 | !endif |
||
77 | coursecheck=!defof user_class in wimshome/log/classes/$class/.users/$auth_user |
||
78 | !if $coursecheck!=$empty |
||
79 | upartic=!append item $class to $upartic |
||
80 | !endif |
||
81 | !if $auth_user=supervisor and $wims_user=supervisor |
||
82 | ctype=!defof class_typename in wimshome/log/classes/$class/.def |
||
83 | prog=!defof sharing_exam in wimshome/log/classes/$class/neighbors |
||
84 | !if $ctype iswordof course icourse and $prog=$wims_class |
||
85 | pass=$current_pass |
||
86 | !endif |
||
87 | !endif |
||
5001 | bpr | 88 | !if $class notitemof $upartic and $auth_user!=supervisor and $wims_user!=supervisor |
23 | reyssat | 89 | pass= |
90 | !endif |
||
91 | # These lines should be opened later to close this possibility. |
||
92 | # !if $auth_user=supervisor and $wims_user=$empty |
||
93 | # pass= |
||
94 | # !endif |
||
95 | !endif |
||
96 | |||
5001 | bpr | 97 | !if $auth_user=supervisor |
98 | !goto wimsauth |
||
99 | !endif |
||
100 | |||
4993 | bpr | 101 | ##### final test of external connection ##### |
102 | # finaly, we must check if user is allowed in class |
||
633 | bpr | 103 | |
23 | reyssat | 104 | exist_check=!defof user_exists in $userdef |
5016 | bpr | 105 | |
5015 | bpr | 106 | !if OK iswordof $auth_test and $auth_method isitemof $auth_method_list |
4993 | bpr | 107 | !if $exist_check issametext yes |
108 | !goto auth_ok |
||
109 | !else |
||
110 | !setdef user_auth=$auth_user_orig in wimshome/$wims_sesdir/var.stat |
||
5001 | bpr | 111 | !goto end |
4993 | bpr | 112 | !endif |
23 | reyssat | 113 | !endif |
4993 | bpr | 114 | ##### end of final test of external connection ##### |
5001 | bpr | 115 | :wimsauth |
5015 | bpr | 116 | |
23 | reyssat | 117 | pass=!passcrypt $pass |
118 | !if $pass=$empty |
||
119 | passwd=???? |
||
120 | !appendfile $logfile $logline |
||
3494 | bpr | 121 | auth_user=$auth_user_orig |
23 | reyssat | 122 | error=bad_password |
123 | !exit |
||
124 | !endif |
||
125 | |||
126 | !if $wims_superclass!=$empty and $wims_user!=supervisor and $auth_user!=$wims_user |
||
127 | supervisable=!defof user_supervisable in wimshome/log/classes/$wims_superclass/.users/$wims_user |
||
128 | !if $supervisable!=yes |
||
129 | current_pass= |
||
130 | !endif |
||
131 | !endif |
||
132 | |||
133 | cps=!passcrypt $current_pass |
||
134 | !if ($auth_user!=$empty and $class $auth_user isitemof $wims_otherclass) or \ |
||
135 | ($current_pass!=$empty and $cps iswordof $pass) or \ |
||
136 | ($auth_user=$wims_user and $class isitemof $wims_participate) or \ |
||
137 | ($auth_user=supervisor and $wims_user=supervisor and \ |
||
5015 | bpr | 138 | (../$wims_class/ isin ../$class/ or $superclass=$wims_class)) or \ |
23 | reyssat | 139 | ($auth_user=supervisor and $class isitemof $wims_supervise) |
140 | !goto auth_ok |
||
141 | !endif |
||
142 | |||
143 | !if $auth_password=$empty |
||
144 | !exit |
||
145 | !endif |
||
146 | |||
147 | !read adm/class/authdelay |
||
148 | !if $auth_password notwordof $pass |
||
149 | passwd=?????? |
||
150 | !appendfile $logfile $logline |
||
3494 | bpr | 151 | auth_user=$auth_user_orig |
23 | reyssat | 152 | error=bad_password |
153 | !exit |
||
154 | !endif |
||
155 | |||
156 | :auth_ok |
||
157 | !if $auth_user=supervisor and $wims_user!=$empty and $wims_user!=supervisor and \ |
||
158 | $class notitemof $wims_supervise |
||
159 | userdef_save=$userdef |
||
160 | !read adm/class/userdef classes,$wims_class,$wims_user |
||
161 | !exchange userdef_save,userdef |
||
162 | spv=!defof user_supervisable in $userdef_save |
||
163 | !if $spv=yes |
||
164 | wims_supervise=!append item $class to $wims_supervise |
||
165 | !setdef !set user_supervise=$wims_supervise in $userdef_save |
||
166 | !endif |
||
167 | !endif |
||
168 | n=!positionof word $auth_password in $pass |
||
169 | n=!item 1 of $n |
||
170 | !if $n!=$empty |
||
171 | passwd=OK$n $ |
||
172 | !else |
||
173 | passwd=$wims_class |
||
174 | !endif |
||
175 | # one-time password |
||
176 | !if $n!=$empty and $n>1 |
||
177 | pass=!replace word $auth_password by $ in $pass |
||
178 | pass=!singlespace $pass |
||
179 | pass=!trim $pass |
||
180 | !setdef !set user_password=$pass in $userdef |
||
181 | !endif |
||
182 | |||
183 | !defread $userdef |
||
184 | ctype=!defof class_type in wimshome/log/classes/$class/.def |
||
185 | !if $ctype=4 and $auth_user!=supervisor and $user_supervisable!=yes\ |
||
186 | and (/ notin $wims_class or ../$wims_superclass/ notin ../$wims_class/) |
||
187 | utest=!itemcnt $user_participate |
||
188 | !if $utest=1 and / isin $user_participate |
||
189 | class=!item 1 of $user_participate |
||
190 | !defread wimshome/log/classes/$class/.def |
||
191 | !endif |
||
192 | !endif |
||
193 | clang=!defof class_lang in wimshome/log/classes/$class/.def |
||
194 | |||
4360 | guerimand | 195 | |
196 | |||
23 | reyssat | 197 | !if $auth_user=supervisor |
198 | sech=!defof class_secure in wimshome/log/classes/$class/.def |
||
199 | sech=!trim $sech |
||
200 | !if $sech=$empty |
||
201 | t=0 |
||
202 | !else |
||
203 | t=!checkhost $sech |
||
204 | !if $t<1 |
||
205 | t=-1 |
||
206 | !endif |
||
207 | !endif |
||
208 | sup_secure=$t |
||
209 | !else |
||
210 | !read adm/class/raftest |
||
211 | !if $raftest>$lastallow |
||
212 | error=recent_rafale |
||
213 | !exit |
||
214 | !endif |
||
215 | sup_secure=-1 |
||
4424 | bpr | 216 | !if $user_agreecgu notwordof yes external |
4360 | guerimand | 217 | error=no_cgu |
218 | !exit |
||
219 | !endif |
||
23 | reyssat | 220 | !endif |
221 | |||
222 | !read adm/class/authprep $class,$auth_user |
||
223 | |||
224 | !if $logfile!=$empty |
||
225 | !if $auth_user=supervisor |
||
226 | !appendfile $logfiles $now $httpd_REMOTE_ADDR supervisor login |
||
227 | !else |
||
228 | !appendfile $logfile $logline |
||
229 | !endif |
||
230 | !endif |
||
231 | |||
232 | !if $class_lock=7 and $auth_user!=supervisor |
||
233 | !usererror class_closed |
||
234 | !exit |
||
235 | !endif |
||
236 | |||
237 | !if $class_lock iswordof 2 4 6 |
||
238 | !set wims_protocol=https |
||
239 | !endif |
||
240 | !if $wims_user=$empty and $changesession!=no |
||
241 | !writefile wimshome/$wims_sesdir/var.class.prep $classdef |
||
242 | random=!randint 10^5,10^9 |
||
243 | !restart session=new.$random&lang=$clang&old_session=$wims_session&module=home |
||
244 | !else |
||
245 | !setdef $classdef in wimshome/$wims_sesdir/var.stat |
||
246 | !sh cd $wims_home\ |
||
247 | rm -Rf $(wims_sesdir)_*\ |
||
248 | mkdir -p log/classes/$class/score $wims_sesdir/getfile\ |
||
249 | rm -f $wims_sesdir/exam*\ |
||
250 | rm -f $wims_sesdir/getfile/oefimages\ |
||
251 | ln -s $wims_home/log/classes/$class/src/images $wims_sesdir/getfile/oefimages |
||
252 | !restart lang=$clang&module=home |
||
253 | !endif |
||
254 | |||
5001 | bpr | 255 | :end |