Skip to content

rodorgas/django-rocketchat-auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

django-rocketchat-auth

Authenticate your Rocket.Chat users with Django web framework.

This app implements the API used by Rocket.Chat IFrame authentication. Also, it handles logout by wiring up a method on Django signals.

It was tested with Django 2.0.4 and Rocket.Chat 0.62.2. If you have any problems, please open an issue.

Quickstart

  1. Install this app in you project:

    pip install django-rocketchat-auth
    
  2. Add "rocketchat_auth" to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = (
        ...
        'rocketchat_auth',
    )
    
  3. Get an Rocket.Chat authentication token, so we can use the API.

  4. Update your settings.py:

    MONGO_DB = 'localhost:27017'
    # or more verbose (e.g. for Heroku)
    # MONGO_DB = '<dbuser>:<dbpassword>@<dbhost>:<dbport>/<dbname>?authSource=<dbname>'
    
    ROCKETCHAT_URL = 'http://localhost:3000'
    
    ROCKETCHAT_AUTH_TOKEN = '<YOUR AUTH TOKEN FROM STEP 3>'
    ROCKETCHAT_USER_ID = '<YOUR USER ID>'
    
    CORS_ORIGIN_WHITELIST = (
        'localhost:8000',
        'localhost:3000',
    )
    
  5. Include the rocketchat_auth URLconf in your project urls.py like this:

    urlpatterns += [url(r'^rocketchat/', include('rocketchat_auth.urls'))]
    
  6. Since we will put your Django app into an iframe, we have to setup some security measures that would prevent it from happening:

  • Install django-cors-headers and set your Rocket.Chat domain in CORS_ORIGIN_WHITELIST
  • Configure Django's XFrameOptionsMiddleware to exempt your login page for Rocket.Chat requests or disable it (dangerous)
  • Configure Django's CsrfViewMiddleware to exempt your login page for Rocket.Chat requests or disable it (dangerous)
  1. Now go to your Rocket.Chat admin page > Accounts > Iframe:

Roadmap

  • Enforce unique email registration in Django admin, since Rocket.Chat requires this.
  • Update Rocket.Chat user details in MongoDB when the user is modified in Django Admin.

About

Rocket.Chat authentication using Django

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published