Skip to main content

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

Metadata

Release files for social-auth-gsis 0.5.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for social-auth-gsis 0.5.8
File Size Uploaded Provenance Actions
social_auth_gsis-0.5.8.tar.gz 3.8 kB Without provenance Details for social_auth_gsis-0.5.8.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for social-auth-gsis 0.5.8
File Interpreter ABI Platform Actions
social_auth_gsis-0.5.8-py3-none-any.whl Python 3 none any Details for social_auth_gsis-0.5.8-py3-none-any.whl

Total release size: 8.2 kB

Release files / social_auth_gsis-0.5.8.tar.gz

Download URL social_auth_gsis-0.5.8.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f1a45976e222ca5353acd9a8f01055dff1cd9c0f58e80e3f87cd0ca40b17bb06
BLAKE2b-256 checksum
How to use checksums
54e92dfcfd8a446736152ed8556fd2c86b6129fe6afef5e0504a658102d114ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.3 Darwin/23.4.0

Release files / social_auth_gsis-0.5.8-py3-none-any.whl

Download URL social_auth_gsis-0.5.8-py3-none-any.whl
Size 4.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
de62d2fa63a460ed26f14009be3e4244ff88bdda9a30847e509339cfb173eb40
BLAKE2b-256 checksum
How to use checksums
00fb175514fac925ee766f06a7efab978b8adf951030ba40088d02100ac700f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.3 Darwin/23.4.0

Security for social-auth-gsis 0.5.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page