Skip to content
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

Support topic authorization #73

Merged
merged 6 commits into from
Sep 11, 2021

Conversation

abompard
Copy link
Contributor

SUMMARY

Add support for topic authorizations in the user module

Topic authorization has been added in RabbitMQ 3.7.0.

Only the full topic permission list is supported for now, similar to the existing vhost permission list.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

rabbitmq_user

ADDITIONAL INFORMATION

I think there may be places for code refactoring in this change, but not as much as one would think since the format is not identical, and we still want different error messages between vhost authorization and topic authorization.

@Andersson007
Copy link
Contributor

I close-reopened to trigger CI

@Andersson007
Copy link
Contributor

@Andersson007
Copy link
Contributor

@abompard ^

Copy link
Contributor

@Andersson007 Andersson007 left a comment

Choose a reason for hiding this comment

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

Comment on lines 132 to 134
# Add user to server and assign some topic permissions on / vhost.
# The user doesn't have topic permission rules for other vhosts
- community.rabbitmq.rabbitmq_user:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# Add user to server and assign some topic permissions on / vhost.
# The user doesn't have topic permission rules for other vhosts
- community.rabbitmq.rabbitmq_user:
- name: Add user to server and assign some topic permissions on / vhost, the user doesn't have topic permission rules for other vhosts
community.rabbitmq.rabbitmq_user:

Or something. - name: statement is required in EXAMPLES according to the development doc

Also there's the sanity error:

00:52 >>> Standard Output
00:52 plugins/modules/rabbitmq_user.py:143:-1: traceback: SyntaxError: invalid escape sequence \.

description:
- A list of dicts, each dict contains vhost, exchange, read_priv and write_priv,
and represents a topic permission rule for that vhost.
- By default vhost is / and exchange is amq.topic.
Copy link
Contributor

@Andersson007 Andersson007 Jul 21, 2021

Choose a reason for hiding this comment

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

Suggested change
- By default vhost is / and exchange is amq.topic.
- By default vhost is C(/) and exchange is C(amq.topic).
- Supported since RabbitMQ 3.7.0.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd also put a note here that the feature has been added in RabbitMQ 3.7.0.

Copy link
Contributor

Choose a reason for hiding this comment

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

or "supported since ..."

Copy link
Contributor

Choose a reason for hiding this comment

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

and that the option is ignored otherwise / the module will fail. Though I didn't look at the code so far, so I have no idea how it is implemented.

Copy link
Contributor

Choose a reason for hiding this comment

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

@cognifloyd
Copy link
Collaborator

Tests are working on the main branch now. @abompard Could you rebase or merge in master?
I'd love to merge this soonish. I don't like leaving PRs dangling... 😃

[Topic authorization](https://www.rabbitmq.com/access-control.html#topic-authorisation)
has been added in RabbitMQ 3.7.0.

Only the full topic permission list is supported for now, similar to the
existing vhost permission list.

Signed-off-by: Aurélien Bompard <aurelien@bompard.org>
The default vhost is now `/` and the default exchange is `amq.topic`.

Signed-off-by: Aurélien Bompard <aurelien@bompard.org>
@abompard
Copy link
Contributor Author

abompard commented Sep 9, 2021

Done, thanks!

@abompard
Copy link
Contributor Author

abompard commented Sep 9, 2021

Oh wait there were review suggestions, let me implement them first

Signed-off-by: Aurélien Bompard <aurelien@bompard.org>
@abompard
Copy link
Contributor Author

abompard commented Sep 9, 2021

@Andersson007 I've implemented your suggestions in a separate commit for ease of review, but I can squash it in the main commit if you prefer.

Signed-off-by: Aurélien Bompard <aurelien@bompard.org>
@Andersson007
Copy link
Contributor

@Andersson007 I've implemented your suggestions in a separate commit for ease of review, but I can squash it in the main commit if you prefer.

@abompard thanks for fixing! No need to squash, we'll do it when merging.
There are sanity issues:

01:28 ERROR: Found 2 pylint issue(s) which need to be resolved:
01:28 ERROR: plugins/modules/rabbitmq_user.py:484:11: use-a-generator: Use a generator instead 'any(vhost_count > 1 for vhost_count in count(vhosts).values())' (50%)
01:28 ERROR: plugins/modules/rabbitmq_user.py:503:11: use-a-generator: Use a generator instead 'any(ve_count > 1 for ve_count in count(vhost_exchanges).values())' (100%)

Please fix it a bit. I think you can try to remove the generator ([]) from any() statement

@Andersson007
Copy link
Contributor

also version_added should be 1.2.0 as we already released 1.1.0

Signed-off-by: Aurélien Bompard <aurelien@bompard.org>
@Andersson007
Copy link
Contributor

please ping us again when CI is green (or if you need help with it) and the PR is ready for review

@abompard
Copy link
Contributor Author

abompard commented Sep 9, 2021

It's green @Andersson007 ! :-)

Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>
Copy link
Contributor

@Andersson007 Andersson007 left a comment

Choose a reason for hiding this comment

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

LGTM (general things like formatting, etc. as I'm not a specialist in the area)

@Andersson007
Copy link
Contributor

@cognifloyd if the PR is fine for you, feel free to merge of course.
@abompard , cognifloyd is a new maintainer of this collection!

@Andersson007
Copy link
Contributor

@abompard I created an issue for doc examples #95 and mention you there. Doc is a face of the collection where examples are especially important cause people usually scroll down right to them:)

@cognifloyd cognifloyd merged commit e748054 into ansible-collections:main Sep 11, 2021
@Andersson007
Copy link
Contributor

@abompard thanks for the contribution! @cognifloyd thanks for reviewing and merging!
(@abompard fyi @duttaANI is gonna fix the examples across the collection, thanks!)

@abompard abompard deleted the topic-authz branch September 14, 2021 08:58
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.

3 participants