Skip to main content

Social Auth backend for GSIS

Project description

Social Auth GSIS

Python Social Auth backend for the OAuth 2.0 for GSIS, intended for use in Django applications.

Requirements

  • Python 3.8, or newer
  • Django 3.2, or newer

Installation

Install the social-auth-gsis from PyPI using your favorite package manager.

pip

pipi install social-auth-gsis

Poetry

poetry add social-auth-gsis

Usage

To get the GSIS authentication package working with a Django application, both settings and URLs need to be configured.

Settings

The best place to get started with integrating Social Auth GSIS in a Django project is the settings.

First, the social_django app needs to be added in the INSTALLED_APPS setting of your Django application:

INSTALLED_APPS = [
    # ...the rest of installed apps
    "social_django",
]

Next, social_django.middleware.SocialAuthExceptionMiddleware needs to be included in MIDDELWARE, right below the django.middleware.clickjacking.XFrameOptionsMiddleware:

MIDDLEWARE = [
    # ...the rest of middleware
    "django.middleware.clickjacking.XFrameOptionsMiddleware",
    "social_django.middleware.SocialAuthExceptionMiddleware",
]

In order to only allow creation of users through the social auth pipeline, the SOCIAL_AUTH_PIPELINE Django Social Auth setting needs to be set to the following value:

SOCIAL_AUTH_PIPELINE = (
    "social_core.pipeline.social_auth.social_details",
    "social_core.pipeline.social_auth.social_uid",
    "social_core.pipeline.social_auth.auth_allowed",
    "social_auth_gsis.pipeline.social_auth.social_user",
    "social_core.pipeline.social_auth.associate_user",
    "social_core.pipeline.social_auth.load_extra_data",
    "social_core.pipeline.user.user_details",
)

To configure the credentials and redirect URLs of a Social Auth GSIS backend the appropriate settings need to be set as well:

SOCIAL_AUTH_GSIS_KEY = "oauth2_client_key"
SOCIAL_AUTH_GSIS_SECRET = "oauth2_client_secret"
SOCIAL_AUTH_GSIS_REDIRECT_URL = "https://yourapp.local/authorize/gsis/"

Finally, the intended backends should be included in the AUTHENTICATION_BACKENDS setting:

AUTHENTICATION_BACKENDS = (
    "social_auth_gsis.backends.GSISOAuth2",
    # ...the rest of backends included
)

URLs

The URLs of Django Social Auth are required to be included also, in order to authenticate users redirected from GSIS' auth:

from django.urls import include, path
from social_django import views as social_django_views


urlpatterns = [
    path("auth/", include("social_django.urls", namespace="social")),
    # ...the rest of URL patterns
]

The ability to explicitly set the backend to be used in a URL for authentication, is also possible:

urlpatterns = [
    path(
        "authorize/gsis/",
         social_django_views.complete,
        kwargs={"backend": "ktimatologio_gsis"},
        name="authorize",
    ),
    # ...the rest of URL patterns
]

Backends

The following social auth backends are available in social_auth_gsis.backends.

GSISOAuth2

Used for authentication of citizens. For testing purposes the GSISOAuth2Testing backend should be used instead. The following settings are required:

  • SOCIAL_AUTH_GSIS_KEY
  • SOCIAL_AUTH_GSIS_SECRET
  • SOCIAL_AUTH_GSIS_REDIRECT_URL

GSISOTPOAuth2

Used for authentication of citizens, requiring also OTP verification. For testing purposes the GSISOTPOAuth2Testing backend should be used instead. The following settings are required:

  • SOCIAL_AUTH_GSIS_OTP_KEY
  • SOCIAL_AUTH_GSIS_OTP_SECRET
  • SOCIAL_AUTH_GSIS_OTP_REDIRECT_URL

GSISPAOAuth2

Used for authentication of public sector employees (PA for Public Administration). For testing purposes the GSISPAOAuth2Testing backend should be used instead. The following settings are required:

  • SOCIAL_AUTH_GSIS_PA_KEY
  • SOCIAL_AUTH_GSIS_PA_SECRET
  • SOCIAL_AUTH_GSIS_PA_REDIRECT_URL

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

social_auth_gsis-0.5.6.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

social_auth_gsis-0.5.6-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file social_auth_gsis-0.5.6.tar.gz.

File metadata

  • Download URL: social_auth_gsis-0.5.6.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.3 Darwin/23.4.0

File hashes

Hashes for social_auth_gsis-0.5.6.tar.gz
Algorithm Hash digest
SHA256 8ae216dd68b7c5d4bdcdc9a5091adf5e1f61a397e6335570c42bb8a71af67fc2
MD5 22ffdb68d2b0d608ffc3d861e1a0e711
BLAKE2b-256 f6cfef9f6a4c585055bff3579025282c4750a519307930bc343a3c2dd6fc3a99

See more details on using hashes here.

File details

Details for the file social_auth_gsis-0.5.6-py3-none-any.whl.

File metadata

File hashes

Hashes for social_auth_gsis-0.5.6-py3-none-any.whl
Algorithm Hash digest
SHA256 acf1444f9c8dbff16fc7f37a4b7cb067cb3a4c323258d5ccaba2ec38440e988b
MD5 ab95882496a5ef7a69b86b0c5947adf3
BLAKE2b-256 a98d15a2fc783a4f733540c0229debd54690257a51d35b8c1f42a9c94b435c94

See more details on using hashes here.

Supported by

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