Skip to main content

A simple way to use TU authentication in django application.

Project description

Dajgno TU Authentication
========================

Requirements
============
- python (2.7, 3.5)
- django (1.11, 2.0)
- social-app-django (2.1.0)

Installation
============
```
pip install git+https://github.com/LeOntalEs/django-tuauth.git
```

Usage
=====
### Prerequisite
Register application in api.tu.ac.th/applications
> note: Callback URL must be same with decarelation in urls.py
> in this example use http://127.0.0.1/oauth/complete/tu/

### in setting.py
```python
INSTALLED_APPS = [
...
'social_django',
'tuauth',
...
]
```
add authentication backend in setting.py
```python
AUTHENTICATION_BACKENDS = (
...
'tuauth.backend.TUOAuth2',
...
)
```
set client id and client secret in setting.py
```python
SOCIAL_AUTH_TU_KEY = '<client_id>'
SOCIAL_AUTH_TU_SECRET = '<client_secret>'
```

Sample SOCIAL_AUTH_PIPELINE
```python
SOCIAL_AUTH_PIPELINE = [
'social_core.pipeline.social_auth.social_details',
'social_core.pipeline.social_auth.social_uid',
'social_core.pipeline.social_auth.social_user',
'social_core.pipeline.user.get_username',
'social_core.pipeline.user.create_user',
'social_core.pipeline.social_auth.associate_user',
'social_core.pipeline.social_auth.load_extra_data',
'social_core.pipeline.user.user_details',
'social_core.pipeline.social_auth.associate_by_email',
]
```
> See more detail in about **social-app-django** in (https://github.com/python-social-auth/social-app-django)

### in urls.py
```
urlpatterns = [
...
path('oauth/', include('social_django.urls', namespace='social')), # in django2
...
]
```

### in template
```
...
<a href="{% url 'social:begin' 'tu' %}">Login with TU</a><br>
...
```


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-tuauth-1.0.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

django_tuauth-1.0-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file django-tuauth-1.0.tar.gz.

File metadata

  • Download URL: django-tuauth-1.0.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.5

File hashes

Hashes for django-tuauth-1.0.tar.gz
Algorithm Hash digest
SHA256 84f80f3a92becb28d30bdc79aba168c9c9c712578bd507489afc06894bdbc76c
MD5 65054d4eea723a16cc860d280eb47b9b
BLAKE2b-256 a3ecdf7d04fd1e465f0d43f761fe7d81eb87a759bcac4f2410e9b9792d3db66c

See more details on using hashes here.

File details

Details for the file django_tuauth-1.0-py3-none-any.whl.

File metadata

  • Download URL: django_tuauth-1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.5

File hashes

Hashes for django_tuauth-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d73b05ce712143708139374153cfe63ea262fb669b459139d2e86a7965e84d66
MD5 aa360a02c5c10a9ef310586718222554
BLAKE2b-256 2a13e87fbc6ec07b5e70650788eb105f6e93c1d0ad4f8e424166839dcdf7e0a8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page