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

Feature/query microservices #22

Merged
merged 19 commits into from May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
1524c51
Added newInstance method to ProxiedUserDetails interface
jwomeara Apr 8, 2023
e034f67
Updated ProxiedUserDetails to use dynamic type for newInstance method.
jwomeara May 8, 2023
9e8acba
Merge remote-tracking branch 'origin/feature/spring-boot-2.x-accumulo…
jwomeara May 24, 2023
09251b8
Merge remote-tracking branch 'origin/feature/spring-boot-2.x-accumulo…
jwomeara Jun 22, 2023
b674cf0
Merge branch 'feature/spring-boot-2.x-accumulo-2.1' into feature/quer…
jwomeara Jun 27, 2023
df256e5
Merge branch 'feature/spring-boot-2.x-accumulo-2.1' into feature/quer…
jwomeara Jun 28, 2023
28a38b3
bumped release version
jwomeara Sep 18, 2023
7906d61
Merge branch 'feature/spring-boot-2.x-accumulo-2.1' into feature/quer…
jwomeara Oct 5, 2023
5510567
bumped versions for some modules
jwomeara Oct 5, 2023
f6eed9b
Updated with latest changes from main/integration
jwomeara Oct 20, 2023
8254cb0
Merge remote-tracking branch 'origin/main' into feature/queryMicroser…
jwomeara Oct 25, 2023
dcd0638
Updated usage of cache inspector factory to use qualifier
jwomeara Nov 22, 2023
c8abc5e
Merge remote-tracking branch 'origin/main' into feature/queryMicroser…
jwomeara Jan 24, 2024
2d95b34
Implemented authorization and query federation for the query microser…
jwomeara Mar 18, 2024
0a641b4
Updated usage of remote user operations for query microservices
jwomeara Mar 19, 2024
3e8b33a
Moved the AuthorizationsPredicate class to authorization-api
jwomeara Mar 22, 2024
a5f4761
Merge remote-tracking branch 'origin/main' into feature/queryMicroser…
jwomeara Apr 2, 2024
5769bf2
PR feedback
jwomeara Apr 26, 2024
5c92e1b
PR feedback
jwomeara Apr 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 30 additions & 2 deletions api/pom.xml
Expand Up @@ -4,11 +4,11 @@
<parent>
<groupId>gov.nsa.datawave.microservice</groupId>
<artifactId>datawave-microservice-parent</artifactId>
<version>3.0.4</version>
<version>4.0.0-SNAPSHOT</version>
<relativePath>../../../microservice-parent/pom.xml</relativePath>
</parent>
<artifactId>authorization-api</artifactId>
<version>3.0.1-SNAPSHOT</version>
<version>4.0.0-SNAPSHOT</version>
<url>https://code.nsa.gov/datawave-authorization-service</url>
<scm>
<connection>scm:git:https://github.com/NationalSecurityAgency/datawave-authorization-service.git</connection>
Expand All @@ -18,6 +18,7 @@
</scm>
<properties>
<datawave.webservice.namespace>http://webservice.datawave.nsa/v1</datawave.webservice.namespace>
<version.accumulo>2.1.1</version.accumulo>
<version.guava>31.1-jre</version.guava>
<version.jackson>2.10.1</version.jackson>
<version.jaxb>2.3.3</version.jaxb>
Expand Down Expand Up @@ -46,6 +47,29 @@
<artifactId>jakarta.xml.bind-api</artifactId>
<version>${version.jaxb}</version>
</dependency>
<dependency>
<groupId>org.apache.accumulo</groupId>
<artifactId>accumulo-core</artifactId>
<version>${version.accumulo}</version>
<exclusions>
<exclusion>
<artifactId>guava</artifactId>
<groupId>com.google.guava</groupId>
</exclusion>
<exclusion>
<artifactId>hadoop-client</artifactId>
<groupId>org.apache.hadoop</groupId>
</exclusion>
<exclusion>
<artifactId>junit</artifactId>
<groupId>junit</groupId>
</exclusion>
<exclusion>
<artifactId>zookeeper</artifactId>
<groupId>org.apache.zookeeper</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
Expand Down Expand Up @@ -91,6 +115,10 @@
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.accumulo</groupId>
<artifactId>accumulo-core</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
Expand Down
@@ -0,0 +1,53 @@
package datawave.security.authorization.predicate;

