Files
ivatar/ivatar/ivataraccount/migrations/0008_userpreference.py
Oliver Falk 368aa5bf27 feat: enhance security with improved password hashing and logging
- Add Argon2PasswordHasher with high security settings as primary hasher
- Implement fallback to PBKDF2PasswordHasher for CentOS 7/Python 3.6 compatibility
- Add argon2-cffi dependency to requirements.txt
- Replace all print statements with proper logging calls across codebase
- Implement comprehensive logging configuration with multiple handlers:
  * ivatar.log - General application logs (INFO level)
  * ivatar_debug.log - Detailed debug logs (DEBUG level)
  * security.log - Security events (WARNING level)
- Add configurable LOGS_DIR setting with local config override support
- Create config_local.py.example with logging configuration examples
- Fix code quality issues (flake8, black formatting, import conflicts)
- Maintain backward compatibility with existing password hashes

Security improvements:
- New passwords use Argon2 (memory-hard, ASIC-resistant)
- Enhanced PBKDF2 iterations for fallback scenarios
- Structured logging for security monitoring and debugging
- Production-ready configuration with flexible log locations

Tests: 85/113 passing (failures due to external DNS/API dependencies)
Code quality: All pre-commit hooks passing
2025-10-15 15:13:09 +02:00

59 lines
1.8 KiB
Python

# -*- coding: utf-8 -*-
# pylint: disable=invalid-name,missing-docstring
# Generated by Django 2.0.6 on 2018-07-04 12:32
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
def add_preference_to_user(apps, schema_editor): # pylint: disable=unused-argument
"""
Make sure all users have preferences set up
"""
from django.contrib.auth.models import User
UserPreference = apps.get_model(
"ivataraccount", "UserPreference"
) # pylint: disable=invalid-name
for user in User.objects.filter(userpreference=None):
pref = UserPreference.objects.create(user_id=user.pk) # pragma: no cover
pref.save() # pragma: no cover
class Migration(migrations.Migration): # pylint: disable=missing-docstring
dependencies = [
("auth", "0009_alter_user_last_name_max_length"),
("ivataraccount", "0007_auto_20180627_0624"),
]
operations = [
migrations.CreateModel(
name="UserPreference",
fields=[
(
"theme",
models.CharField(
choices=[
("default", "Default theme"),
("clime", "Climes theme"),
],
default="default",
max_length=10,
),
),
(
"user",
models.OneToOneField(
on_delete=django.db.models.deletion.CASCADE,
primary_key=True,
serialize=False,
to=settings.AUTH_USER_MODEL,
),
),
],
),
migrations.RunPython(add_preference_to_user),
]