Skip to content

Comments

Master into Multiples Profiles epic branch#336

Merged
lbjunq merged 5 commits intoepic/multiples-profilesfrom
master
Oct 14, 2025
Merged

Master into Multiples Profiles epic branch#336
lbjunq merged 5 commits intoepic/multiples-profilesfrom
master

Conversation

@lbjunq
Copy link
Contributor

@lbjunq lbjunq commented Oct 7, 2025

No description provided.

patsluth-tsl and others added 4 commits September 15, 2025 08:34
<!-- 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>
@coderabbitai
Copy link

coderabbitai bot commented Oct 7, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch master

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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 -->
@lbjunq lbjunq merged commit baae48d into epic/multiples-profiles Oct 14, 2025
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants