Skip to main content

A Django authentication backend for GeoAxIS

Project description

A Django authentication backend for GeoAxIS OAuth.

requirements

pip install git+ssh://git@github.com:boundlessgeo/django-geoaxis.git#egg=django_geoaxis

local_settings.py (example)

import os
from django.conf import settings

def isValid(v):
    if v and len(v) > 0:
        return True
    else:
        return False

SOCIAL_AUTH_NEW_USER_REDIRECT_URL = '/'
DEFAULT_AUTH_PIPELINE = (
    'social_core.pipeline.social_auth.social_details',
    'social_core.pipeline.social_auth.social_uid',
    'social_core.pipeline.social_auth.auth_allowed',
    'social_core.pipeline.social_auth.social_user',
    'social_core.pipeline.user.get_username',
    'social_core.pipeline.mail.mail_validation',
    'social_core.pipeline.social_auth.associate_by_email',
    '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_AUTH_GEOAXIS_KEY = os.getenv('OAUTH_GEOAXIS_KEY', None)
SOCIAL_AUTH_GEOAXIS_SECRET = os.getenv('OAUTH_GEOAXIS_SECRET', None)
SOCIAL_AUTH_GEOAXIS_HOST = os.getenv('OAUTH_GEOAXIS_HOST', None)
OAUTH_GEOAXIS_USER_FIELDS = os.getenv(
    'OAUTH_GEOAXIS_USER_FIELDS', 'username, email, last_name, first_name')
SOCIAL_AUTH_GEOAXIS_USER_FIELDS = map(
    str.strip, OAUTH_GEOAXIS_USER_FIELDS.split(','))
OAUTH_GEOAXIS_SCOPES = os.getenv('OAUTH_GEOAXIS_SCOPES', 'UserProfile.me')
SOCIAL_AUTH_GEOAXIS_SCOPE = map(str.strip, OAUTH_GEOAXIS_SCOPES.split(','))
ENABLE_GEOAXIS_LOGIN = isValid(SOCIAL_AUTH_GEOAXIS_KEY)
if settings.SITEURL.startswith('https'):
    SOCIAL_AUTH_REDIRECT_IS_HTTPS = True
# GeoAxisOAuth2 will cause all login attempt to fail if
# SOCIAL_AUTH_GEOAXIS_HOST is None
if ENABLE_GEOAXIS_LOGIN:
    settings.AUTHENTICATION_BACKENDS += (
        'django_geoaxis.backends.geoaxis.GeoAxisOAuth2',
    )

login template addition

Add the following to your login template.

{% if ENABLE_GEOAXIS_LOGIN %}
     <a class="btn-geoaxis btn-social btn bg-ms btn-block" href="{% url 'social:begin' 'geoaxis' %}?{{ redirect_field_name }}={{ redirect_field_value }}">
         <i class="fa fa-lock"></i> Log In with GeoAxis
     </a>

Project details


Release history Release notifications

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
django_geoaxis-0.0.1-py3-none-any.whl (5.6 kB) Copy SHA256 hash SHA256 Wheel py3
django_geoaxis-0.0.1.tar.gz (3.8 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page