Coder Social home page Coder Social logo

bsab / django-unifi-portal Goto Github PK

View Code? Open in Web Editor NEW
79.0 12.0 28.0 1008 KB

Authenticate Unifi WiFi Guests with Django

License: MIT License

Python 81.20% HTML 18.80%
django python unifi unifi-controller captive-portal captiveportal wifi-network wifimanager facebook-login authentication

django-unifi-portal's People

Contributors

bsab avatar dependabot[bot] avatar jameslodge avatar kodexarg avatar tomaszkolek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-unifi-portal's Issues

Migrate Command & Directories

Good Morning Everyone,
Excuse my lack of knowledge here, but I can't seem to put together the step between installing the unifi-portal & the migrate command. I have already installed the unifi-portal using pip; just wondering if the "migrate" command supposed to just work right after? Or do I have to setup the environment variables for django before I can issue that command? Also reading further, there's mention of settings.py file, what directory does that go in? I'm just asking in advance. Finally, is this something I can run on an apache server with virtual hosts or should I just use a dedicated machine? Thank you for your time guys.

No module named "unifi_settings"

Hi,

When I tried, on ubuntu :
$ pip install django-unifi-portal
$ pip install git+https://github.com/bsab/django-unifi-portal.git
cd django-unifi-portal/demo
$ python3 manage.py migrate django_unifi_portal

It prints
ModuleNotFoundError : No module named unifi_settings

Any idea ?

Session State - Cookie Expiry

Setting UNIFI_TIMEOUT_MINUTES doesn't seem to have an effect on the session cookie expiry.

For example, I set UNIFI_TIMEOUT_MINUTES = 60 the unifi controller expiry is correct, yet the session cookie expiry is 14 days in the future.

Redirect & Login Error

Good Morning Everyone, I've been making what I think is good progress on this project, with a few bumps along the way I need some assistance ironing out.
The registration part of the portal works correctly, I can register a user, the portal adds it to the database, but then when its time to navigate, it doesn't let me. I noticed that on the UniFi Controller it shows the device trying to connect, but it says its unauthorized; at one point I just manually authorized the test device, then it was able to browse the web.
As for the login error; as I mentioned before, the registration part works. It writes to the database and the user is added. However when the user goes back and tries to login I get this error from the apache error log:

response = view_func(request, *args, **kwargs)
File "/usr/lib64/python2.7/site-packages/django/utils/decorators.py", line 63, in bound_func
return func.get(self, type(self))(*args2, **kwargs2)
"/var/www/html/vHost2/jMtest/Wifi_Portal/views.py", line 123, in dispatch
return super(UnifiUserLogin, self).dispatch(request, *args, **kwargs)
"/usr/lib64/python2.7/site-packages/django/views/generic/base.py", line 88, in dispatch
return handler(request, *args, **kwargs)
File "/usr/lib64/python2.7/site-packages/django/views/generic/edit.py", line 183, in post
return self.form_valid(form)
File "/var/www/html/vHost2/jMtest/Wifi_Portal/views.py", line 133, in form_valid
return super(UnifiUserLogin, self).form_valid(form)
File "/usr/lib64/python2.7/site-packages/django/views/generic/edit.py", line 79, in form_valid
return HttpResponseRedirect(self.get_success_url())
File "/var/www/html/vHost2/jMtest/Wifi_Portal/views.py", line 136, in get_success_url
redirect_to = self.request.REQUEST.get(self.redirect_field_name)
AttributeError: 'WSGIRequest' object has no attribute 'REQUEST'

I tried to keep that as short as possible, but made the part of interest bold here.

Here's a screenshot from the UniFi Controller

screen shot 2018-02-05 at 9 11 15 am

I'm going to ssh into the access-point and see what's happening on that that side, I'll post logs if I find anything of interest. Thanks in advance I hope someone can assist me with this issue.

Canceling Facebook Login Handling

Need to handle when a user cancels the Facebook login.

