Skip to content

Commit

Permalink
Handling SSH connection error
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlia committed Apr 20, 2014
1 parent fcd0ed1 commit 03c0092
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions geofront/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
request, url_for)
from paramiko.pkey import PKey
from paramiko.rsakey import RSAKey
from paramiko.ssh_exception import SSHException
from waitress import serve
from werkzeug.contrib.cache import BaseCache, SimpleCache
from werkzeug.exceptions import BadRequest, Forbidden, HTTPException, NotFound
Expand Down Expand Up @@ -782,11 +783,21 @@ def authorize_remote(token_id: str, alias: str):
raise HTTPException(response=response)
public_keys = key_store.list_keys(identity)
master_key = master_key_store.load()
expires_at = authorize(public_keys, master_key, remote,
AUTHORIZATION_TIMEOUT)
remote_mapping = remote_dict(remote)
try:
expires_at = authorize(public_keys, master_key, remote,
AUTHORIZATION_TIMEOUT)
except SSHException as e:
response = jsonify(
error='connection-failure',
remote=remote_mapping,
message=str(e)
)
response.status_code = 500
return response
return jsonify(
success='authorized',
remote=remote_dict(remote),
remote=remote_mapping,
expires_at=expires_at.isoformat()
)

Expand Down

0 comments on commit 03c0092

Please sign in to comment.