Skip to content

Conversation

ansd
Copy link
Member

@ansd ansd commented Sep 29, 2025

This PR contains two commits.

Commit 1:

What?

Support logging (at INFO level) the reason provided by the HTTP auth backend why authentication or autorisation was denied.

Why?

  • Security and compliance often require detailed logs of why access was denied
  • Operational debugging: Operators see immediately in RabbitMQ logs why authentication/authorization failed without checking the HTTP backend logs

How?

The HTTP body returned by the HTTP auth server is allowed to be deny <Reason> where <Reason> is any text that will be logged by RabbitMQ at INFO level.

Commit 2:

What?

If the new config setting authorization_failure_disclosure
for an authz backend is set to true, (false by default), RabbitMQ
will return the reason why access was denied to the client.
For now, only the HTTP auth backend supports this new config setting.

Why?

This helps debugging and troubleshooting directly in the client.
Some users might not have access to the RabbitMQ logs, for other
users it's cumbersome to correlate authz denial in the client with
logs on the broker.

For example, some customers would like to pass the reason why
authorization was denied from their custom HTTP auth backend via
RabbitMQ back to the client.

How?

Authz backends can now return {false, Reason} as an alternative to
just false if access is denied.

For security reasons, the additional denial reason by the authz backend
will be returned to the client only if the operator opted in by setting
authorization_failure_disclosure to true.

Note that authorization_failure_disclosure applies only to
already authenticated clients when they try to access resources (e.g. vhosts,
exchanges, queues, topics). For security reasons, no detailed denial reason is
returned to the client if authentication fails.

Also note that authorization_failure_disclosure is set separately per
auth backend instead of being set globally for all auth backends. This
more fine granular configurability helps for use cases where the broker
should reveal the authz denial reason for only a specific auth backend.

@ansd ansd added this to the 4.3.0 milestone Sep 29, 2025
@ansd ansd self-assigned this Sep 29, 2025
@ansd ansd force-pushed the auth-backend-http-log-deny-reason branch 3 times, most recently from 16af50f to 5e08d74 Compare October 7, 2025 14:35
@mergify mergify bot added the make label Oct 7, 2025
@ansd ansd force-pushed the auth-backend-http-log-deny-reason branch 5 times, most recently from f9b9fa0 to 36f885c Compare October 8, 2025 14:57
@ansd ansd changed the title Support logging HTTP auth denial reason Optionally return HTTP auth backend denial reason to client Oct 8, 2025
ansd added 2 commits October 9, 2025 10:26
 ## What?
Support logging (at INFO level) the reason provided by the HTTP auth backend why
authentication or autorisation was denied.

 ## Why?
* Security and compliance often require detailed logs of why access was denied
* Operational debugging: Operators see immediately in RabbitMQ logs why
  authentication/authorization failed without checking the HTTP backend logs

 ## How?
The HTTP body returned by the HTTP auth server is allowed to be `deny <Reason>`
where `<Reason>` is any text that will be logged by RabbitMQ at INFO level.
 ## What?

If the new config setting `authorization_failure_disclosure`
for an authz backend is set to `true`, (`false` by default), RabbitMQ
will return the reason why access was denied to the client.
For now, only the HTTP auth backend supports this new config setting.

 ## Why?

This helps debugging and troubleshooting directly in the client.
Some users might not have access to the RabbitMQ logs, for other
users it's cumbersome to correlate authz denial in the client with
logs on the broker.

For example, some customers would like to pass the reason why
authorization was denied from their custom HTTP auth backend via
RabbitMQ back to the client.

 ## How?

Authz backends can now return `{false, Reason}` as an alternative to
just `false` if access is denied.

For security reasons, the additional denial reason by the authz backend
will be returned to the client only if the operator opted in by setting
`authorization_failure_disclosure` to `true`.

Note that `authorization_failure_disclosure` applies only to
already authenticated clients when they try to access resources (e.g. vhosts,
exchanges, queues, topics). For security reasons, no detailed denial reason is
returned to the client if **authentication** fails.

Also note that `authorization_failure_disclosure` is set separately per
auth backend instead of being set globally for all auth backends. This
more fine granular configurability helps for use cases where the broker
should reveal the authz denial reason for only a specific auth backend.
@ansd ansd force-pushed the auth-backend-http-log-deny-reason branch from 36f885c to 9c075ad Compare October 9, 2025 08:26
@ansd ansd marked this pull request as ready for review October 9, 2025 09:06
Copy link
Collaborator

@dumbbell dumbbell left a comment

Choose a reason for hiding this comment

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

This looks good to me!

@ansd ansd merged commit 34a638a into main Oct 10, 2025
291 checks passed
@ansd ansd deleted the auth-backend-http-log-deny-reason branch October 10, 2025 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants