gridstudio icon indicating copy to clipboard operation
gridstudio copied to clipboard

How to create new user?

Open isunix opened this issue 6 years ago • 9 comments

How to create new user to login to the web page except the 'admin' user?

isunix avatar Aug 07 '19 23:08 isunix

Currently it's not possible in an easy way. You could use a sqlite database editor on the manage.db file. But for the password hashing you need to login with the desired password, check the log and enter that in the database.

ricklamers avatar Aug 07 '19 23:08 ricklamers

But for the password hashing you need to login with the desired password, check the log and enter that in the database.

Ah, I see -- when running on Docker that is the container log, not the log files in proxy/logs/sessionLogs.

How is manage.db created / installed / populated? I'm not able to easily track it down in the code.

Depending on where it comes from, it might be fairly easy to create an optional Dockerfile config setting for overriding that user / pass when the container is created. Then people could inject their own user/pass via environment variables when they create the container, or via a docker-compose.yml file, or via docker secrets, et cetera. I could take a look at it.

For example, Jupyter docker containers let you set JUPYTER_TOKEN / JUPYTER_PASSWORD, while the mongo docker container lets you set MONGO_INITDB_ROOT_USERNAME / MONGO_INITDB_ROOT_PASSWORD.

jeremydouglass avatar Aug 09 '19 21:08 jeremydouglass

@jeremydouglass It's done in manager.go (https://github.com/ricklamers/gridstudio/blob/master/grid-app/proxy/manager.go). I think you make a good suggestion and it's something I'll look to add to Grid since the login is kind of confusing right now.

ricklamers avatar Aug 10 '19 16:08 ricklamers

Thanks so much. I couldn't find the string "admin" in the manager.go file, or quickly figure out if it was being created by boilerplate code in "database/sql" or in "github.com/mattn/go-sqlite3" -- particularly given that sqlite has no inbuilt account management, so I'm assuming (?) that is just data.

Unfortunately, I'm not at all familiar go -- however I might be able to contribute Docker container / composes / swarm configurations or entrypoint scripting if I knew what the specific interface point was.

...oh! Is it already hardcoded in the gridstudio/grid-app/proxy/db/manager.db object in the repo? So code that creates and sets up the database with users would need to be added before it could be configured....

jeremydouglass avatar Aug 10 '19 22:08 jeremydouglass

@jeremydouglass I think you've figured it out ; )

ricklamers avatar Aug 11 '19 09:08 ricklamers

Is there any plan / idea to replace sqlite with some other kind of database which supports modification by another programm during runtime? An SQL- or NOSQL-based database which is accessed through ports? I would like to run a central instance and have different student accounts. For this a fixed sqlite3 database is not the perfect (even though feasible) solution.

For that, I guess https://github.com/ricklamers/gridstudio/blob/master/grid-app/proxy/manager.go needs to be re-written in order to support different kinds of authentication plugins. Then sqlite3 could be still the default plugin but by configuration (maybe controlled by environment variables) one could decide to activate other pre-defined methods as well.

1kastner avatar Aug 13 '19 12:08 1kastner

@1kastner It's actually not too difficult to support a MySQL database. The original version of this code had support for it. Could you open a separate issue for it? I'll try adding it down the road.

ricklamers avatar Aug 14 '19 18:08 ricklamers

Of course, thanks a lot for the effort! Thanks a lot for sharing this project!

1kastner avatar Aug 14 '19 19:08 1kastner

@1kastner you're very welcome.

ricklamers avatar Aug 14 '19 19:08 ricklamers