Master into Multiples Profiles epic branch#336
Merged
lbjunq merged 5 commits intoepic/multiples-profilesfrom Oct 14, 2025
Merged
Master into Multiples Profiles epic branch#336lbjunq merged 5 commits intoepic/multiples-profilesfrom
lbjunq merged 5 commits intoepic/multiples-profilesfrom
Conversation
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * New Features * Added an API Key module with encrypted storage, optional expiry, DRF authentication/permission, GraphQL middleware and WebSocket support, plus an admin UI that generates and shows keys on create. * Introduced a management command to generate and rotate encryption keys. * New environment variables: BA_API_KEY_REQUEST_HEADER and BA_API_KEY_ENCRYPTION_KEY. * Documentation * Added API Key module docs and guidance for REST/GraphQL integration. * Chores * Packaged templates/README for the API Key app and tightened dependency versions. <!-- end of auto-generated comment: release notes by coderabbit.ai --> [Demo!](https://www.loom.com/share/92f36d4d2e6c4594bbd10da1b1310f8b)
Disable coverage for the management command <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Adjusted test coverage configuration to exclude a non-critical command from coverage analysis, improving accuracy of coverage metrics. * No changes to functionality, runtime behavior, or public APIs. * Error handling and control flow remain unchanged. * This update is internal-only and has no user-facing impact. * No action required from users or integrators. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
## Current Scenario
- Right now `password_expiration` is not really stored anywhere. It's
always calculated in the flight based in the `password_changed_date`
attr. this attr will be changed first time password get's a value and
when it updates. This also means we don't have a ready to read field
with this data.
```python
def save(self, *args, **kwargs):
with self.tracker:
if self.tracker.has_changed("password"):
self.password_changed_date = timezone.now()
super().save(*args, **kwargs)
```
There's also this method which will change `password_changed_date` and
send an email. This is currently not being used anywhere besides under
the admin action to force password expiration:
```python
def force_expire_password(self, request, queryset):
if not request.user.mfa_methods.filter(is_active=True).exists():
self.message_user(
request,
_("You must be a superuser with MFA enabled to perform this action."),
level=messages.ERROR,
)
return
queryset.update(
# Add extra time so the email doesn't get sent multiple times
password_changed_date=timezone.now()
- timezone.timedelta(days=config.USER_PASSWORD_EXPIRATION_INTERVAL + 7)
)
for user in queryset:
send_password_expired_email(user)
```
The password expiration validation works because we are adding it to the
managers queryset. Which means that every object will get this
annotation (which is something that we definitely don't want.
```python
class UserManager(BaseUserManager):
def get_queryset():
return super().get_queryset(*args, **kwargs).add_is_password_expired()
```
Then it will be validated by:
```python
def check_password_expiration(self, user):
if user.is_password_expired:
raise UserPasswordExpiredException(user=user)
```
## Changes applied by this PR
This implementation removes this default annotation from the manager's
queryset by using the annotation where it really needs and by adding a
property for the model instance, where it can be accessed when needed.
E.g. `LoginSerializer` invoking check_password_expiration.
Although I think a better approach would be really handling an
is_expired "cache field", this is a more simple way to workaround this
unnecessary annotations happening through the manager. Without needing
bigger changes for now.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- New Features
- Option to globally disable password expiration by setting the interval
to 0.
- Admin UI now surfaces password-expiration status for users.
- Bug Fixes
- Consistent password-expiration handling across login, admin,
background notifications, and tasks.
- Documentation
- README updated to show default expiration interval is 0.
- Refactor
- Login viewsets consolidated onto a common base for simpler
configuration.
- Tests
- Updated and added tests covering interval == 0 behavior.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Vitor <vitor@M4cb00k.local>
Co-authored-by: Alisson Patricio <eu@alisson.net>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
also updated graphene-django-query-optimizer >= 0.10.15 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Tightened dependency constraints for core REST and GraphQL-related libraries to improve compatibility and stability. * **Tests** * Pinned REST framework and JWT authentication versions in test setup. * Added thumbnail handling and social authentication libraries to broaden test coverage. No user-facing changes are expected from this update. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
vitorguima
approved these changes
Oct 14, 2025
nossila
approved these changes
Oct 14, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.