Right now, and exception is thrown

Request Method: GET
http:///auth/complete/facebook/?error=access_denied&error_code=200&error_description=Permissions%20error&error_reason=user_denied&state=1mFmJIddk8Tmgpq8ZBgR2revYO32Shzr
1.11.7
AuthCanceled
Authentication process canceled: Permissions error
/usr/local/apps/virtenv/unifi_portal/lib/python2.7/site-packages/social_core/backends/oauth.py in process_error, line 378
/usr/local/apps/virtenv/unifi_portal/bin/python
2.7.14
['/usr/local/apps/virtenv/unifi', '/usr/local/apps/virtenv/unifi_portal/lib/python27.zip', '/usr/local/apps/virtenv/unifi_portal/lib/python2.7', '/usr/local/apps/virtenv/unifi_portal/lib/python2.7/plat-freebsd11', '/usr/local/apps/virtenv/unifi_portal/lib/python2.7/lib-tk', '/usr/local/apps/virtenv/unifi_portal/lib/python2.7/lib-old', '/usr/local/apps/virtenv/unifi_portal/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7', '/usr/local/lib/python2.7/plat-freebsd11', '/usr/local/lib/python2.7/lib-tk', '/usr/local/apps/virtenv/unifi_portal/lib/python2.7/site-packages']
Thu, 25 Jan 2018 16:44:24 +0000

Quick Start guide errors

Hey,

I'm trying to install this using you Quick Start guide but seem to be having some issues in the setup.

I'm running in a virtual environment and I'm able to run the pip install django_unifi_portal command successfully however I'm having some issues with the migrate command..

I am met with the following:

(env) root@ubuntu:~/unifi# pip install django-unifi-portal
Collecting django-unifi-portal
  Using cached django-unifi-portal-0.0.2.zip
Requirement already satisfied: django>=1.10 in ./env/lib/python2.7/site-packages (from django-unifi-portal)
... (output suppressed)
Successfully installed Pillow-4.2.1 PyJWT-1.5.3 certifi-2017.7.27.1 chardet-3.0.4 django-braces-1.11.0 django-material-1.0.0 django-oauth-toolkit-1.0.0 django-rest-framework-social-oauth2-1.0.8 django-unifi-portal-0.0.2 djangorestframework-3.6.4 idna-2.6 oauthlib-2.0.4 olefile-0.44 python-openid-2.2.5 requests-2.18.4 requests-oauthlib-0.8.0 requests-toolbelt-0.8.0 six-1.11.0 social-auth-app-django-1.2.0 social-auth-core-1.4.0 urllib3-1.22
(env) root@ubuntu:~/unifi# 
(env) root@ubuntu:~/unifi# migrate django_unifi_portal
Usage: migrate COMMAND ...`

Available commands:
    compare_model_to_db          - compare MetaData against the current database state
    create                       - create an empty repository at the specified path
    create_model                 - dump the current database as a Python model to stdout
    db_version                   - show the current version of the repository under version control
    downgrade                    - downgrade a database to an earlier version
    drop_version_control         - removes version control from a database
    help                         - displays help on a given command
    make_update_script_for_model - create a script changing the old MetaData to the new (current) MetaData
    manage                       - creates a Python script that runs Migrate with a set of default values
    script                       - create an empty change Python script
    script_sql                   - create empty change SQL scripts for given database
    source                       - display the Python code for a particular version in this repository
    test                         - performs the upgrade and downgrade command on the given database
    update_db_from_model         - modify the database to match the structure of the current MetaData
    upgrade                      - upgrade a database to a later version
    version                      - display the latest version available in a repository
    version_control              - mark a database as under this repository's version control

Enter "migrate help COMMAND" for information on a particular command.


migrate: error: Invalid command django_unifi_portal

Django version:

(env) root@ubuntu:~/unifi# python -c "import django; print(django.get_version())"
1.11.5

Am I missing something?

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.