INSTALLED_APPS = (
...
'social_django',
)
MIDDLEWARE_CLASSES = (
...
'tethys_portal.middleware.TethysSocialAuthExceptionMiddleware',
)
AUTHENTICATION_BACKENDS = (
'tethys_services.backends.hydroshare.HydroShareOAuth2',
'social_core.backends.linkedin.LinkedinOAuth2',
'social_core.backends.google.GoogleOAuth2',
'social_core.backends.facebook.FacebookOAuth2',
'django.contrib.auth.backends.ModelBackend',
'guardian.backends.ObjectPermissionBackend',
)
TEMPLATES = [
{
...
'OPTIONS': {
'context_processors': [
...
'django.contrib.messages.context_processors.messages',
'social_django.context_processors.backends',
'social_django.context_processors.login_redirect',
...
],
...
}
}
]
# OAuth Settings
SOCIAL_AUTH_ADMIN_USER_SEARCH_FIELDS = ['username', 'first_name', 'email']
SOCIAL_AUTH_SLUGIFY_USERNAMES = True
SOCIAL_AUTH_LOGIN_REDIRECT_URL = '/apps/'
SOCIAL_AUTH_LOGIN_ERROR_URL = '/accounts/login/'
# OAuth Providers
## Google
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = ''
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = ''
## Facebook
SOCIAL_AUTH_FACEBOOK_KEY = ''
SOCIAL_AUTH_FACEBOOK_SECRET = ''
SOCIAL_AUTH_FACEBOOK_SCOPE = ['email']
## LinkedIn
SOCIAL_AUTH_LINKEDIN_OAUTH2_KEY = ''
SOCIAL_AUTH_LINKEDIN_OAUTH2_SECRET = ''
## HydroShare
SOCIAL_AUTH_HYDROSHARE_KEY = ''
SOCIAL_AUTH_HYDROSHARE_SECRET = ''
Social Authentication¶
Last Updated: September 2019
Tethys Portal supports authenticating users with Google, Facebook, LinkedIn and HydroShare via the OAuth 2.0 method. The social authentication and authorization features have been implemented using the Python Social Auth module and the social buttons provided by the Social Buttons for Bootstrap. Social login is disabled by default, because enabling it requires registering your tethys portal instance with each provider.
Enable Social Login¶
Use the following instructions to setup social login for the providers you desire.
Caution
These instructions assume that you have generated a new settings file after upgrading to Tethys Platform 1.2.0 or later. If this is not the case, please review the Social Auth Settings section.
Google¶
Create a Google Developer Account
Open
settings.py
script located in$TETHYS_SRC/tethys_portal/settings.py
References¶
For more detailed information about using Google social authentication see the following articles:
Developer Console Help
Google Identity Platform
Facebook¶
Create a Facebook Developer Account
Create a Facebook App
Setup OAuth
Expand the
Settings
menu on the left and selectBasic
. Note theApp ID
andApp Secret
.Open
settings.py
script located in$TETHYS_SRC/tethys_portal/settings.py
References¶
For more detailed information about using Facebook social authentication see the following articles:
Facebook Login
Facebook Login for the Web with the JavaScript SDK
LinkedIn¶
Create a LinkedIn Developer Account
Create a LinkedIn Application
Open the Auth tab and note the
Client ID
andClient Secret
for Step 5.Setup OAuth
Open
settings.py
script located in$TETHYS_SRC/tethys_portal/settings.py
References¶
For more detailed information about using LinkedIn social authentication see the following articles:
LinkedIn: Authenticating with OAuth 2.0
HydroShare¶
Create a HydroShare Account
Create and setup a HydroShare Application
Open
settings.py
script located in$TETHYS_SRC/tethys_portal/settings.py
Work with HydroShare in your app
(Optional) Link to a testing HydroShare instance
References¶
For more detailed information about using HydroShare social authentication see the following articles:
https://github.com/hydroshare/hydroshare/wiki/HydroShare-REST-API#oauth-20-support
Social Auth Settings¶
The following code snippet shows the settings in the
settings.py
that are relevant to social auth in Tethys Platform: