4
4
# --- BEGIN_HEADER ---
5
5
#
6
6
# reqpwresetaction - handle account password reset requests and send email to user
7
- # Copyright (C) 2003-2024 The MiG Project lead by Brian Vinter
7
+ # Copyright (C) 2003-2025 The MiG Project by the Science HPC Center at UCPH
8
8
#
9
9
# This file is part of MiG.
10
10
#
30
30
from __future__ import absolute_import
31
31
32
32
import os
33
- import tempfile
34
- import time
35
33
36
34
from mig .shared import returnvalues
37
- from mig .shared .base import canonical_user_with_peers , generate_https_urls , \
38
- fill_distinguished_name , cert_field_map , auth_type_description , \
39
- mask_creds , is_gdp_user
40
- from mig .shared .defaults import keyword_auto , RESET_TOKEN_TTL
41
- from mig .shared .functional import validate_input , REJECT_UNSET
42
- from mig .shared .griddaemons .https import default_max_user_hits , \
43
- default_user_abuse_hits , default_proto_abuse_hits , hit_rate_limit , \
44
- expire_rate_limit , validate_auth_attempt
45
- from mig .shared .handlers import safe_handler , get_csrf_limit
46
- from mig .shared .htmlgen import themed_styles , themed_scripts
47
- from mig .shared .init import initialize_main_variables , find_entry
35
+ from mig .shared .base import auth_type_description , canonical_user_with_peers , \
36
+ cert_field_map , is_gdp_user , mask_creds
37
+ from mig .shared .defaults import RESET_TOKEN_TTL , keyword_auto
38
+ from mig .shared .functional import REJECT_UNSET , validate_input
39
+ from mig .shared .griddaemons .https import default_proto_abuse_hits , \
40
+ default_user_abuse_hits , expire_rate_limit , hit_rate_limit , \
41
+ validate_auth_attempt
42
+ from mig .shared .handlers import get_csrf_limit , safe_handler
43
+ from mig .shared .htmlgen import themed_scripts , themed_styles
44
+ from mig .shared .init import initialize_main_variables
48
45
from mig .shared .notification import send_email
49
46
from mig .shared .pwcrypto import generate_reset_token
50
47
from mig .shared .url import urlencode
@@ -125,7 +122,7 @@ def main(client_id, user_arguments_dict):
125
122
'class' : 'genericbutton' , 'text' : "Try again" })
126
123
return (output_objects , returnvalues .CLIENT_ERROR )
127
124
128
- if not auth_type in configuration .site_login_methods :
125
+ if auth_type not in configuration .site_login_methods :
129
126
output_objects .append ({'object_type' : 'error_text' , 'text' :
130
127
'You must provide a supported auth_type!' })
131
128
output_objects .append (
@@ -141,7 +138,6 @@ def main(client_id, user_arguments_dict):
141
138
'class' : 'genericbutton' , 'text' : "Back" })
142
139
return (output_objects , returnvalues .CLIENT_ERROR )
143
140
144
- mig_user = os .environ .get ('USER' , 'mig' )
145
141
client_addr = os .environ .get ('REMOTE_ADDR' , None )
146
142
tcp_port = int (os .environ .get ('REMOTE_PORT' , '0' ))
147
143
anon_migoid_url = configuration .migserver_https_sid_url
@@ -165,13 +161,13 @@ def main(client_id, user_arguments_dict):
165
161
(authorized , disconnect ) = validate_auth_attempt (
166
162
configuration ,
167
163
proto ,
168
- op_name ,
164
+ "passwordreset" ,
169
165
cert_id ,
170
166
client_addr ,
171
167
tcp_port ,
172
168
secret = None ,
173
169
authtype_enabled = True ,
174
- auth_reset = True ,
170
+ modify_account = True ,
175
171
exceeded_rate_limit = exceeded_rate_limit ,
176
172
user_abuse_hits = default_user_abuse_hits ,
177
173
proto_abuse_hits = default_proto_abuse_hits ,
@@ -211,7 +207,7 @@ def main(client_id, user_arguments_dict):
211
207
# Registered emails are automatically lowercased
212
208
search_filter ['email' ] = cert_id .lower ()
213
209
(_ , hits ) = search_users (search_filter , configuration , keyword_auto , False )
214
- user_dict , password_hash = None , None
210
+ user_dict = None
215
211
for (uid , user_dict ) in hits :
216
212
if is_gdp_user (configuration , uid ):
217
213
logger .debug ("skip password reset for gdp sub-user %r" % cert_id )
@@ -227,7 +223,7 @@ def main(client_id, user_arguments_dict):
227
223
try :
228
224
reset_token = generate_reset_token (configuration , user_dict ,
229
225
auth_type )
230
- except ValueError as vae :
226
+ except ValueError :
231
227
logger .info ("skip password reset for %r without matching auth" %
232
228
cert_id )
233
229
continue
0 commit comments