-
Notifications
You must be signed in to change notification settings - Fork 6
Ensure default password for TigaUser #323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR ensures that newly created TigaUser instances are assigned a default password by modifying the password field to include a default value generator. Previously, the password field was nullable, which could allow users without passwords.
Key Changes:
- Added a default password configuration in settings
- Modified TigaUser model to automatically hash and assign default password
- Added test coverage to verify the default password is set correctly
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tigaserver_project/settings.py | Introduces DEFAULT_TIGAUSER_PASSWORD constant for configuring the default password |
| tigaserver_app/models.py | Adds get_default_password_hash() function and updates TigaUser.password field to use it as default |
| tigaserver_app/tests/tests.py | Adds test assertion to verify new users are created with the default password |
| tigaserver_app/migrations/0087_alter_tigauser_password.py | Django migration to apply the password field default change |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Change this in prod | ||
| DEFAULT_TIGAUSER_PASSWORD = 'TEST_PASSWORD' |
Copilot
AI
Oct 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hardcoding a default password in settings is a security risk, especially with DEBUG=False in production. Consider using environment variables or Django's secrets management to configure this value securely, and ensure it's overridden in production environments.
| # Change this in prod | |
| DEFAULT_TIGAUSER_PASSWORD = 'TEST_PASSWORD' | |
| # Set this via environment variable in production | |
| DEFAULT_TIGAUSER_PASSWORD = os.environ.get('DEFAULT_TIGAUSER_PASSWORD') |
| def get_default_password_hash(): | ||
| return make_password(settings.DEFAULT_TIGAUSER_PASSWORD) |
Copilot
AI
Oct 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is called every time a TigaUser instance is created, hashing the same password repeatedly. Since the default password is static, consider caching the hash result to avoid unnecessary computation on each user creation.
| USERNAME_FIELD = 'pk' | ||
|
|
||
| password = models.CharField(_('password'), max_length=128, null=True, blank=True) | ||
| password = models.CharField(_('password'), max_length=128, default=get_default_password_hash) |
Copilot
AI
Oct 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing null=True and blank=True from the password field may cause issues for existing TigaUser records that have NULL passwords. Consider adding a data migration to populate existing NULL passwords before applying this schema change.
No description provided.