-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fix for #792 #794
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
Fix for #792 #794
Conversation
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.
Either there are changes required or I did not understand what we are trying to do.
server/client.go
Outdated
// and cache. We check if the subject is a wildcard that contains any of | ||
// the deny clauses. | ||
// FIXME(dlc) - We could be smarter and track when these go away and remove. | ||
if c.mperms == nil && subjectHasWildcard(subject) { |
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.
Should remove c.mperms == nil
. We need to think of reload. On reload, we will call processSubsOnConfigReload() for each client and that calls canSubscribe(). If there was a deny before but not anymore, this would need to be cleared, etc..
But even then, it brings the question: if a client has already a mperms, then any other subscription for that client would not be making this check? Why? Say that you have deny clauses on "foo.bar" and "foo.baz", and for the first time create a subscription on ".bar", then only "foo.bar" would be added to the mperms. But if later I create a subscription on ">" or ".baz", etc.. then I should also have "foo.baz" in mperms.
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 agree need to handle reload, I will think through that. My first thought is just clear mperms on processSubsOnConfigReload() which will then reprocess all the subs that we have as if they are being recreated.
For not checking, see comment above. Once we get triggered we load all deny filters at once, not one at a time.
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.
Yes, clearing prior to call canSubscribe() would repopulate it I guess.
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.
Will make that change..
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.
Well I notice now that we release the client lock and then we process the subs checking canSubscribe(). Which means that if I clear c.mperms and then release the lock we could allow messages through that should not. Will think some more about how to do this.
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.
Safe to hold the lock in your opinion there?
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 I meant is in processSubsOnConfigReload(), you could do something like:
for _, sub := range subs {
if checkPerms {
c.mu.Lock()
c.mperms = nil
canSub := c.canSubscribe(sub.subject)
c.mu.Unlock()
if !canSub {
removed = append(removed, sub)
c.unsubscribe(acc, sub, true)
}
}
if checkAcc {
c.mu.Lock()
...
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.
Can't do that, need to clear it once before looping through subs.
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.
Oh yes, it is per client, while this loop is for all subs for that client.
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 created another solution that I think works well.
Signed-off-by: Derek Collison <derek@nats.io>
Signed-off-by: Derek Collison <derek@nats.io>
Signed-off-by: Derek Collison <derek@nats.io>
Signed-off-by: Derek Collison <derek@nats.io>
Signed-off-by: Derek Collison <derek@nats.io>
LGTM. We could cleanup |
Allow deny clauses for subscriptions to still allow wildcard subscriptions but do not deliver the messages themselves.
Signed-off-by: Derek Collison derek@nats.io
Resolves #792
git pull --rebase origin master
)Resolves #792
Changes proposed in this pull request:
/cc @nats-io/core