Code Monkey home page Code Monkey logo

opendashauth's Introduction

openDashAuth

Dash Multi-User Authentication

Dash does not natively support multi-user authentication (at least not for free). While looking for a solution to support my own app, I noticed many developers online needed the ability to support dedicated viewpoints for individual users, but the official forums provided little to no help.

As far as I'm aware, this is the only free and publicly available solution to support multiple users within Dash (at least that is useful in a real-world application).

How it Works

Since Dash is built on top of Flask, this application uses Flask as the primary server and serves Dash as an embedded app.

This adds more benefits on top of login functionality, as this allows for the construction of a full-fledged application in addition to the dashboard view.

Flask's login-manager is used to manage the user's session. Normally, in a Flask app, routes.py defines all of the URL-page mappings. This is also where the current-user is identified to securely serve content based on whether or not the user is logged in.

By creating a method within routes that returns the current-user, one can import and reference this user in Dash, allowing for database queries based on the individual user (while simultaneously preventing the user from getting access to other user's data).

demo gif

Getting Started

Simply perform a git pull to grab the files from this repo.

git clone https://github.com/seanmajorpayne/dash_multi_user_authentication

Open your terminal and navigate to the main application folder

$ cd /path/to/dash_multi_user_authentication
# The command on windows is 'dir' not 'cd'

Then run the application with docker

$ docker-compose build
$ docker-compose up

You can stop the application with

$ docker-compose down

The app is configured with a single user 'john' and password 'pw' which you can use to see the functionality provided by the app. You can add more users easily through the database. Note that the config file currently has a secret key that always amounts to true. This needs to be changed for a production application.

Security

While this template is offered 'as is' and I don't make any guarantees about security, there are a few helpful security features included. Flask-WTF forms have CSRF protection by default. Flask configures Jinja2 to automatically escape values unless explicitly told not to, which helps with cross site scripting issues.

For a full overview of Flask Security, check here

Contributions

Pull requests are welcome.

License

See the license details here

Acknowledgements

Thank you to Miguel Ginsberg for the Flask Mega Tutorial.

To Do

  • Add requirements.txt
  • Add License
  • Clean up Bootstrap Styling

opendashauth's People

Contributors

dazzag24 avatar dependabot[bot] avatar seanmajorpayne avatar seanppayne avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.