Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround for wildcard dns issue #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions butterfly/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,12 @@ def wrap_execute(handler_execute):
# be a good place to see if you like their username and
# password.)
def require_basic_auth(handler, kwargs):
username = handler.get_query_arguments('u')[0]
password = handler.get_query_arguments('p')[0]
username = handler.get_query_argument('u')
password = handler.get_query_argument('p')
consoleId = handler.get_query_argument('c')
# auth_header = handler.request.headers.get('Authorization')
# if auth_header is None or not auth_header.startswith('Basic '):
if username is None or password is None:
if username is None or password is None or consoleId is None:
# If the browser didn't send us authorization headers,
# send back a response letting it know that we'd like
# a username and password (the "Basic" authentication
Expand All @@ -101,6 +102,7 @@ def require_basic_auth(handler, kwargs):
# auth_decoded = base64.decodestring(auth_header[6:])
# username, password = auth_decoded.split(':', 2)
kwargs['basicauth_user'], kwargs['basicauth_pass'] = username, password
kwargs.setdefault('console_id', consoleId)
return True

# Since we're going to attach this to a RequestHandler class,
Expand All @@ -119,7 +121,7 @@ def _execute(self, transforms, *args, **kwargs):
@require_basic_auth
@url(r'/(?:user/(.+))?/?(?:wd/(.+))?')
class Index(Route):
def get(self, user, path, basicauth_user, basicauth_pass):
def get(self, user, path, basicauth_user, basicauth_pass, console_id):
if not tornado.options.options.unsecure and user:
return self.redirect(tornado.options.options.redirect_404)
if tornado.options.options.password:
Expand All @@ -129,7 +131,7 @@ def get(self, user, path, basicauth_user, basicauth_pass):
return self.redirect(tornado.options.options.redirect_404)
else:
self.set_secure_cookie("user", basicauth_user)
return self.render('index.html')
return self.render('index.html', consoleId=console_id)


@url(r'/style.css')
Expand Down
6 changes: 3 additions & 3 deletions butterfly/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

<body spellcheck="false"
data-force-unicode-width="{{ 'yes' if options.force_unicode_width else 'no' }}">
<script src="{{ static_url('html-sanitizer.js') }}"></script>
<script src="{{ static_url('main.%sjs' % (
<script src="http://tty-{{consoleId}}.sensegrid.dev{{ static_url('html-sanitizer.js') }}"></script>
<script src="http://tty-{{consoleId}}.sensegrid.dev{{ static_url('main.%sjs' % (
'' if options.unminified else 'min.')) }}"></script>
<script src="{{ static_url('ext.%sjs' % (
<script src="http://tty-{{consoleId}}.sensegrid.dev{{ static_url('ext.%sjs' % (
'' if options.unminified else 'min.')) }}"></script>
</body>
</html>