-
Notifications
You must be signed in to change notification settings - Fork 46
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
Permission subset checks when creating roles #64
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 21 additions & 5 deletions
26
sor-api/src/main/java/com/bazaarvoice/emodb/sor/condition/Comparison.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,34 @@ | ||
package com.bazaarvoice.emodb.sor.condition; | ||
|
||
import com.bazaarvoice.emodb.sor.delta.Delta; | ||
|
||
public enum Comparison { | ||
GT("gt"), | ||
GE("ge"), | ||
LT("lt"), | ||
LE("le"); | ||
GT("gt", false), | ||
GE("ge", true), | ||
LT("lt", false), | ||
LE("le", true); | ||
|
||
private final String _deltaFunction; | ||
private final boolean _isClosed; | ||
|
||
private Comparison(String deltaFunction) { | ||
private Comparison(String deltaFunction, boolean isClosed) { | ||
_deltaFunction = deltaFunction; | ||
_isClosed = isClosed; | ||
} | ||
|
||
/** | ||
* Returns the name of the this comparison as it appears as a function in the delta syntax. | ||
* @see Delta#appendTo(Appendable) | ||
*/ | ||
public String getDeltaFunction() { | ||
return _deltaFunction; | ||
} | ||
|
||
/** | ||
* A comparison is closed if the associated value is included in the defined range. This method returns true for | ||
* GE and LE, false for GT and LT. | ||
*/ | ||
public boolean isClosed() { | ||
return _isClosed; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
sor-api/src/main/java/com/bazaarvoice/emodb/sor/condition/LikeCondition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,49 @@ | ||
package com.bazaarvoice.emodb.sor.condition; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
public interface LikeCondition extends Condition { | ||
|
||
/** | ||
* Returns the matching string used by this condition. | ||
*/ | ||
String getCondition(); | ||
|
||
/** | ||
* Returns true if the provided String is a match for this condition. | ||
*/ | ||
boolean matches(String input); | ||
|
||
/** | ||
* Returns true if there exists a value v which matches both this condition and the provided condition. | ||
* For example, like("a*") overlaps like("*c") since there exists a value, "abc", which matches both, | ||
* while like("a*") does not overlap like("b*") since they share no common values. | ||
*/ | ||
boolean overlaps(LikeCondition condition); | ||
|
||
/** | ||
* Returns true if for every value v which matches this condition v also matches the provided condition. | ||
* For example, like("ab*") is a subset of like("a*"), while like("a*") is not a subset of like("*c") since | ||
* there exists a value, "ab", which matches the former but not the latter. | ||
*/ | ||
boolean isSubsetOf(LikeCondition condition); | ||
|
||
/** | ||
* Returns the constant prefix shared by all results matching this condition, or null if no such prefix exists. | ||
* For example: "ab*cd" has prefix "ab" and "*cd" has prefix null. | ||
*/ | ||
@Nullable | ||
String getPrefix(); | ||
|
||
/** | ||
* Returns the constant suffix shared by all results matching this condition, or null if no such suffix exists. | ||
* For example: "ab*cd" has suffix "cd" and "ab*" has suffix null. | ||
*/ | ||
@Nullable | ||
String getSuffix(); | ||
|
||
/** | ||
* Returns true if the condition contains any wildcards, false if it is a constant. | ||
*/ | ||
boolean hasWildcards(); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Just a thought about the subset permission - even though A is subset of A, do we have any reason to prevent creating a new role with the different name with the same permission(s)? One advantage in preventing that is we can reuse the existing roles instead of just growing with the duplicate roles with the same permissions. Also, why would a user with ApiKey with sor|* permissions create a new role with the same sor|* to hand over to the other teams?
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 that it opens the door for redundant roles, but I don't think it should be prohibited. For example, it may be that the new role today shares the same permissions, but by creating the new role it can be modified in the future without needing to be concerned about either unintended consequences of modifying the existing role or hunting down all users with the reused role and re-assigning their roles in the future.