Name | django-allauth-vatsim JSON |
Version |
0.0.3
JSON |
| download |
home_page | None |
Summary | OAuth2 login provider for VATSIM using django-allauth. |
upload_time | 2024-06-15 17:29:51 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.10 |
license | None |
keywords |
vatsim
vatsim-oauth
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# django-allauth-vatsim
OAuth2 login provider for VATSIM using django-allauth.
## Description
Welcome to django-allauth-vatsim!
This OAuth2 provider for [django-allauth](https://github.com/pennersr/django-allauth/) enables users to log in using their account on the [VATSIM](https://vatsim.net) online ATC network.
The following components are included:
* OAuth2 provider for VATSIM (supports both production and sandbox environments).
* Social account adapter which can optionally be used to populate the user model with VATSIM-specific account details, such as a user's CID, pilot / controller rating and ATC division.
* Implementation of a basic test case to ensure that the login provider works as expected.
## Installation
To get started, install and configure django-allauth as described [here](https://docs.allauth.org/en/latest/installation/index.html).
Next, install django-allauth-vatsim into your project.
```
pip install django-allauth-vatsim
```
In your settings.py file, add it to your INSTALLED_APPS list so it looks similar to this:
```
INSTALLED_APPS = [
# Django apps
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"django.contrib.sites",
# 3rd party apps
"allauth",
"allauth.account",
"allauth.socialaccount",
"django_allauth_vatsim",
]
```
Also, add the base VATSIM OAuth2 URL:
* For the sandbox environment, use https://auth-dev.vatsim.net.
* For the production server, use https://auth.vatsim.net.
The corresponding line in your settings.py file should look like the following:
```
VATSIM_OAUTH_URL = "https://auth.vatsim.net"
```
Finally, you need to configure the credentials (client ID and secret) which you have obtained from VATSIM. As these are sensitive credentials, it is highly recommended to store them as environment variables using a package such as [environs](https://pypi.org/project/environs/).
The provider configuration should be specified as follows:
```
SOCIALACCOUNT_PROVIDERS = {
"vatsim": {
"APP": {
"client_id": "<YOUR_CLIENT_ID>",
"secret": "<YOUR_CLIENT_SECRET>",
}
},
}
```
Once all of the above is done, you can start using the new login provider, e.g. by using the following tag in your login template to initiate the authentication flow:
```
{% provider_login_url 'vatsim' %}
```
### Optional: adding the social account adapter to populate user profiles
If you like, you can utilize the included social account adapter to populate a user's profile in your database with additional details, such as their CID, VATSIM division, and controller / pilot rating information.
The adapter is configured to store this information in a Profile database model that is linked to the user model with a one-to-one relationship, which means it is also necessary to set up and configure a basic customized user model to make this work, preferably in a dedicated accounts app.
The steps required to set this up are beyond the scope of this README, but [this excellent tutorial](https://learndjango.com/tutorials/django-custom-user-model) will guide you through the process.
As an example, the CustomUser and UserProfile models that I created while working on this look as follows:
```
from django.contrib.auth.models import AbstractUser
from django.db import models
class CustomUser(AbstractUser):
pass
class UserProfile(models.Model):
user = models.OneToOneField(CustomUser, on_delete=models.CASCADE, related_name='profile')
cid = models.IntegerField(primary_key=True)
rating_id = models.IntegerField()
rating_long = models.CharField(max_length=100)
rating_short = models.CharField(max_length=50)
region_id = models.CharField(max_length=20)
region_name = models.CharField(max_length=100)
division_id = models.CharField(max_length=20, blank=True, null=True)
division_name = models.CharField(max_length=100, blank=True, null=True)
pilot_rating_id = models.IntegerField()
pilot_rating_long = models.CharField(max_length=100)
pilot_rating_short = models.CharField(max_length=50)
subdivision_id = models.CharField(max_length=20, blank=True, null=True)
subdivision_name = models.CharField(max_length=100, blank=True, null=True)
def __str__(self):
return f"{self.user.username} {self.cid}"
```
If you decide to set this up in your project, add the following line to settings.py to register the social account adapter:
```
SOCIALACCOUNT_ADAPTER = "django_allauth_vatsim.adapter.VATSIMSocialAccountAdapter"
````
## Contributing
As this is my first time publishing a Python package and also my first time developing a plugin for django-allauth, it's very much possible that I've overlooked something obvious that could make this project even more stable and / or useful.
As such, contributions, suggestions and constructive criticisms are most welcome and greatly appreciated.
If you do encounter any issues or would like to improve this package, feel free to open an issue or submit a pull request.
Raw data
{
"_id": null,
"home_page": null,
"name": "django-allauth-vatsim",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "vatsim, vatsim-oauth",
"author": null,
"author_email": "Robin Kipp <robin@robin-kipp.net>",
"download_url": "https://files.pythonhosted.org/packages/e9/a6/e140fb538528d1030c55b18688d7c7a1dba616bde4929c1c8755f1849b46/django_allauth_vatsim-0.0.3.tar.gz",
"platform": null,
"description": "# django-allauth-vatsim\nOAuth2 login provider for VATSIM using django-allauth.\n\n## Description\n\nWelcome to django-allauth-vatsim!\n\nThis OAuth2 provider for [django-allauth](https://github.com/pennersr/django-allauth/) enables users to log in using their account on the [VATSIM](https://vatsim.net) online ATC network.\nThe following components are included:\n\n* OAuth2 provider for VATSIM (supports both production and sandbox environments).\n* Social account adapter which can optionally be used to populate the user model with VATSIM-specific account details, such as a user's CID, pilot / controller rating and ATC division.\n* Implementation of a basic test case to ensure that the login provider works as expected.\n\n## Installation\nTo get started, install and configure django-allauth as described [here](https://docs.allauth.org/en/latest/installation/index.html).\nNext, install django-allauth-vatsim into your project.\n```\npip install django-allauth-vatsim\n```\nIn your settings.py file, add it to your INSTALLED_APPS list so it looks similar to this:\n```\nINSTALLED_APPS = [\n # Django apps\n \"django.contrib.admin\",\n \"django.contrib.auth\",\n \"django.contrib.contenttypes\",\n \"django.contrib.sessions\",\n \"django.contrib.messages\",\n \"django.contrib.staticfiles\",\n \"django.contrib.sites\",\n # 3rd party apps\n \"allauth\",\n \"allauth.account\",\n \"allauth.socialaccount\",\n \"django_allauth_vatsim\",\n]\n```\nAlso, add the base VATSIM OAuth2 URL:\n\n* For the sandbox environment, use https://auth-dev.vatsim.net.\n* For the production server, use https://auth.vatsim.net.\n\nThe corresponding line in your settings.py file should look like the following:\n```\nVATSIM_OAUTH_URL = \"https://auth.vatsim.net\"\n```\n\nFinally, you need to configure the credentials (client ID and secret) which you have obtained from VATSIM. As these are sensitive credentials, it is highly recommended to store them as environment variables using a package such as [environs](https://pypi.org/project/environs/).\nThe provider configuration should be specified as follows:\n```\nSOCIALACCOUNT_PROVIDERS = {\n \"vatsim\": {\n \"APP\": {\n \"client_id\": \"<YOUR_CLIENT_ID>\",\n \"secret\": \"<YOUR_CLIENT_SECRET>\",\n }\n },\n}\n```\n\nOnce all of the above is done, you can start using the new login provider, e.g. by using the following tag in your login template to initiate the authentication flow:\n```\n{% provider_login_url 'vatsim' %}\n```\n\n### Optional: adding the social account adapter to populate user profiles\nIf you like, you can utilize the included social account adapter to populate a user's profile in your database with additional details, such as their CID, VATSIM division, and controller / pilot rating information.\n\nThe adapter is configured to store this information in a Profile database model that is linked to the user model with a one-to-one relationship, which means it is also necessary to set up and configure a basic customized user model to make this work, preferably in a dedicated accounts app.\nThe steps required to set this up are beyond the scope of this README, but [this excellent tutorial](https://learndjango.com/tutorials/django-custom-user-model) will guide you through the process.\nAs an example, the CustomUser and UserProfile models that I created while working on this look as follows:\n```\nfrom django.contrib.auth.models import AbstractUser\nfrom django.db import models\n\nclass CustomUser(AbstractUser):\n pass\n\n\nclass UserProfile(models.Model):\n user = models.OneToOneField(CustomUser, on_delete=models.CASCADE, related_name='profile')\n cid = models.IntegerField(primary_key=True)\n rating_id = models.IntegerField()\n rating_long = models.CharField(max_length=100)\n rating_short = models.CharField(max_length=50)\n region_id = models.CharField(max_length=20)\n region_name = models.CharField(max_length=100)\n division_id = models.CharField(max_length=20, blank=True, null=True)\n division_name = models.CharField(max_length=100, blank=True, null=True)\n pilot_rating_id = models.IntegerField()\n pilot_rating_long = models.CharField(max_length=100)\n pilot_rating_short = models.CharField(max_length=50)\n subdivision_id = models.CharField(max_length=20, blank=True, null=True)\n subdivision_name = models.CharField(max_length=100, blank=True, null=True)\n\n def __str__(self):\n return f\"{self.user.username} {self.cid}\"\n```\n\nIf you decide to set this up in your project, add the following line to settings.py to register the social account adapter:\n```\nSOCIALACCOUNT_ADAPTER = \"django_allauth_vatsim.adapter.VATSIMSocialAccountAdapter\"\n````\n\n## Contributing\n\nAs this is my first time publishing a Python package and also my first time developing a plugin for django-allauth, it's very much possible that I've overlooked something obvious that could make this project even more stable and / or useful.\nAs such, contributions, suggestions and constructive criticisms are most welcome and greatly appreciated.\nIf you do encounter any issues or would like to improve this package, feel free to open an issue or submit a pull request.\n",
"bugtrack_url": null,
"license": null,
"summary": "OAuth2 login provider for VATSIM using django-allauth.",
"version": "0.0.3",
"project_urls": {
"Homepage": "https://github.com/robin24/django-allauth-vatsim",
"Issues": "https://github.com/robin24/django-allauth-vatsim/issues"
},
"split_keywords": [
"vatsim",
" vatsim-oauth"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "bf85a520a5352d977158c9b99edbe9b7a312157e7f9510f775386a68264cff91",
"md5": "9a3143ad01a235740b2b53dc97d76e94",
"sha256": "43eb1d5505e63dbccefffc640aec12584e4f001df338c4e594489dd9e6a572ed"
},
"downloads": -1,
"filename": "django_allauth_vatsim-0.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9a3143ad01a235740b2b53dc97d76e94",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 7117,
"upload_time": "2024-06-15T17:29:50",
"upload_time_iso_8601": "2024-06-15T17:29:50.153762Z",
"url": "https://files.pythonhosted.org/packages/bf/85/a520a5352d977158c9b99edbe9b7a312157e7f9510f775386a68264cff91/django_allauth_vatsim-0.0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e9a6e140fb538528d1030c55b18688d7c7a1dba616bde4929c1c8755f1849b46",
"md5": "da6210fc4c1791379f17266a1f7cbd50",
"sha256": "aa6075279c306ce81d8423224288adc08387998ccb514f66413f35086ac7faaa"
},
"downloads": -1,
"filename": "django_allauth_vatsim-0.0.3.tar.gz",
"has_sig": false,
"md5_digest": "da6210fc4c1791379f17266a1f7cbd50",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 7119,
"upload_time": "2024-06-15T17:29:51",
"upload_time_iso_8601": "2024-06-15T17:29:51.592101Z",
"url": "https://files.pythonhosted.org/packages/e9/a6/e140fb538528d1030c55b18688d7c7a1dba616bde4929c1c8755f1849b46/django_allauth_vatsim-0.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-15 17:29:51",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "robin24",
"github_project": "django-allauth-vatsim",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "django-allauth-vatsim"
}