Skip to main content

No project description provided

Project description

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()

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_oauth_usp-1.2.2.tar.gz (12.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_oauth_usp-1.2.2-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

File details

Details for the file django_oauth_usp-1.2.2.tar.gz.

File metadata

  • Download URL: django_oauth_usp-1.2.2.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Linux/5.15.114-2-MANJARO

File hashes

Hashes for django_oauth_usp-1.2.2.tar.gz
Algorithm Hash digest
SHA256 00a43da41f0a4a7cc63f25764c6037d5ac597e7b817a40ae55eabac36ebb338d
MD5 3858ad59caaed89f76d578035dbbb4f9
BLAKE2b-256 0eff759978e352124d018aeed6d0162b1654545a1f1e9641455f64ba7ecbd2ea

See more details on using hashes here.

File details

Details for the file django_oauth_usp-1.2.2-py3-none-any.whl.

File metadata

  • Download URL: django_oauth_usp-1.2.2-py3-none-any.whl
  • Upload date:
  • Size: 19.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Linux/5.15.114-2-MANJARO

File hashes

Hashes for django_oauth_usp-1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1efd2fc9a53bcf2ec9afb8b7b4ecdcaf759b312fa013be67a1051bd5dbaec68b
MD5 be1bb771759dd9437e439b60e2ad05a8
BLAKE2b-256 abaa80ec2b52f6f0148123d2c763a1299c3f11d85871365a1fc36617d2541b41

See more details on using hashes here.

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