ines / course-starter-python

๐Ÿ‘ฉโ€๐Ÿซ๐Ÿ Starter repo for building interactive Python courses
https://course-starter-python.netlify.com
MIT License
504 stars 118 forks source link

Possibility for auth #8

Open NixBiks opened 5 years ago

NixBiks commented 5 years ago

Hi @ines

You make so awesome tools all the time. I love it! ๐Ÿ˜

I have a paying client that wants me to do a one-day course in Python for them and thought it would be very cool to use this tool. Due to data privacy the course has to be private though. Is it possible to use a private gitlab repo and add auth to the course app?

I am quite new in this app space.

ines commented 5 years ago

Thanks! ๐Ÿ˜ƒ The Electron experiments I did the other day kind of go in a similar use case direction, but it's still a bit rough.

I think the easiest way might be to use a hosting provider that offers auth out-of-the-box? Netlify has this for instance: https://www.netlify.com/docs/identity/ I haven't used it myself, but like most of their features, it looks pretty straightforward.

You'd still need to host a public Binder, but that shouldn't be a problem, right? All you need is a GitHub repo with a requirements.txt that lists the Python dependencies you need.

NixBiks commented 5 years ago

Thanks for the response.

A public Binder. Wouldn't I need to upload the data to the Binder repo as well?

One other thing: what about plotting? Is that possible somehow?

ines commented 5 years ago

If you want to use data files and load them from the root of the user directory of the Python session, then yes, they need to be in the Binder. But you don't have to do that โ€“ you could just set up the Python environment there and then use requests to load an external file from somewhere. You could also use your own Jupyter server (example here). Something just needs to serve it.

Plotting should be possible, yes. It's a regular Jupyter environment, like a notebook.

NixBiks commented 5 years ago

Ah yes I needed %matplotlib inline as the first command.

Regarding auth I was looking for a solution with a login landing page before accessing the course site. But I get confused about all the graphql, gatsby etc since I am new to all these frameworks.

It might be that Netlify Identity is the solution but I donโ€™t really see how to integrate that here. Iโ€™m sure itโ€™s due to my rookie skills though.

Alternatively I was thinking of integrating redux and using that to keep track of whether or not a person has logged in or not (if not then route to login).

ines commented 5 years ago

It might be that Netlify Identity is the solution but I donโ€™t really see how to integrate that here. Iโ€™m sure itโ€™s due to my rookie skills though.

I think you host your page on Netlify, set it up and add that identity widget: https://github.com/netlify/netlify-identity-widget

Alternatively I was thinking of integrating redux and using that to keep track of whether or not a person has logged in or not (if not then route to login).

You could do that, but then you have to build the whole user authentication stuff yourself. This really sucks and probably isn't worth it? At least, it's definitely not something I would do.

You can also just host the built app somewhere and then set up a super basic server-side auth. Like this, if you're using nginx: https://docs.nginx.com/nginx/admin-guide/security-controls/configuring-http-basic-authentication/ It's not pretty and super rudimentary, but it's easy and it works.