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

Review/fix RabbitMQ user permissions for source and subscriber users #1028

Open
reidsunderland opened this issue Apr 25, 2024 · 2 comments
Open
Labels
Discussion_Needed developers should discuss this issue. good first issue Good for newcomers Priority 5 - Defect Missing and/or broken functionality - do not forget

Comments

@reidsunderland
Copy link
Member

The RabbitMQ permissions set by sr3:

# source
if role in ['source']:
c = "configure=^q_%s.*|^xs_%s.*" % (user, user)
w = "write=^q_%s.*|^xs_%s.*" % (user, user)
r = "read=^q_%s.*|^x[lrs]_%s.*|^x.*public$" % (user, user)
logger.info("permission user '%s' role %s %s %s %s " %
(user + '@' + url.hostname, 'source', c, w, r))
declare = "declare permission vhost=/ user=%s %s %s %s" % (user, c, w, r)
dummy = run_rabbitmqadmin(url, declare, simulate)
return
# subscribe
if role in ['subscribe', 'subscriber']:
c = "configure=^q_%s.*" % user
w = "write=^q_%s.*|^xs_%s$" % (user, user)
r = "read=^q_%s.*|^x[lrs]_%s.*|^x.*public$" % (user, user)
logger.info("permission user '%s' role %s %s %s %s " %
(user + '@' + url.hostname, 'source', c, w, r))
declare = "declare permission vhost=/ user=%s %s %s %s" % (user, c, w, r)
dummy = run_rabbitmqadmin(url, declare, simulate)

seem a little bit wrong, after discussing with @petersilva, @andreleblanc11 and @junhu3.

User Configure Write Read
source ^q_USERNAME.*|^xs_USERNAME.* ^q_USERNAME.*|^xs_USERNAME.* ^q_USERNAME.*|^x[lrs]_USERNAME.*|^x.*public$
subscriber ^q_USERNAME.* ^q_USERNAME.*|^xs_USERNAME$ ^q_USERNAME.*|^x[lrs]_USERNAME.*|^x.*public$

History: the l in x[lrs] was for log, which was renamed to report. We keep it for backwards compatibility.

I think the correct permissions should probably be:

User Configure Write Read
source ^q_USERNAME.*|^x[lrs]_USERNAME.* ^q_USERNAME.*|^x[lrs]_USERNAME.* ^q_USERNAME.*|^x[lrs]_USERNAME.*|^x.*public$
subscriber ^q_USERNAME.*|^x[lr]_USERNAME$ ^q_USERNAME.*|^x[lr]_USERNAME$ ^q_USERNAME.*|^x[lrs]_USERNAME.*|^x.*public$
@reidsunderland reidsunderland added good first issue Good for newcomers Priority 5 - Defect Missing and/or broken functionality - do not forget Discussion_Needed developers should discuss this issue. labels Apr 25, 2024
@petersilva
Copy link
Contributor

petersilva commented Apr 26, 2024

  • The 'l' in all the patterns are a long gone transition thing... if we are changing them the patterns should just be [rs]. ( in about 2017 we decided to rename the telemetry messages from "log" messages to "report" messages, and the xl_ and xr_ messages were meant to be publication channels for telemetry messages returned by consumers.

  • If we are looking at this. I notice a weakness in all the patterns based on usernames that are substrings of other user names. If we have user A and user AB, then user A will be able to use any of user AB eschanges. I think the patterns should likely be changed to add a trailing underscore.... q_USERNAME_.* ... x[rs]USERNAME.* ... etc... This may involve some incompatibility with existing deplorements.

@petersilva
Copy link
Contributor

I just re-read the relevant documentation with @mshak2 and this intent here looks correct... the corresponding documentaiton is wrong and needs to be updated also.

Role can be one of:

subscriber
A subscriber is a user that can only subscribe to data and report messages. Not permitted to inject data. Each subscriber gets an xs_ named exchange on the pump. If a user is named Acme, the corresponding exchange will be xs_Acme. This exchange is where an sr_subscribe process will send its report messages.

By convention/default, the anonymous user is created on all pumps to permit subscription without a specific account.

should likely be xr_ ... not xs... in agreement with @reidsunderland 's proposal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Discussion_Needed developers should discuss this issue. good first issue Good for newcomers Priority 5 - Defect Missing and/or broken functionality - do not forget
Projects
None yet
Development

No branches or pull requests

2 participants