Skip to main content

Django accounts management for terralego apps

Project description

Build Status codecov Maintainability

django-terra-accounts

Django accounts management for terralego apps

https://django-terra-accounts.readthedocs.io/

WARNING

  • splitted from terracommon.accounts

  • If you want to migrate data, please :

    • test in local env
      • all terracommon.accounts reference should be replaced by terra_accounts
      • all migration file which is referencing a 'accounts' migration should reference 'terra_accounts'
    • backup your instance
    • stop instance
    • update your django_content_type table
      • UPDATE django_content_type SET app_label = 'terra_accounts' WHERE app_label = 'account';
    • update your django_migrations table
      • UPDATE django_migrations SET app = 'terra_accounts' WHERE app = 'account';
    • Rename tables
      • ALTER TABLE accounts_terrauser RENAME TO terra_accounts_terrauser;
      • ALTER TABLE accounts_readmodels RENAME TO terra_accounts_readmodel;
    • Restart instances and launch migrations

Setting Up

It's recommended to follow all instruction if you don't know how this app really works, else if you set up half of this, you may experience some problems.

Django app and URLs

If you plan to use User API for authentication, registration, and other this, you should add the terra_accounts app to INSTALLED_APPS and

INSTALLED_APPS = (
  [...],
  'terra_accounts',
)

And include terra_accounts's URLs to your project urls, by adding this:

path("", include("terra_accounts.urls")),

User's model

To set up the Terra User Model, you should follow the standard django procedure, by adding this to you project settings:

AUTH_USER_MODEL = 'terra_accounts.TerraUser'

Payload handler

You should also override the default payload handler of jwt tokens, setting this:

JWT_AUTH = {
  'JWT_PAYLOAD_HANDLER' 'terra_accounts.jwt_payload.terra_payload_handler',
}

Permissions mixin

If you plan to use the permission mecanism which heritate from django Permission class you should add the permission mixin to your appconfig's.

There is an exemple of AppConfig

from django.apps import AppConfig

from terra_accounts.permissions_mixins import PermissionRegistrationMixin


class MyAppConfig(PermissionRegistrationMixin, AppConfig):
    name = 'my_app'

    permissions = (
        ('can_do_something', 'Is able to do something'),
        ('can_do_whatever', 'Is able to do whatever'),
    )

The permission mixin, overrides the ready() method to register a signal. If you plan to override this method, do not forget to add a call to super().ready()

To start a dev instance

Define settings you wants in test_geosource django project.

docker-compose up

First start should failed as the database need to be initialized. Just launch the same command twice.

Then initialize the database:

docker-compose run web /code/venv/bin/python3 /code/src/manage.py migrate

You can now edit your code. A django runserver is launched internally so the this is an autoreload server.

You can access to the api on http://localhost:8000/api/

Test

To run test suite, just launch:

docker-compose run web /code/venv/bin/python3 /code/src/manage.py test

CHANGELOG

1.0.7 (2021-05-07)

  • Fix missing migration (and check migrations in CI)

1.0.6 (2021-05-07)

  • Fix case where disabled_module is not defined in settings

1.0.5 (2021-04-22)

  • Add manager to filter permission with disabled_modules setting (#41)

1.0.4 (2021-04-13)

  • Fix bug when pushing terra_permisisions from client
  • Filter module permission

1.0.3 (2020-02-16)

  • Translate permission labels

1.0.2 (2021-01-20)

  • Permissions are not required anymore by serializer for TerraUser
  • Group permissions are set in permission_list field by serializer for reading operations and permission for writing operations

1.0.1 (2020-11-24)

  • Backport terra-settings functions

1.0.0 (2020-11-18)

  • !! WARNING : Breaking changes !!

  • Change and fix way to get user terra modules

0.5.1 (2020-11-16)

  • Endpoint to get all / user available functional permissions

0.5.0 (2020-11-03)

  • Breaking changes
    • terra-accounts settings endpoint is now removed in favor of terra-settings settings endpoint
    • Used with django-terra-settings instead of django-terra-utils
    • Please update your project requirements and code to use new terra-settings app.
    • Remove deprecated user viewset / serializer / info endpoint

0.3.13 (2020-09-08)

  • Officially support Django 3.1

0.3.12 (2020-08-25)

  • Using django.db.models.JSONField instead of django.contrib.postgres.fields
  • New DjangoModelFactory location

0.3.11 (2020-06-24)

  • Fix settings override by TERRA_APPLIANCE_SETTINGS

0.3.10 (2020-06-03)

  • Move settings endpoint from terra_utils
  • Serve language from instance defined language

0.3.9 (2020-03-20)

  • Manage reset password views

0.3.8 (2019-12-13)

  • Update documentation
  • Support Django 3.0
  • Support DjangoRestFramework 3.11

0.3.7.1 (2019-11-26)

  • Include inherited permissions from groups to user
  • Improve Terra Permission creation

0.3.6 (2019-11-05)

  • Add a method to check if a user has some terra permission

0.3.5 (2019-11-04)

  • Implement TerraPermissions

0.3.4 (2019-10-08)

  • Deprecate looking up user by id (will be removed in 0.4.0)

0.3.3 (2019-10-03)

Feature

  • test factories are now included in packaging

0.3.2 (2019-09-27)

Fixes

  • Groups must be a DRF standard attribute

0.3.1 (2019-09-26)

Fixes

  • Fix id in Group serializer (and API)

0.3.0 (2019-09-25)

Breaking Changes

  • App name move from accounts to terra_accounts. Structure is the same, so backup and restore your data

First public tag

  • Terra app extracted from terracommon.accounts

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-terra-accounts-1.0.7.tar.gz (17.0 kB view details)

Uploaded Source

File details

Details for the file django-terra-accounts-1.0.7.tar.gz.

File metadata

  • Download URL: django-terra-accounts-1.0.7.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.6.13

File hashes

Hashes for django-terra-accounts-1.0.7.tar.gz
Algorithm Hash digest
SHA256 9d0067b39bcf90023b762b3aa7ee619fbf02a4dd31e6260a77344beab6d19deb
MD5 4f4f41df9f2199ba28c3a96757395abd
BLAKE2b-256 e237b014d6281c72f56ea62d07639984e7eff8ba3c905cd3f476c271ad9c626e

See more details on using hashes here.

Supported by

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