{ "info": { "author": "bsab", "author_email": "tino.saba@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Topic :: Internet :: WWW/HTTP", "Topic :: Software Development :: Libraries" ], "description": "![Preview](logo-django-unifi.png)\n\nDjango-Unifi-Portal is a custom portal based on two authentication/registration mechanism:\n- **_Django_** user authentication system\n- **_Facebook_** OAuth2 logging. \n\nIt is a powerful reusable Django app for interacting with the Unifi AP Controller software, version 4 and 5.\n\nThe UniFi\u00ae AP is an Access Point ideal for deployment of high-performance wireless networks. [Here](https://www.ubnt.com/unifi/unifi-ap/) you can find more details.\n\n![Preview](screen/login_reg.png)\n\nOverview\n--------\n\nDjango-Unifi-Portal works with Django 1.10/1.11.\nIt is based on this [article](https://help.ubnt.com/hc/en-us/articles/204950374-UniFi-Custom-Portal-With-Individual-Usernames-and-Passwords-) from community.\n\nHow It Works\n--------\n\nWhen an guest try to connects to a wireless network with the guest policy enabled, http requests are redirected to the django-portal server.\n \nWhen the form is submitted or the Facebook sign in has been validated, Django validates the user and then uses the Unifi API to authorize the guest\u2019s MAC address.\n\nQuick start\n-----------\n\n- Setup Django-Unifi-Portal application in Python environment:\n\n\n $ pip install django-unifi-portal\n\n\n- Migrate the django_unifi_portal app to create the user model:\n\n\n $ migrate django_unifi_portal\n\n- Add \"django_unifi_portal\" to your INSTALLED\\_APPS:\n\n ```python\n\n INSTALLED_APPS = (\n ...,\n 'django_unifi_portal',\n )\n ```\n \n- Copy this configuration and paste it on file named unifi_settings.py:\n\n ```python\n from django.core.urlresolvers import reverse_lazy\n \n UNIFI_INSTALLED_APPS = [\n # material apps\n 'material',\n 'oauth2_provider',\n 'social_django',\n 'rest_framework_social_oauth2',\n 'django_unifi_portal',\n ]\n \n UNIFI_LOGIN_URL = '/unifi-portal/login'\n UNIFI_LOGIN_REDIRECT_URL = reverse_lazy('index')\n \n UNIFI_TEMPLATE_CONTEXT_PROCESSORS = [\n 'material.frontend.context_processors.modules',\n 'social_django.context_processors.backends',\n 'social_django.context_processors.login_redirect',\n 'django_unifi_portal.context_processor.unifi_context'\n ]\n \n UNIFI_TEMPLATE_BUILTINS = 'material.templatetags.material_form'\n \n UNIFI_AUTHENTICATION_BACKENDS = (\n \n # Others auth providers (e.g. Google, OpenId, etc)\n \n # Facebook OAuth2\n 'social_core.backends.facebook.FacebookAppOAuth2',\n 'social_core.backends.facebook.FacebookOAuth2',\n \n # Django\n 'django.contrib.auth.backends.ModelBackend',\n \n )\n \n UNIFI_SOCIAL_AUTH_PIPELINE = (\n 'social_core.pipeline.social_auth.social_details',\n 'social_core.pipeline.social_auth.social_uid',\n 'social_core.pipeline.social_auth.auth_allowed',\n 'django_unifi_portal.pipeline.manage_auth_already_associated',\n 'social_core.pipeline.social_auth.social_user',\n 'social_core.pipeline.user.get_username',\n 'django_unifi_portal.pipeline.require_email',\n 'social_core.pipeline.mail.mail_validation',\n 'social_core.pipeline.user.create_user',\n 'social_core.pipeline.social_auth.associate_user',\n 'social_core.pipeline.debug.debug',\n 'social_core.pipeline.social_auth.load_extra_data',\n 'social_core.pipeline.user.user_details',\n 'django_unifi_portal.pipeline.user_details',\n 'django_unifi_portal.pipeline.save_profile',\n 'social_core.pipeline.debug.debug',\n )\n \n # Define SOCIAL_AUTH_FACEBOOK_SCOPE to get extra permissions from facebook.\n # Email is not sent by default, to get it, you must request the email permission:\n SOCIAL_AUTH_FACEBOOK_SCOPE = ['email']\n SOCIAL_AUTH_FACEBOOK_PROFILE_EXTRA_PARAMS = {\n 'fields': 'id, name, about, email, birthday, gender, hometown, languages'\n }\n \n UNIFI_SERVER = \"\n UNIFI_PORT = # default is 8443\n UNIFI_VERSION = 'v4'\n UNIFI_SITE_ID = 'default'\n \n # It's important to note that if this server is offsite, you need to have port 8443 forwarded through to it\n UNIFI_SSID = ''\n UNIFI_LOGO = ''\n \n UNIFI_USER = \"\"\n UNIFI_PASSWORD = \"\"\n UNIFI_TIMEOUT_MINUTES = # ex. 8 hours is 480\n \n # Facebook configuration\n SOCIAL_AUTH_FACEBOOK_KEY = \"\"\n SOCIAL_AUTH_FACEBOOK_SECRET = \"\"\n ```\n\n- Then add this configuration to your settings.py:\n ```python\n #################################################\n # UNIFI CONFIGURATION #\n #################################################\n from unifi_settings import *\n \n INSTALLED_APPS += UNIFI_INSTALLED_APPS\n \n LOGIN_URL = UNIFI_LOGIN_URL\n LOGIN_REDIRECT_URL = UNIFI_LOGIN_REDIRECT_URL\n \n TEMPLATES[0]['OPTIONS']['context_processors'] += UNIFI_TEMPLATE_CONTEXT_PROCESSORS\n \n # shortcut for in form templates\n try:\n # shortcut for in form templates\n from django.template.base import add_to_builtins\n add_to_builtins(UNIFI_TEMPLATE_BUILTINS)\n except ImportError:\n \"\"\"\n Django 1.9.\n \"\"\"\n TEMPLATES[0]['OPTIONS']['builtins'] = [\n UNIFI_TEMPLATE_BUILTINS,\n ]\n \n AUTHENTICATION_BACKENDS = UNIFI_AUTHENTICATION_BACKENDS\n SOCIAL_AUTH_PIPELINE = UNIFI_SOCIAL_AUTH_PIPELINE\n ```\n \n- You need to map the views to an url in url.py file:\n\n ```python\n url(r'', include('django_unifi_portal.urls')),\n ```\n\n\n- If you want you can use the base UnifiUser model or extend it defining a simple model like this :\n\n ```python\n from unifi_portal.models import UnifiUser\n class CustomUnifiUser(UnifiUser):\n nick = models.CharField(max_length=100)\n\nUnifi Server Configuration\n--------\n\nLast, setup UniFi to point to the IP of the django portal al server. You can test authentication by inserting a dummy account in to the database.\n\n![Config](screen/unifi-dash.png)\n\nIt's important to note that you cannot include folders in your External Portal option, just an IP address. You can either modify the default Apache2 index.html file to redirect to the appropriate path, or create a symlink to the guest/s/default/index.php file.\n\n## Contributing\n\nContributions welcome; Please submit all pull requests against the master branch. If your pull request contains Python patches or features, you should include relevant unit tests.\nThanks!\n\n## Author\n\n[Sabatino Severino](https://about.me/the_sab), @bsab\n\n## License\n\nDjango-Unifi-Portal is available under the MIT license. See the LICENSE file for more info.\n\n## Disclaimer\nUbiquiti will not support this code. It is provided simply as an example of a rudimentary, functioning external portal.\n\n##PLEASE NOTE: This package is still in development so please use with caution.", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/bsab/django-unifi-portal", "keywords": "", "license": "MIT License", "maintainer": "", "maintainer_email": "", "name": "django-unifi-portal", "package_url": "https://pypi.org/project/django-unifi-portal/", "platform": "", "project_url": "https://pypi.org/project/django-unifi-portal/", "project_urls": { "Homepage": "https://github.com/bsab/django-unifi-portal" }, "release_url": "https://pypi.org/project/django-unifi-portal/0.0.2/", "requires_dist": null, "requires_python": "", "summary": "Authenticate Unifi WiFi Guests with Django.", "version": "0.0.2" }, "last_serial": 2961855, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "1f5b76e02fd6109c0f29846a3a03eb29", "sha256": "76aab4e8931dc0a51769660c7b9b5580f37ffb928e2b9040e834044b96a0b4a6" }, "downloads": -1, "filename": "django-unifi-portal-0.0.1.zip", "has_sig": false, "md5_digest": "1f5b76e02fd6109c0f29846a3a03eb29", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 585048, "upload_time": "2017-06-16T13:23:11", "url": "https://files.pythonhosted.org/packages/6c/fe/1f9ba1f9ac98892d4b63dd0b4ee0661691e74d1e1630fbff2186f9ab2bdc/django-unifi-portal-0.0.1.zip" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "433b934e34e43bfab315ee7b49d67342", "sha256": "741fccfd75d9818df97bc379c45cc78fb05d5344aad1674cb33e7ed4950ff73d" }, "downloads": -1, "filename": "django-unifi-portal-0.0.2.zip", "has_sig": false, "md5_digest": "433b934e34e43bfab315ee7b49d67342", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 593358, "upload_time": "2017-06-20T10:27:38", "url": "https://files.pythonhosted.org/packages/7b/e7/ab58be6dd056d3fbba679522ed5980c6458982467dce15b1c2ff8a01582c/django-unifi-portal-0.0.2.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "433b934e34e43bfab315ee7b49d67342", "sha256": "741fccfd75d9818df97bc379c45cc78fb05d5344aad1674cb33e7ed4950ff73d" }, "downloads": -1, "filename": "django-unifi-portal-0.0.2.zip", "has_sig": false, "md5_digest": "433b934e34e43bfab315ee7b49d67342", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 593358, "upload_time": "2017-06-20T10:27:38", "url": "https://files.pythonhosted.org/packages/7b/e7/ab58be6dd056d3fbba679522ed5980c6458982467dce15b1c2ff8a01582c/django-unifi-portal-0.0.2.zip" } ] }