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
...
]
- Não esqueça das demais configurações do
allauthemAUTHENTICATION_BACKENDS,MIDDLEWAREeurls.py. - Gere as chaves de API do SUAP em https://suap.ifrn.edu.br/admin/api/aplicacaooauth2/ com as seguintes informações:
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 secretpois não será mostrado novamente; - Adicione ao
settings.pydo 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_nameelast_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
- O projeto Paca CMS usa esse pacote.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
871edcd0e527d6dd5f6ebbf0ef97c19f9e339dd0aa9312c0ae646b8edd2c9240
|
|
| MD5 |
2aa9aca18835540d271bc48de2c35863
|
|
| BLAKE2b-256 |
0d45a96337379deab84854f188f5dc04b4c279b825c7c0c13dee5d1c072e2fdc
|
Provenance
The following attestation bundles were made for django_allauth_suap-0.1.2.tar.gz:
Publisher:
release.yml on dvcirilo/django-allauth-suap
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_allauth_suap-0.1.2.tar.gz -
Subject digest:
871edcd0e527d6dd5f6ebbf0ef97c19f9e339dd0aa9312c0ae646b8edd2c9240 - Sigstore transparency entry: 194208719
- Sigstore integration time:
-
Permalink:
dvcirilo/django-allauth-suap@5429b6739f08353ac8623f06586786fb05834953 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/dvcirilo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5429b6739f08353ac8623f06586786fb05834953 -
Trigger Event:
push
-
Statement type:
File details
Details for the file django_allauth_suap-0.1.2-py3-none-any.whl.
File metadata
- Download URL: django_allauth_suap-0.1.2-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce0c753852e03e68a482f67b7c030822ba5bd1eaa963dad7f0ca1a65daeb4e2b
|
|
| MD5 |
6b6fa193edb5b6128db6c0720e06442d
|
|
| BLAKE2b-256 |
0ae231600bb9650b418fdbe5e133d4b0abfbee58bee86d736c14117b5bd9cc11
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_allauth_suap-0.1.2-py3-none-any.whl -
Subject digest:
ce0c753852e03e68a482f67b7c030822ba5bd1eaa963dad7f0ca1a65daeb4e2b - Sigstore transparency entry: 194208722
- Sigstore integration time:
-
Permalink:
dvcirilo/django-allauth-suap@5429b6739f08353ac8623f06586786fb05834953 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/dvcirilo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5429b6739f08353ac8623f06586786fb05834953 -
Trigger Event:
push
-
Statement type: