Skip to content

Provide CSV file with names and passwords #2

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

Merged
merged 8 commits into from
Dec 31, 2017
Merged

Provide CSV file with names and passwords #2

merged 8 commits into from
Dec 31, 2017

Conversation

rschroll
Copy link
Member

@tianhuil, I don't know if you want to do code reviews here or not. If you don't feel like it, I'll just merge it in now and have Zach and Chris look over this code carefully when I start to bring them up to speed on JH.

The main thrust of this code is to provide a JupyterHub service that reports (to admin users only) a CSV file full of names and passwords. This will make getting set up for day 1 easier -- the teacher doesn't have to know the secret_key or even have downloaded this package. They can just go to /services/hashauth/ and get everything they need.

Around that, there's a fair amount of cleanup I ended up doing, mainly related to getting the install working and improving the command line script. I don't think those things particularly need review.

Copy link

@tianhuil tianhuil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, a few small comments but mostly just a small bit about using argparse. Please merge once you fix.

import requests
from traitlets.config import PyFileConfigLoader

from tornado.ioloop import IOLoop

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope this is listed in the dependencies somewhere?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not explicitly, for two reasons:

  1. Tornado is a dependency of JupyterHub, so if you've got JH installed, you'll be okay here.
  2. I feel like this service is a little bonus, but the meat of this project is the authenticator itself. If you just want to use the authenticator, you shouldn't have to install the things to make the service work. I don't know how to represent this in the setup.py file, so I haven't put anything additional there.

get_password = generate_password_function()


class HashAuthHandler(HubOAuthenticated, RequestHandler):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth using flask instead? I'm thinking about keeping our development compatible with our main website. Don't know if it's worth rewriting this though ...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you look back in the git history, you'll see I started with a Flask version. I think tornado is right for this particular project, though. Since we've released this as an open-source project, we should make it as easy to install as possible. If they have JupyterHub, they have Tornado, so we might as well just use that. JupyterHub provides some authentication helpers for tornado, so this code is actually more compact than the Flask version.

Also, I don't see this expanding past a single endpoint. The grader, on the other hand, I've done in Flask and I see no reason to move it to tornado.


if __name__ == '__main__':
if len(sys.argv) not in [3,4]:
print('Usage: hashauthenticator secret_key user [len]')
if len(sys.argv) not in [2,3,4]:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use argparse which makes this much more clear.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I know.

Signature changed slightly: now the length is indicated with a flag.
@rschroll rschroll merged commit f78bd81 into master Dec 31, 2017
@rschroll rschroll deleted the service branch December 31, 2017 07:18
README.md Outdated
@@ -30,7 +30,7 @@ This package comes with a command called `hashauthpw`. Example usage:

```bash
$ hashauthpw
Usage: hashauthenticator user [secret_key [len]]
usage: hashauthpw [-h] [--length LENGTH] username [secret_key]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also just say hashauthpw -h for more as this future proofs against future changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants