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

Deny/Allow Permissions #725

Merged
merged 7 commits into from
Aug 24, 2018
Merged

Deny/Allow Permissions #725

merged 7 commits into from
Aug 24, 2018

Conversation

derekcollison
Copy link
Member

Adds the ability to express deny attributes for publish and subscribe permissions. Old behavior and configuration syntax is preserved. This adds a third type to the configuration with allow and deny.

e.g.

publish = {
  allow = "*.*"
  deny = ["foo.bar", "foo.baz"]
}

/cc @nats-io/core

Signed-off-by: Derek Collison <derek@nats.io>
Signed-off-by: Derek Collison <derek@nats.io>
@coveralls
Copy link

coveralls commented Aug 23, 2018

Coverage Status

Coverage increased (+0.08%) to 92.085% when pulling 7b9bab2 on deny into 3ad63c7 on master.

Signed-off-by: Derek Collison <derek@nats.io>
@derekcollison
Copy link
Member Author

ok now that routes added in its ready for review.

Copy link
Member

@kozlovic kozlovic left a comment

Choose a reason for hiding this comment

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

Something weird with sublist's cache

@@ -575,17 +593,73 @@ func parseSubjects(v interface{}) ([]string, error) {
default:
return nil, fmt.Errorf("Expected subject permissions to be a subject, or array of subjects, got %T", v)
}
return checkSubjectArray(subjects)
Copy link
Member

Choose a reason for hiding this comment

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

Why we don't check for validity here?

Copy link
Member Author

Choose a reason for hiding this comment

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

You are correct, need to rework this and use parseSubject() more. I see duplicate code. One sec.

@@ -92,7 +92,8 @@ func newLevel() *level {

// New will create a default sublist
func NewSublist() *Sublist {
return &Sublist{root: newLevel(), cache: make(map[string]*SublistResult)}
// return &Sublist{root: newLevel(), cache: make(map[string]*SublistResult)}
Copy link
Member

Choose a reason for hiding this comment

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

Is that intentional? If you don't create the cache here, it will never be created therefore used.

Copy link
Member Author

Choose a reason for hiding this comment

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

This was me playing with other things, should not be in here. Will remove.

for k := range s.cache {
delete(s.cache, k)
break
if s.cache != nil {
Copy link
Member

Choose a reason for hiding this comment

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

I think all code in sublist assumes the cache is not nil since it is (was) created in NewSublist().

Copy link
Member Author

Choose a reason for hiding this comment

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

Ditto

allow = "foo.*"
deny = "foo.baz"
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Not that it matters but newline?

Copy link
Member Author

Choose a reason for hiding this comment

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

Can add.

Signed-off-by: Derek Collison <derek@nats.io>
Signed-off-by: Derek Collison <derek@nats.io>
Signed-off-by: Derek Collison <derek@nats.io>
@kozlovic
Copy link
Member

LGTM

@derekcollison derekcollison merged commit 976e754 into master Aug 24, 2018
@derekcollison derekcollison deleted the deny branch August 24, 2018 00:09
kozlovic added a commit that referenced this pull request Aug 27, 2018
This is an issue in master only, not in any public release.
The issue is that permissions should be assigned as-is for the
route perms because Publish/Subscribe could be nil, so trying
to dereference Publish.Allow/Deny or Subscribe.Allow/Deny could
crash. The code checking for permissions correctly check if
Publish/Subscribe is nil or not.

This was introduced with PR #725

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
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.

None yet

3 participants