Subversion Repositories wimsdev

Rev

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