Subversion Repositories wimsdev

Rev

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