import java.util.function.Predicate;

import org.apache.accumulo.core.security.Authorizations;
import org.apache.accumulo.core.security.ColumnVisibility;
import org.apache.accumulo.core.security.VisibilityEvaluator;
import org.apache.accumulo.core.security.VisibilityParseException;

/**
* This is a predicate that will test the auths against a specified visibility (as defined by accumulo's ColumnVisibility). In addition to the visibility, one
* can specify that only the first of the authorizations is matched (presumably the user).
*/
public class AuthorizationsPredicate implements Predicate<Authorizations> {

// A visibility string to be matched against the auths being used for the query
private ColumnVisibility visibility;

public AuthorizationsPredicate() {}

public AuthorizationsPredicate(String visibility) {
setVisibility(visibility);
}

@Override
public boolean test(Authorizations auths) {
// match the visibility against the auths.
ColumnVisibility vis = getVisibility();
VisibilityEvaluator ve = new VisibilityEvaluator(auths);
try {
return (ve.evaluate(vis));
} catch (VisibilityParseException e) {
throw new RuntimeException(e);
}
}

public ColumnVisibility getVisibility() {
return visibility;
}

public void setVisibility(ColumnVisibility visibility) {
this.visibility = visibility;
}

public void setVisibility(String visibility) {
setVisibility(new ColumnVisibility(visibility));
}

@Override
public String toString() {
return "(auths =~ " + visibility + ')';
}
}
4 changes: 2 additions & 2 deletions pom.xml
Expand Up @@ -4,11 +4,11 @@
<parent>
<groupId>gov.nsa.datawave.microservice</groupId>
<artifactId>datawave-microservice-parent</artifactId>
<version>3.0.4</version>
<version>4.0.0-SNAPSHOT</version>
<relativePath>../../microservice-parent/pom.xml</relativePath>
</parent>
<artifactId>authorization-service-parent</artifactId>
<version>3.0.1-SNAPSHOT</version>
<version>4.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<url>https://code.nsa.gov/datawave-authorization-service</url>
<modules>
Expand Down
10 changes: 5 additions & 5 deletions service/pom.xml
Expand Up @@ -4,11 +4,11 @@
<parent>
<groupId>gov.nsa.datawave.microservice</groupId>
<artifactId>datawave-microservice-service-parent</artifactId>
<version>4.0.4</version>
<version>5.0.0-SNAPSHOT</version>
<relativePath>../../../microservice-service-parent/pom.xml</relativePath>
</parent>
<artifactId>authorization-service</artifactId>
<version>3.0.1-SNAPSHOT</version>
<version>4.0.0-SNAPSHOT</version>
<description>DATAWAVE Authorization Microservice</description>
<url>https://code.nsa.gov/datawave-authorization-service</url>
<scm>
Expand All @@ -19,10 +19,10 @@
</scm>
<properties>
<start-class>datawave.microservice.authorization.AuthorizationService</start-class>
<version.authorization-api>3.0.0</version.authorization-api>
<version.authorization-api>4.0.0-SNAPSHOT</version.authorization-api>
<version.jaxb>2.3.3</version.jaxb>
<version.microservice.hazelcast-client>3.0.0</version.microservice.hazelcast-client>
<version.microservice.starter>3.0.0</version.microservice.starter>
<version.microservice.hazelcast-client>4.0.0-SNAPSHOT</version.microservice.hazelcast-client>
<version.microservice.starter>4.0.0-SNAPSHOT</version.microservice.starter>
<version.zookeeper>3.8.0</version.zookeeper>
</properties>
<dependencyManagement>
Expand Down
Expand Up @@ -21,6 +21,7 @@
import datawave.security.authorization.DatawaveUser;
import datawave.security.authorization.DatawaveUserInfo;
import datawave.user.AuthorizationsListBase;
import datawave.webservice.result.GenericResponse;
import io.swagger.v3.oas.annotations.ExternalDocumentation;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
Expand Down Expand Up @@ -55,8 +56,21 @@ public String user(@AuthenticationPrincipal DatawaveUserDetails currentUser) {
@Operation(summary = "Lists the effective Accumulo user authorizations for the calling user.")
@RequestMapping(path = "/listEffectiveAuthorizations", method = RequestMethod.GET, produces = {MediaType.APPLICATION_JSON_VALUE,
MediaType.APPLICATION_XML_VALUE, MediaType.TEXT_XML_VALUE, PROTOSTUFF_VALUE, MediaType.TEXT_HTML_VALUE, "text/x-yaml", "application/x-yaml"})
public AuthorizationsListBase<?> listEffectiveAuthorizations(@AuthenticationPrincipal DatawaveUserDetails currentUser) {
return authOperations.listEffectiveAuthorizations(currentUser);
public AuthorizationsListBase<?> listEffectiveAuthorizations(
@Parameter(description = "Whether the request should be federated to downstream services.") @RequestParam(
name = "includeRemoteServices") boolean federate,
@AuthenticationPrincipal DatawaveUserDetails currentUser) {
return authOperations.listEffectiveAuthorizations(currentUser, federate);
}

@Operation(summary = "Clears any cached credentials for the calling user.")
@RequestMapping(path = "/flushCachedCredentials", method = RequestMethod.GET, produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE,
MediaType.TEXT_XML_VALUE, PROTOSTUFF_VALUE, MediaType.TEXT_HTML_VALUE, "text/x-yaml", "application/x-yaml"})
public GenericResponse<String> flushCachedCredentials(
@Parameter(description = "Whether the request should be federated to downstream services.") @RequestParam(
name = "includeRemoteServices") boolean federate,
@AuthenticationPrincipal DatawaveUserDetails currentUser) {
return authOperations.flushCachedCredentials(currentUser, federate);
}

/**
Expand Down
Expand Up @@ -21,6 +21,7 @@
import datawave.security.authorization.DatawaveUser;
import datawave.security.authorization.DatawaveUserInfo;
import datawave.user.AuthorizationsListBase;
import datawave.webservice.result.GenericResponse;
import io.swagger.v3.oas.annotations.ExternalDocumentation;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
Expand Down Expand Up @@ -55,8 +56,21 @@ public String user(@AuthenticationPrincipal DatawaveUserDetails currentUser) {
@Operation(summary = "Lists the effective Accumulo user authorizations for the calling user.")
@RequestMapping(path = "/listEffectiveAuthorizations", method = RequestMethod.GET, produces = {MediaType.APPLICATION_JSON_VALUE,
MediaType.APPLICATION_XML_VALUE, MediaType.TEXT_XML_VALUE, PROTOSTUFF_VALUE, MediaType.TEXT_HTML_VALUE, "text/x-yaml", "application/x-yaml"})
public AuthorizationsListBase<?> listEffectiveAuthorizations(@AuthenticationPrincipal DatawaveUserDetails currentUser) {
return authOperations.listEffectiveAuthorizations(currentUser);
public AuthorizationsListBase<?> listEffectiveAuthorizations(
@Parameter(description = "Whether the request should be federated to downstream services.") @RequestParam(
name = "includeRemoteServices") boolean federate,
@AuthenticationPrincipal DatawaveUserDetails currentUser) {
return authOperations.listEffectiveAuthorizations(currentUser, federate);
}

@Operation(summary = "Clears any cached credentials for the calling user.")
@RequestMapping(path = "/flushCachedCredentials", method = RequestMethod.GET, produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE,
MediaType.TEXT_XML_VALUE, PROTOSTUFF_VALUE, MediaType.TEXT_HTML_VALUE, "text/x-yaml", "application/x-yaml"})
public GenericResponse<String> flushCachedCredentials(
@Parameter(description = "Whether the request should be federated to downstream services.") @RequestParam(
name = "includeRemoteServices") boolean federate,
@AuthenticationPrincipal DatawaveUserDetails currentUser) {
return authOperations.flushCachedCredentials(currentUser, federate);
}

/**
Expand Down