-
Notifications
You must be signed in to change notification settings - Fork 35
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
Feature/mqtt topic namespacing for emq #2887
Conversation
…ub.com/apinf/platform into feature/mqtt-topic-namespacing-for-emq
…lable and make it unique
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't tested this yet, these are comments from just looking at the diff.
.disabled-div{ | ||
pointer-events: none; | ||
opacity: 0.4; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consistent indentation please. And configure your editor to end files with newlines.
@@ -125,7 +126,7 @@ Meteor.methods({ | |||
id: rule.id, | |||
allow: rule.allow, | |||
access: rule.access, | |||
topic: rule.topic, | |||
topic: topicPrefix + rule.topic, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this is a good idea. an enterprising user can make a request with invalid or someone else's topic prefix.
Please add a verification to ensure this is the same as saved topic prefix for this api, or even better, do not accept topic prefix as argument here. I'm asuming it would be possible to extract saved topic prefix from mongo directly on server and prepend it there.
Client side data should never be trusted blindly. Client uses topic prefix to display to users, and server should extract topic prefix from db and use it for its operations instead of trusting data that was through the client.
@@ -153,7 +154,7 @@ Meteor.methods({ | |||
proxyId: rule.proxyId, | |||
allow: rule.allow, | |||
access: rule.access, | |||
topic: rule.topic, | |||
topic: topicPrefix + rule.topic, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
@@ -11,3 +11,5 @@ https://joinup.ec.europa.eu/community/eupl/og_page/european-union-public-licence | |||
export const proxyBasePathRegEx = new RegExp(/^\/[\w\-\.\?\$\*\+\'\)\(/:#@!&,;=]+\/$/); | |||
// eslint-disable-next-line no-useless-escape | |||
export const apiBasePathRegEx = new RegExp(/^\/[\w\-\?\.\$\*\+\)\'\(/:#@!&,;=]*$/); | |||
// allow only a-zA-Z0-9_ # + | |||
export const topicPrefix = new RegExp(/^\/[\w+#]+\/$/); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+
and #
are special in mqtt topics. Both characters must not be allowed in topic prefix.
Topic prefix regex should be /^\/[\w-]+\/$/
Topics, on the other hand, should probably be /^\/[\w-]+\/(([\w-]+|\+)\/)*([\w-]+|\+|#)$/
To explain, topics must start with a /
, have atleast one "word" (topic prefix), followed by a /
, and can be followed by:
- an arbitrarily long string of words or
+
delimited by/
- optionally ending in a
#
The last character of a topic can not be /
. The regex is a bit unwieldy, but I can not compress it further.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW the topic regex is for use after prepending the prefix. Without the prefix, it will reduce to /^(([\w-]+|\+)\/)*([\w-]+|\+|#)$/
@@ -28,6 +28,7 @@ | |||
"invalidDomainMessage": "Tarvitaan validi verkkotunnus", | |||
"invalidEmailMessage": "Tarvitaan validi s\u00e4hk\u00f6postiosoite", | |||
"invalidApiBasePathMessage": "T\u00e4ytyy alkaa kauttaviivalla ja p\u00e4\u00e4tty\u00e4 kauttaviivaan. Sallittuja merkkej\u00e4 ovat kirjaimet, numerot sek\u00e4 -.?$*+'()\/:#@!&,;=", | |||
"invalidTopicPrefix": "On aloitettava ja päättyttävä /. Sallitut aakkosnumeeriset merkit ja + #", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete Finnish text
@@ -1060,6 +1061,7 @@ | |||
"proxyBackendForm_apiPort_helpText": "Rajapintapalvelimen portin numero", | |||
"proxyBackendForm_disableApiKey_helpText": "Salli k\u00e4ytt\u00e4jien kutsua rajapintaa ilman rajapinta-avainta.", | |||
"proxyBackendForm_proxyBasePath_helpText": "Peruspolku jokaiseen v\u00e4lityspalvelinkutsuun. Esimerkiksi:", | |||
"proxyBackendForm_topicPrefix_helpText": "Aiheen etuliite lisätään ennen kaikkia EMQ-aiheita.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete Finnish text
<!-- Rate limits --> | ||
<div class="panel panel-default"> | ||
<div class="panel panel-default {{# unless proxyBackend.emq.settings.topicPrefix }} disabled-div {{/ unless}}"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrap part {{# unless proxyBackend.emq.settings.topicPrefix }} disabled-div {{/ unless}}
in helper.
Read: http://blazejs.org/guide/spacebars.html#Attribute-Helpers
@@ -3,8 +3,35 @@ | |||
<!-- Hidden fields --> | |||
{{> afQuickField name="type" type="hidden" value="emq" }} | |||
<!-- End hidden fields --> | |||
|
|||
<!-- Topic prefix --> | |||
{{#unless proxyBackend.emq.settings.topicPrefix}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add spacebar between #
and word
Add spacebar before }}
</label> | ||
|
||
{{> afFieldInput | ||
name="emq.settings.topicPrefix" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Place it in one line
|
||
<!-- validation messages --> | ||
{{# if afFieldIsInvalid name='emq.settings.topicPrefix' }} | ||
<p class="text-danger"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<p>
block must be nested
@amardeep-deligence Don't generate one-type commits.
These commits are unuseful, squash them |
If trying to fix the last commit, amending and force pushing with lease is
a good idea. or else there's a fixup flag to git commit that allows marking
commits for future squashing.
Even for other commits, commit messages need some work to make intent
clear, but I won't block this waiting for that.
…On Thu 7 Sep, 2017, 10:48 Daria Voytova ***@***.***> wrote:
@amardeep-deligence <https://github.com/amardeep-deligence> Don't
generate one-type commits.
Fixed git platform build errors
Fixed git platform build errors
Fixed git platform build errors Third Time
Fixed git platform build errors - Fourth attempt
These commits are unuseful, squash them
https://github.com/apinf/platform/blob/develop/CONTRIBUTING.md#git-rebase
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub
<#2887 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABnL8NrUF5MPZ_7E0euPs4Ktj0iy0hmmks5sf3yzgaJpZM4PMyAf>
.
|
@phanimahesh Did you test the functional work of this code? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never merge into a feature branch. As it stands this branch can not be reviewed. Commits are present multiple times and changes in a commit don't appear in overall diff, even when I did not notice any later commit reverting them. Please do a proper rebase and push force with lease, compressing this into no more than 2-3 logical commits.
Also:
- ACL rules must fit in a single line on desktop screens
- Deleting all ACLs is a single accidental click away. Add a confirmation or undo option.
@@ -53,7 +53,7 @@ Meteor.methods({ | |||
if (err) reject(err); | |||
|
|||
// Expose only username and ID | |||
const users = _.map(res.data, (user) => { | |||
const users = _.map(res?res.data:[], (user) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally this single line should be commit of its own.
@@ -130,7 +142,7 @@ Meteor.methods({ | |||
}; | |||
// Append ACL type & value | |||
data[rule.fromType] = rule.fromValue; | |||
|
|||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
@@ -158,7 +170,7 @@ Meteor.methods({ | |||
}; | |||
// Append ACL type & value | |||
data[rule.fromType] = rule.fromValue; | |||
|
|||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
// allow / then a-zA-Z0-9 then / | ||
export const topicPrefixRegEx = new RegExp(/^\/[\w-]+\/$/); | ||
// Must begin with alphanumeric. Allowed character is / and end with + or # delimited by / | ||
export const topicRegEx = new RegExp(/^(([\w-]+|\+)\/)*([\w-]+|\+|#)$/); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is incorrect. This should make it clear:
Topic is a string of segments joined by /
. A segment is either:
- a string of letters, numbers or literals
-
or_
- Or just the literal
+
In addition, the last segment can be a literal #
.
{ 'emq.settings.acl.id': { $in: [rules && rules.length ? rules[0].id : ''] } }, | ||
{ fields: { 'emq.settings.topicPrefix': 1 } }); | ||
// set topicPrefix if available in db | ||
if (emqProxyBackend && emqProxyBackend.emq.settings.topicPrefix) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if it is not available? User gets to set rules on arbitrary topics because enforced prefix will be ''
? (see line 106)
Fixed git platform build errors Fixed git platform build errors Fixed git platform build errors Third Time
dc7aae6
to
0ddd2a1
Compare
@marla-singer Can you review the code? @phanimahesh Can you check that the PR fulfills the requirements for the enhancement issue? |
@phanimahesh "Deleting all ACLs is a single accidental click away. Add a confirmation or undo option." is not done yet. Other features are ready to test. |
f47ea50
to
bd10f98
Compare
@phanimahesh Can you create a separate issue for "Deleting all ACLs is a single accidental click away. Add a confirmation or undo option." ? Describe why it is needed in the issue and what needs to be done. |
@bajiat @phanimahesh , I have implemented "confirmation before deleting ACLs" in this PR already |
This PR may also close Issue- #2724 |
@amardeep-deligence and @phanimahesh What is the status of the PR? Have all the requested changes been made? If not, is there a reason? |
@bajiat @phanimahesh @marla-singer @brylie this PR is ready for review. |
@phanimahesh and @marla-singer What is the status of this PR? The PR was started 1,5 months ago. Are there pending changes or is the review for changes missing? Can this still be rebased or should it be started from scratch by cherrypicking the actual changes? I would like to have a resolution (decision on what is to be done) by 16:00 EEST today. |
@preriasusi What to do with this PR? |
@marla-singer We are effectively reimplementing this entire view in the new dashboard you are working on, after considering more feedback. This can be closed for now, or after we have absorbed the relevant parts into the new dashboard. |
Fixed issue #2842
closes: #2842