forked from opensearch-project/security
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show rudimentary resource authz impl
Signed-off-by: Craig Perkins <[email protected]>
- Loading branch information
Showing
15 changed files
with
474 additions
and
11 deletions.
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
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
10 changes: 10 additions & 0 deletions
10
spi/src/main/java/org/opensearch/security/spi/ResourceRequest.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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.opensearch.security.spi; | ||
|
||
/** | ||
* A ResourceRequest is a subtype of ActionRequest that pertains to resource. | ||
*/ | ||
public interface ResourceRequest { | ||
String getResourceId(); | ||
|
||
String getResourceIndex(); | ||
} |
61 changes: 61 additions & 0 deletions
61
spi/src/main/java/org/opensearch/security/spi/ResourceSharingInfo.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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package org.opensearch.security.spi; | ||
|
||
import java.io.IOException; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import org.opensearch.core.ParseField; | ||
import org.opensearch.core.xcontent.ConstructingObjectParser; | ||
import org.opensearch.core.xcontent.XContentParser; | ||
|
||
/** | ||
* ResourceSharingInfo is a subset of the fields in a SharableResource document that correspond to the owner | ||
* of the SharableResource (the resource_user) and a list of ShareWith data structures that corresponding | ||
* to who (individuals or groups) the resource has been shared with and at what access level | ||
*/ | ||
public class ResourceSharingInfo { | ||
private final ResourceUser resourceUser; | ||
private final List<ShareWith> shareWith; | ||
|
||
public ResourceSharingInfo(ResourceUser resourceUser) { | ||
this.resourceUser = resourceUser; | ||
this.shareWith = Collections.emptyList(); | ||
} | ||
|
||
public ResourceSharingInfo(ResourceUser resourceUser, List<ShareWith> shareWith) { | ||
this.resourceUser = resourceUser; | ||
this.shareWith = shareWith; | ||
} | ||
|
||
public ResourceUser getResourceUser() { | ||
return resourceUser; | ||
} | ||
|
||
public List<ShareWith> getShareWith() { | ||
return shareWith; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
private static final ConstructingObjectParser<ResourceSharingInfo, Void> PARSER = new ConstructingObjectParser<>( | ||
"resource_sharing_info", | ||
true, | ||
a -> new ResourceSharingInfo((ResourceUser) a[0], (List<ShareWith>) a[1]) | ||
); | ||
|
||
static { | ||
PARSER.declareObject( | ||
ConstructingObjectParser.constructorArg(), | ||
(p, c) -> ResourceUser.fromXContent(p), | ||
new ParseField("resource_user") | ||
); | ||
PARSER.declareObjectArray( | ||
ConstructingObjectParser.optionalConstructorArg(), | ||
(p, c) -> ShareWith.fromXContent(p), | ||
new ParseField("share_with") | ||
); | ||
} | ||
|
||
public static ResourceSharingInfo parse(XContentParser parser) throws IOException { | ||
return PARSER.parse(parser, null); | ||
} | ||
} |
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
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
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
Oops, something went wrong.