Skip to content

Check Will publish permission on connect - #276

Merged
Gujiawei-Edinburgh merged 1 commit into
apache:mainfrom
popduke:feat-will-permission-check
Aug 26, 2026
Merged

Check Will publish permission on connect#276
Gujiawei-Edinburgh merged 1 commit into
apache:mainfrom
popduke:feat-will-permission-check

Conversation

@popduke

@popduke popduke commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Motivation

A Will message is declared as part of the CONNECT packet, so its publish permission should be determined before the session is established.

Previously, the permission was checked only when the Will was about to be published. That could happen long after CONNECT and make the result depend on permission state at disconnect time.

Changes

  • Check the Will topic's publish permission while processing CONNECT.
  • Reject CONNECT with the corresponding MQTT 3 or MQTT 5 reason code when the permission is denied or cannot be checked.
  • Remove the permission check from the Will publication path.
  • Keep normal PUBLISH permission checks unchanged.

Testing

Added MQTT 3 and MQTT 5 coverage for:

  • denied Will publish permission;
  • permission provider failures and invalid results;
  • immediate and delayed Will messages;
  • permission checks occurring before session creation;
  • Will publication without another permission check.

@Gujiawei-Edinburgh Gujiawei-Edinburgh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good to me.

@Gujiawei-Edinburgh
Gujiawei-Edinburgh merged commit d1b6e72 into apache:main Aug 26, 2026
4 checks passed
@popduke
popduke deleted the feat-will-permission-check branch August 27, 2026 03:40
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.

2 participants