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