Permalink
Browse files

DOH: Added the logging and ssh plugin templates to the git repo. NO W…

…ONDER people were saying some things just don't look right. LOL!

auth.py:  Fixed all the authentication redirects so they works with the new url_prefix option.
gateone.py:  Fixed the login_url (Tornado setting) so it now uses the url_prefix option.
gateone.py:  Fixed the HTTPSRedirectHandler so it also takes the url_prefix into account.  I also changed its URL pattern regex to be ".*" (meaning, 'match anything') from just "/" (meaning, 'match *just* http://whatever/').  That way a user can hit your Gate One server's hostname/IP via HTTP in a browser with *any* URL and get magically redirected to HTTPS on the proper port.
gateone.py:  Removed that leftover print statement from the new ErrorHandler.
SSH Plugin:  Added support for telnet:// URLs to ssh_connect.py.  This should resolve #87
Bookmarks Plugin:  Added support for telnet:// URLs as well.
Bookmarks Plugin:  Added a new type of tag that gets automatically added to bookmarks:  URL type.  Essentially this will let you filter the bookmarks list based on the type of URL in the bookmark.  This was necessary in order to be able to easily differentiate between ssh:// and telnet:// URLs.
Bookmarks Plugin:  Added a new "Autotags" section to the tag cloud area where you can filter based on URL type (protocol) and the age of bookmarks (e.g. "<7 Days").
setup.py:  Made a minor change to ensure that when it is run that the combined_plugins.js gets automatically overwritten.
Playback Plugin:  Changed playback.js a bit in an attempt to save some memory but I believe what I'm experiencing is a bug in Chrome...  Everything stays nice and low (in terms of memory utilization) and then suddenly jumps a huge amount after switching tabs and then back again.  It needs more investigation.
Logging Plugin:  Added the ability to download logs in the self-contained recording format.
NOTE:  Something strange is going on with log titles and the new telnet protocol support in ssh_connect.py.  It'll be fixed soon.
  • Loading branch information...
