Skip to main content

SUAP social login provider for django-allauth

Project description

Social Login Provider do SUAP para o django-allauth

Esse projeto permite a autenticação OAuth2 do SUAP para projetos Django que usem a biblioteca django-allauth.

Instalação

  • Instale e configure o Django Allauth conforme a documentação
  • Instale o pacote django-allauth-suap:
pip install django-allauth-suap

settings.py

  • Adicione ao INSTALLED_APPS:
INSTALLED_APPS = [
    ...
    # Padrão do allauth
    allauth
    allauth.account
    allauth.socialaccount

    # SUAP Provider
    allauth_suap
    ...
]
Name: Nome do App
Authorization grant type: Authorization code
# Em desenvolvimento usar o exemplo abaixo e em produção ajustar o domínio, porta e protocolo (HTTPS), mantendo o endpoint.
Redirect URIs:
http://127.0.0.1:8000/accounts/suap/login/callback/
Client type: Confidential # Já que as chaves ficam seguras no back-end.
Algorithm: No OIDC support
Ativo: check
  • Guarde o Client secret pois não será mostrado novamente;
  • Adicione ao settings.py do projeto:
SOCIALACCOUNT_PROVIDERS = {
    "suap": {
        # Talvez funcione para outras instituições apenas
        # mudando a URL, mas só foi testado no IFRN.
        "SUAP_URL": "https://suap.ifrn.br",
        # Escopo básico. Para acessar dados como CPF, adicione
        # "documentos_pessoais".
        "SCOPE": ["identificacao", "email"]
        "APP": {
            # IMPORTANTE! Use algum mecanismo para ler esses valores
            # de um .env, por exemplo.
            # Não suba suas chaves para o repositório!!
            "client_id": "seu_client_id",
            "secret": "seu_client_secret",
        },
    }
}

Uso

  • O Provider apenas recupera as informações básicas do usuário padrão Django: username (matrícula), email, first_name e last_name.
  • Caso seja necessário recuperar mais dados (ex. cpf, campus), crie um SocialAcountAdapter customizado e use os métodos disponíveis, conforme a documentação do allauth.

Exemplos

Contribuições

O projeto está aberto a contribuições, inclusive para adequações que permitam o funcionamento com outras instituições que usem o SUAP.

Referências

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

django_allauth_suap-0.1.2.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_allauth_suap-0.1.2-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file django_allauth_suap-0.1.2.tar.gz.

File metadata

  • Download URL: django_allauth_suap-0.1.2.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for django_allauth_suap-0.1.2.tar.gz
Algorithm Hash digest
SHA256 871edcd0e527d6dd5f6ebbf0ef97c19f9e339dd0aa9312c0ae646b8edd2c9240
MD5 2aa9aca18835540d271bc48de2c35863
BLAKE2b-256 0d45a96337379deab84854f188f5dc04b4c279b825c7c0c13dee5d1c072e2fdc

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_allauth_suap-0.1.2.tar.gz:

Publisher: release.yml on dvcirilo/django-allauth-suap

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_allauth_suap-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for django_allauth_suap-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ce0c753852e03e68a482f67b7c030822ba5bd1eaa963dad7f0ca1a65daeb4e2b
MD5 6b6fa193edb5b6128db6c0720e06442d
BLAKE2b-256 0ae231600bb9650b418fdbe5e133d4b0abfbee58bee86d736c14117b5bd9cc11

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_allauth_suap-0.1.2-py3-none-any.whl:

Publisher: release.yml on dvcirilo/django-allauth-suap

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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