(self, **kwargs)
| 267 | return False, '', password |
| 268 | |
| 269 | def connect(self, **kwargs): |
| 270 | if self.conn: |
| 271 | if self.conn.closed: |
| 272 | self.conn = None |
| 273 | else: |
| 274 | return True, None |
| 275 | |
| 276 | manager = self.manager |
| 277 | |
| 278 | crypt_key_present, crypt_key = get_crypt_key() |
| 279 | if not crypt_key_present: |
| 280 | raise CryptKeyMissing() |
| 281 | password, encpass, is_update_password = \ |
| 282 | self._check_user_password(kwargs) |
| 283 | |
| 284 | tunnel_password = kwargs['tunnel_password'] if 'tunnel_password' in \ |
| 285 | kwargs else '' |
| 286 | |
| 287 | # Check SSH Tunnel needs to be created |
| 288 | if manager.use_ssh_tunnel == 1 and not manager.tunnel_created: |
| 289 | status, error = manager.create_ssh_tunnel(tunnel_password) |
| 290 | if not status: |
| 291 | return False, error |
| 292 | |
| 293 | # Check SSH Tunnel is alive or not. |
| 294 | if manager.use_ssh_tunnel == 1: |
| 295 | manager.check_ssh_tunnel_alive() |
| 296 | |
| 297 | if is_update_password: |
| 298 | if encpass is None: |
| 299 | encpass = self.password or getattr(manager, 'password', None) |
| 300 | |
| 301 | self.password = encpass |
| 302 | |
| 303 | # Reset the existing connection password |
| 304 | if self.reconnecting is not False: |
| 305 | self.password = None |
| 306 | |
| 307 | if not crypt_key_present: |
| 308 | raise CryptKeyMissing() |
| 309 | |
| 310 | is_error, errmsg, password = self._decode_password( |
| 311 | encpass, manager, password, crypt_key) |
| 312 | if is_error: |
| 313 | return False, errmsg |
| 314 | |
| 315 | # If no password credential is found then connect request might come |
| 316 | # from Query tool, ViewData grid, debugger, etc. In that case, fall |
| 317 | # back to using the password returned from manager.passexec. |
| 318 | passfile = manager.get_connection_param_value('passfile') |
| 319 | if not password and not encpass and manager.passexec: |
| 320 | if not passfile: |
| 321 | password = manager.passexec.get() |
| 322 | else: |
| 323 | current_app.logger.warning( |
| 324 | 'Ignoring passexec in favor of the specified passfile ' |
| 325 | f'({passfile!r}).' |
| 326 | ) |
no test coverage detected