liftoff committed Feb 9, 2012
1 parent f45b351 commit 81ae0e71f78d9d864a7d5c260b6c430d895bb32d
View
@@ -96,7 +96,7 @@ def user_login(self, user):
logging.info(_("Creating user directory: %s" % user_dir))
mkdir_p(user_dir)
os.chmod(user_dir, 0700)
- session_file = user_dir + '/session'
+ session_file = os.path.join(user_dir, 'session')
if os.path.exists(session_file):
session_data = open(session_file).read()
session_info = tornado.escape.json_decode(session_data)
@@ -117,11 +117,12 @@ def user_logout(self, user, redirect=None):
information and optionally, redirects them to *redirect* (URL).
"""
logging.debug("user_logout(%s)" % user)
+ url_prefix = self.settings['url_prefix']
if redirect:
self.write(redirect)
self.finish()
else:
- self.write("/")
+ self.write(url_prefix)
self.finish()
class NullAuthHandler(BaseAuthHandler):
@@ -162,7 +163,7 @@ def get(self):
if next_url:
self.redirect(next_url)
else:
- self.redirect("/")
+ self.redirect(self.settings['url_prefix'])
class GoogleAuthHandler(BaseAuthHandler, tornado.auth.GoogleMixin):
"""
@@ -220,7 +221,7 @@ def _on_auth(self, user):
if next_url:
self.redirect(next_url)
else:
- self.redirect("/")
+ self.redirect(self.settings['url_prefix'])
# Add our KerberosAuthHandler if sso is available
KerberosAuthHandler = None
@@ -270,7 +271,7 @@ def _on_auth(self, user):
if next_url:
self.redirect(next_url)
else:
- self.redirect("/")
+ self.redirect(self.settings['url_prefix'])
except ImportError:
pass # No SSO available.
@@ -321,6 +322,6 @@ def _on_auth(self, user):
if next_url:
self.redirect(next_url)
else:
- self.redirect("/")
+ self.redirect(self.settings['url_prefix'])
except ImportError:
pass # No PAM auth available.
View
@@ -611,7 +611,10 @@ class HTTPSRedirectHandler(tornado.web.RequestHandler):
def get(self):
"""Just redirects the client from HTTP to HTTPS"""
port = self.settings['port']
- self.redirect('https://%s:%s/' % self.request.headers['Host'], port)
+ url_prefix = self.settings['url_prefix']
+ self.redirect(
+ 'https://%s:%s%s' % (
+ self.request.headers['Host'], port, url_prefix))
class BaseHandler(tornado.web.RequestHandler):
"""
@@ -1115,13 +1118,14 @@ def authenticate(self, settings):
for css_template in plugins['css']:
self.write_message(json_encode({'load_css': css_template}))
- def new_multiplex(self, cmd, term_id):
+ def new_multiplex(self, cmd, term_id, logging=True):
"""
Returns a new instance of :py:class:`termio.Multiplex` with the proper global and
client-specific settings.
* *cmd* - The command to execute inside of Multiplex.
* *term_id* - The terminal to associate with this Multiplex or a descriptive identifier (it's only used for logging purposes).
+ * *logging* - If False, logging will be disabled for this instance of Multiplex (even if it would otherwise be enabled).
"""
user_dir = self.settings['user_dir']
try:
@@ -1132,21 +1136,24 @@ def new_multiplex(self, cmd, term_id):
session_dir = self.settings['session_dir']
session_dir = os.path.join(session_dir, self.session)
log_path = None
- if self.settings['session_logging']:
- log_dir = os.path.join(user_dir, user)
- log_dir = os.path.join(log_dir, 'logs')
- # Create the log dir if not already present
- if not os.path.exists(log_dir):
- mkdir_p(log_dir)
- log_name = datetime.now().strftime('%Y%m%d%H%M%S%f.golog')
- log_path = os.path.join(log_dir, log_name)
+ syslog_logging = False
+ if logging:
+ syslog_logging = self.settings['syslog_session_logging']
+ if self.settings['session_logging']:
+ log_dir = os.path.join(user_dir, user)
+ log_dir = os.path.join(log_dir, 'logs')
+ # Create the log dir if not already present
+ if not os.path.exists(log_dir):
+ mkdir_p(log_dir)
+ log_name = datetime.now().strftime('%Y%m%d%H%M%S%f.golog')
+ log_path = os.path.join(log_dir, log_name)
facility = string_to_syslog_facility(self.settings['syslog_facility'])
return termio.Multiplex(
cmd,
log_path=log_path,
user=user,
term_id=term_id,
- syslog=self.settings['syslog_session_logging'],
+ syslog=syslog_logging,
syslog_facility=facility,
syslog_host=self.settings['syslog_host']
)
@@ -1683,7 +1690,6 @@ def get_error_html(self, status_code, **kwargs):
self.require_setting("static_path")
if status_code in [404, 500, 503, 403]:
filename = os.path.join(self.settings['static_path'], '%d.html' % status_code)
- print("filename: %s" % filename)
if os.path.exists(filename):
f = open(filename, 'r')
data = f.read()
@@ -1715,7 +1721,7 @@ def __init__(self, settings):
static_path=os.path.join(GATEONE_DIR, "static"),
static_url_prefix="%sstatic/" % settings['url_prefix'],
gzip=True,
- login_url="/auth"
+ login_url="%sauth" % settings['url_prefix']
)
# Make sure all the provided settings wind up in self.settings
for k, v in settings.items():
@@ -1740,7 +1746,7 @@ def __init__(self, settings):
docs_path = os.path.join(GATEONE_DIR, 'docs')
docs_path = os.path.join(docs_path, 'build')
docs_path = os.path.join(docs_path, 'html')
- url_prefix = tornado_settings['url_prefix']
+ url_prefix = settings['url_prefix']
# Setup our URL handlers
handlers = [
(r"%s" % url_prefix, MainHandler),
@@ -2225,7 +2231,11 @@ def main():
ssl_options = None
https_server = tornado.httpserver.HTTPServer(
Application(settings=app_settings), ssl_options=ssl_options)
- https_redirect = tornado.web.Application([(r"/", HTTPSRedirectHandler),])
+ https_redirect = tornado.web.Application(
+ [(r".*", HTTPSRedirectHandler),],
+ port=options.port,
+ url_prefix=options.url_prefix
+ )
tornado.web.ErrorHandler = ErrorHandler
try: # Start your engines!
if options.address:
Oops, something went wrong.

0 comments on commit 81ae0e7

Please sign in to comment.