4848
4949gConfigNeeded = [ '--allowed.schemes' , '--allowed.domains' , '--bearer.insecure' ]
5050
51- gAllowedCalls = [ "urltext" , "urlraw" , "pdftext" ]
51+ gAllowedCalls = {
52+ "urltext" : [],
53+ "urlraw" : [],
54+ "pdftext" : [ "pypdf" ]
55+ }
5256
5357
5458def bearer_transform ():
@@ -157,6 +161,7 @@ def handle_aum(ph: ProxyHandler, pr: urllib.parse.ParseResult):
157161 Handle requests to aum path, which is used in a simple way to
158162 verify that one is communicating with this proxy server
159163 """
164+ import importlib
160165 queryParams = urllib .parse .parse_qs (pr .query )
161166 url = queryParams ['url' ]
162167 print (f"DBUG:HandleAUM:Url:{ url } " )
@@ -165,9 +170,15 @@ def handle_aum(ph: ProxyHandler, pr: urllib.parse.ParseResult):
165170 ph .send_error (400 , f"WARN:HandleAUM:MissingUrl/UnknownQuery?!" )
166171 return
167172 urlParts = url .split ('.' ,1 )
168- if not (urlParts [0 ] in gAllowedCalls ) :
169- ph .send_error (403 , f"WARN:HandleAUM:Forbidded :{ urlParts [0 ]} " )
173+ if gAllowedCalls . get (urlParts [0 ], None ) == None :
174+ ph .send_error (403 , f"WARN:HandleAUM:Forbidden :{ urlParts [0 ]} " )
170175 return
176+ for dep in gAllowedCalls [urlParts [0 ]]:
177+ try :
178+ importlib .import_module (dep )
179+ except ImportError as exc :
180+ ph .send_error (400 , f"WARN:HandleAUM:{ urlParts [0 ]} :Support module [{ dep } ] missing or has issues" )
181+ return
171182 print (f"INFO:HandleAUM:Availability ok for:{ urlParts [0 ]} " )
172183 ph .send_response_only (200 , "bharatavarshe" )
173184 ph .send_header ('Access-Control-Allow-Origin' , '*' )
0 commit comments