-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Conversation
Signed-off-by: Derek Collison <[email protected]>
Signed-off-by: Derek Collison <[email protected]>
Signed-off-by: Derek Collison <[email protected]>
ok now that routes added in its ready for review. |
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.
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) |
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.
Why we don't check for validity here?
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.
You are correct, need to rework this and use parseSubject() more. I see duplicate code. One sec.
server/sublist.go
Outdated
@@ -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)} |
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.
Is that intentional? If you don't create the cache here, it will never be created therefore used.
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 was me playing with other things, should not be in here. Will remove.
server/sublist.go
Outdated
for k := range s.cache { | ||
delete(s.cache, k) | ||
break | ||
if s.cache != nil { |
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 think all code in sublist assumes the cache is not nil since it is (was) created in NewSublist().
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.
Ditto
allow = "foo.*" | ||
deny = "foo.baz" | ||
} | ||
} |
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.
Not that it matters but newline?
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 add.
Signed-off-by: Derek Collison <[email protected]>
Signed-off-by: Derek Collison <[email protected]>
Signed-off-by: Derek Collison <[email protected]>
LGTM |
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 <[email protected]>
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.
/cc @nats-io/core