Skip to main content

Django OAuth USP

Este pacote permite que usuários façam login utilizando a senha única USP.

Além da autenticação OAuth este pacote também possui migrations para o armazenamento dos usuários no banco de dados.

É recomendado que a estas migrations sejam rodadas antes de qualquer outra migration, devido a dificuldade de alteração do model User depois de realizada a primeira migration:

Using a custom user model when starting a project

Como usar

  1. Adicione "django_oauth_usp" em INSTALLED_APPS no arquivo settings.py

    INSTALLED_APPS = [
        ...
        'django_oauth_usp.accounts',
    ]
    
  2. Adicone o Middleware OAuthUspMiddleware

    MIDDLEWARE = [
        ...
        'django_oauth_usp.accounts.middleware.OAuthUspMiddleware',
    ]
    
  3. No arquivo settings.py, informe o Model que será utilizado para armazenar os usuários

     ```
     AUTH_USER_MODEL= 'accounts.UserModel'
     ```
    
  4. Defina os parâmetro para OAuth::

    OAUTH_CALLBACK_ID = 'callback_id_da_aplicação'
    
    AUTHLIB_OAUTH_CLIENTS = {
        'usp': {
            'client_id': 'meu_client_id',
            'client_secret': 'meu_secret_key'
        }
    }
    
    #Rota utilizada para a view accounts_authorize
    REDIRECT_URI = '/auth/authorize'
    
    #Lista com o código das unidades que poderão ter acesso.
    ALLOWED_UNIDADES = [12, 13, 14]
    
  5. Rode as migrations::

    python manage.py migrate
    
  6. Adicione rotas para as views accounts_login e accounts_authorize::

    urlpatterns = [
        path('login', accounts_login, name='login'),
        path('authorize', accounts_authorize, name='authorize'),
    ]
    

Dados do usuário

Os model UserModel provê os seguintes dados do usuário

  • Nome completo
user.get_full_name()
  • Primeiro nome()
user.get_short_name()
  • Email
user.email_user()
  • Telefone
user.get_phone()
  • É servidor
user.is_servidor()
  • Função
user.get_funcao()
  • Vínculo
user.get_vinculo()
  • Setor
user.get_setor()

Release files for django-oauth-usp 1.2.2

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

Source distribution (sdist)

Source distribution for django-oauth-usp 1.2.2
File Size Uploaded
django_oauth_usp-1.2.2.tar.gz 12.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-oauth-usp 1.2.2
File Interpreter ABI Platform
django_oauth_usp-1.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 31.9 kB

Release files / django_oauth_usp-1.2.2.tar.gz

Download URL django_oauth_usp-1.2.2.tar.gz
Size 12.4 kB
Tags Source
SHA-256 checksum
How to use checksums
00a43da41f0a4a7cc63f25764c6037d5ac597e7b817a40ae55eabac36ebb338d
BLAKE2b-256 checksum
How to use checksums
0eff759978e352124d018aeed6d0162b1654545a1f1e9641455f64ba7ecbd2ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.11.4 Linux/5.15.114-2-MANJARO

Release files / django_oauth_usp-1.2.2-py3-none-any.whl

Download URL django_oauth_usp-1.2.2-py3-none-any.whl
Size 19.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1efd2fc9a53bcf2ec9afb8b7b4ecdcaf759b312fa013be67a1051bd5dbaec68b
BLAKE2b-256 checksum
How to use checksums
abaa80ec2b52f6f0148123d2c763a1299c3f11d85871365a1fc36617d2541b41
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.11.4 Linux/5.15.114-2-MANJARO

Release history Release notifications | RSS feed

This release

1.2.2 This release

2 release files

1.2.1

2 release files

1.1.1

2 release files

1.1.0

1 release file

1.0.0

2 release files

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