Skip to content

Commit e3c7887

Browse files
committed
Feature Update.
Added social authentication feature. Updated readme file & requirments.txt file. Automation of Social Profile creation. Update in the UI.
1 parent 3544d89 commit e3c7887

23 files changed

+417
-243
lines changed
1015 Bytes
Binary file not shown.
106 Bytes
Binary file not shown.

Base_Master/settings.py

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
# External pacakages
4444
'crispy_forms',
4545
'import_export',
46+
'social_django',
4647
'django_cleanup.apps.CleanupConfig',
4748
]
4849
IMPORT_EXPORT_USE_TRANSACTIONS = True #Mandatory for Transactions perfomred with import_export package
@@ -153,6 +154,7 @@
153154
EMAIL_HOST_USER = 'Email Id' #You should type your Email address
154155
EMAIL_HOST_PASSWORD = 'password' #You should type your Email password
155156
EMAIL_USE_TLS = True
157+
DEFAULT_FROM_EMAIL = 'noreply<[email protected]>'
156158

157159
LOGIN_REDIRECT_URL = 'home' #this Url is used to redirect Users after login
158160
LOGOUT_REDIRECT_URL = 'login' #this Url is used to redirect Users after logout
@@ -239,4 +241,38 @@
239241
"changeform_format": "horizontal_tabs",
240242
# override change forms on a per modeladmin basis
241243
"changeform_format_overrides": {"auth.user": "collapsible", "auth.group": "vertical_tabs"},
242-
}
244+
}
245+
246+
## Social Authentication Configuration
247+
AUTHENTICATION_BACKENDS = (
248+
'social_core.backends.google.GoogleOAuth2', ## Google Authentication
249+
'social_core.backends.github.GithubOAuth2', ## Github Authentication
250+
'django.contrib.auth.backends.ModelBackend', ## Normal Username & Password Authentication
251+
)
252+
253+
## Google Authentication Keys
254+
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = 'xxxxxxxxxxxxxxxxxxxxx'
255+
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = 'xxxxxxxxxxxxxxxxl'
256+
257+
## Github Authetication Keys
258+
SOCIAL_AUTH_GITHUB_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxx'
259+
SOCIAL_AUTH_GITHUB_SECRET = 'xxxxxxxxxxxxxxxxxxxxx'
260+
SOCIAL_AUTH_GITHUB_SCOPE = ['user:email','user.user','user:profile_name']
261+
262+
## Social Authentication Features.
263+
## Remove from pipeline, if you want to remove any feature.
264+
265+
## Example: If you dont want user to be created automatically, if the user is not there in database.
266+
## Remove 'social_core.pipeline.user.create_user', from the pipeline. Then it wont create users if user not exist.
267+
268+
SOCIAL_AUTH_PIPELINE = (
269+
'social_core.pipeline.social_auth.social_details',
270+
'social_core.pipeline.social_auth.social_uid',
271+
'social_core.pipeline.social_auth.social_user',
272+
'social_core.pipeline.user.get_username',
273+
'social_core.pipeline.social_auth.associate_by_email',
274+
'social_core.pipeline.user.create_user',
275+
'social_core.pipeline.social_auth.associate_user',
276+
'social_core.pipeline.social_auth.load_extra_data',
277+
'social_core.pipeline.user.user_details',
278+
)

Base_Master/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@
1414
path('update/', views.profile_update, name="update"),
1515
path('disable/<str:id>/', views.disable_user, name="disable_user"),
1616
path('theme', views.theme, name="theme"),
17+
path('social-auth/', include('social_django.urls', namespace='social')),
1718
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

README.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,32 @@ Follow these steps to make the project run locally:
6464
```sh
6565
python manage.py createsuperuser
6666
```
67-
7. Run the server locally on your system.
67+
7. Configurations on <b>settings.py</b> file
68+
69+
<b>Step 1:</b> Go to your Gmail and create an App.<br>
70+
[Click Here ](https://github.com/tamaraiselvan/Base-django-project-Setup/wiki/Email-Configuration.) to Refer the Documentation for the configuration.<br><br>
71+
<b>Step 2:</b> Go to Google could platform. Create an OAuth app.<br>
72+
[Click Here ](https://github.com/tamaraiselvan/Base-django-project-Setup/wiki/Google-Oauth-Configuration.) to Refer the Documentation for the configuration.
73+
<br><br>
74+
<b>Step 3:</b> Go to Github. Create an OAuth app.<br>
75+
[Click Here ](https://github.com/tamaraiselvan/Base-django-project-Setup/wiki/GitHub-OAuth-Configuration.) to Refer the Documentation for the configuration.
76+
77+
8. Run the server locally on your system.
6878
```sh
6979
python manage.py runserver
7080
```
71-
8. Open your browser and type.
81+
9. Open your browser and type.
7282
```sh
73-
http://127.0.0.1:8000/
83+
http://localhost:8000/
7484
```
85+
Note: Only on the localhost Social Authentication will work.
7586

87+
## Sponsor to TS Tamarai Selvan
88+
[![](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub&color=%23fe8e86)](https://github.com/sponsors/tamaraiselvan)
89+
7690
## License
7791

7892
Licensed under the MIT License.
7993
Copyright © 2022 TS Tamarai Selvan [Copy of the license](LICENSE).
94+
95+

db.sqlite3

68 KB
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)