Skip to content
Snippets Groups Projects
Commit 415d1994 authored by MIchael Nguyen's avatar MIchael Nguyen
Browse files

merge conflicts

parents 5fdd34ea d6afaf77
No related branches found
No related tags found
1 merge request!6Trusted ibm
Showing
with 94 additions and 26 deletions
File moved
File moved
......@@ -5,14 +5,13 @@
<parent>
<groupId>org.opengroup.osdu.indexer</groupId>
<artifactId>indexer-service</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
<version>1.0.0</version>
</parent>
<artifactId>indexer-service-root</artifactId>
<version>1.0-SNAPSHOT</version>
<name>indexer-service-root</name>
<description>Indexer Service Root</description>
<artifactId>indexer-core</artifactId>
<version>1.0.0</version>
<name>indexer-core</name>
<description>Indexer Service Core</description>
<packaging>jar</packaging>
<!--<repositories>
......@@ -69,8 +68,7 @@
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>indexer-search-core-lib</artifactId>
<version>1.0.9</version>
<scope>compile</scope>
<version>1.0.10</version>
</dependency>
<dependency>
......@@ -200,6 +198,7 @@
</dependency>
</dependencies>
<<<<<<< HEAD:indexer-service-root/pom.xml
<build>
<plugins>
<plugin>
......@@ -219,4 +218,20 @@
</plugin>
</plugins>
</build>
=======
<build>
<defaultGoal>test</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4.2</version>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
<threadCount>1</threadCount>
</configuration>
</plugin>
</plugins>
</build>
>>>>>>> d6afaf7791e4fc3cdfe05a7f42e7c4215bda5aef:indexer-core/pom.xml
</project>
......@@ -27,14 +27,14 @@ import javax.annotation.security.PermitAll;
@Log
@RestController
@RequestMapping("/_ah")
@RequestMapping("/")
@RequestScope
public class HealthCheckApi {
@PermitAll
@GetMapping("/liveness_check")
public ResponseEntity<String> livenessCheck(){
return new ResponseEntity<String>("Indexer service is alive", org.springframework.http.HttpStatus.OK);
return new ResponseEntity<String>("Indexer service is alive", HttpStatus.OK);
}
@PermitAll
......
......@@ -30,11 +30,11 @@ import org.opengroup.osdu.indexer.util.RecordInfo;
import org.opengroup.osdu.is.core.model.RecordChangedMessages;
import org.opengroup.osdu.is.core.util.AppException;
import org.springframework.http.HttpStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.annotation.RequestScope;
import javax.inject.Inject;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.lang.reflect.Type;
......@@ -46,9 +46,9 @@ import java.util.List;
@RequestScope
public class RecordIndexerApi {
@Autowired
@Inject
private IndexerService indexerService;
@Autowired
@Inject
private ReindexService reIndexService;
// THIS IS AN INTERNAL USE API ONLY
......
......@@ -14,16 +14,10 @@
package org.opengroup.osdu.indexer.api;
import io.swagger.annotations.*;
import org.opengroup.osdu.indexer.SwaggerDoc;
import org.opengroup.osdu.indexer.logging.AuditLogger;
import org.opengroup.osdu.indexer.model.RecordReindexRequest;
import org.opengroup.osdu.indexer.service.ReindexService;
import org.opengroup.osdu.core.api.DpsHeaders;
import org.opengroup.osdu.core.multitenancy.TenantInfo;
import org.opengroup.osdu.is.core.model.SearchServiceRole;
import org.opengroup.osdu.is.core.util.AppError;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
......@@ -32,51 +26,26 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.annotation.RequestScope;
import javax.annotation.security.RolesAllowed;
import javax.inject.Inject;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import static java.util.Collections.singletonList;
@Api(
value = SwaggerDoc.INDEXER_TAG,
authorizations = {@Authorization(value = SwaggerDoc.BEARER_AUTH),
@Authorization(value = SwaggerDoc.GOOGLE_ID_AUTH),
@Authorization(value = SwaggerDoc.SAUTH_ID_AUTH)})
@RestController
@RequestMapping("/reindex")
@ApiImplicitParams({
@ApiImplicitParam(name = DpsHeaders.ACCOUNT_ID, value = SwaggerDoc.PARAMETER_ACCOUNT_ID, required = true, defaultValue = TenantInfo.COMMON, dataType = "string", paramType = "header"),
@ApiImplicitParam(name = DpsHeaders.ON_BEHALF_OF, value = SwaggerDoc.PARAMETER_ONBEHALF_ACCOUNT_ID, dataType = "string", paramType = "header")})
@RequestScope
public class ReindexApi {
@Autowired
@Inject
private ReindexService reIndexService;
@Autowired
@Inject
private AuditLogger auditLogger;
// @PreAuthorize("@authorizationFilter.hasPermission('" + SearchServiceRole.ADMIN + "')")
@PreAuthorize("@authorizationFilter.hasPermission('" + SearchServiceRole.ADMIN + "')")
@PostMapping
@ApiOperation(
value = SwaggerDoc.REINDEX_POST_TITLE,
nickname = SwaggerDoc.REINDEX_OPERATION_ID,
notes = SwaggerDoc.REINDEX_POST_NOTES)
@ApiResponses({
@ApiResponse(
code = org.apache.http.HttpStatus.SC_OK,
message = SwaggerDoc.REINDEX_POST_RESPONSE_OK,
response = String.class),
@ApiResponse(
code = org.apache.http.HttpStatus.SC_BAD_REQUEST,
message = SwaggerDoc.REINDEX_POST_RESPONSE_BAD_REQUEST,
response = AppError.class),
@ApiResponse(
code = org.apache.http.HttpStatus.SC_NOT_FOUND,
message = SwaggerDoc.REINDEX_POST_RESPONSE_NOT_FOUND,
response = AppError.class)})
public ResponseEntity reindex(
@NotNull(message = SwaggerDoc.REQUEST_VALIDATION_NOT_NULL_BODY)
@Valid @RequestBody RecordReindexRequest recordReindexRequest) {
@NotNull @Valid @RequestBody RecordReindexRequest recordReindexRequest) {
this.reIndexService.reindexRecords(recordReindexRequest);
this.auditLogger.getReindex(singletonList(recordReindexRequest.getKind()));
return new ResponseEntity (org.springframework.http.HttpStatus.OK);
......
......@@ -14,6 +14,7 @@
package org.opengroup.osdu.indexer.auth;
import lombok.extern.java.Log;
import org.opengroup.osdu.core.api.DpsHeaders;
import org.opengroup.osdu.core.api.entitlements.EntitlementsException;
import org.opengroup.osdu.core.api.entitlements.IEntitlementsFactory;
......@@ -26,11 +27,11 @@ import org.opengroup.osdu.is.core.model.AuthorizationResponse;
import org.opengroup.osdu.is.core.provider.interfaces.auth.AuthorizationService;
import org.opengroup.osdu.is.core.util.AppException;
import org.opengroup.osdu.is.core.util.HeadersUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.web.context.annotation.RequestScope;
import javax.inject.Inject;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
......@@ -41,11 +42,11 @@ public class AuthorizationServiceEntitlements implements AuthorizationService {
private static final String TENANT_GROUP_FORMAT = "@%s";
@Autowired
@Inject
private IEntitlementsFactory factory;
@Autowired
@Inject
@Lazy
private JaxRsDpsLog log;
private JaxRsDpsLog jaxRsDpsLog;
@Override
public AuthorizationResponse authorizeAny(DpsHeaders headers, String... roles) {
......@@ -96,8 +97,8 @@ public class AuthorizationServiceEntitlements implements AuthorizationService {
return AuthorizationResponse.builder().user(userEmail).groups(groups).build();
}
}
log.info(String.join(" | ", logMessages));
log.info(HeadersUtil.toLogMsg(headers, userEmail));
jaxRsDpsLog.info(String.join(" | ", logMessages));
jaxRsDpsLog.info(HeadersUtil.toLogMsg(headers, userEmail));
throw AppException.createUnauthorized("required search service roles are missing for user");
}
......
......@@ -17,19 +17,19 @@ package org.opengroup.osdu.indexer.logging;
import org.opengroup.osdu.core.logging.payload.AuditPayload;
import org.opengroup.osdu.is.core.logging.JaxRsDpsLog;
import org.opengroup.osdu.is.core.provider.interfaces.util.IHeadersInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.context.annotation.RequestScope;
import javax.inject.Inject;
import java.util.List;
@Component
@RequestScope
public class AuditLogger {
@Autowired
@Inject
private JaxRsDpsLog logger;
@Autowired
@Inject
private IHeadersInfo headers;
private AuditEvents events = null;
......
......@@ -5,27 +5,26 @@ import lombok.extern.java.Log;
import org.opengroup.osdu.core.api.DpsHeaders;
import org.opengroup.osdu.is.core.model.AuthorizationResponse;
import org.opengroup.osdu.is.core.provider.interfaces.auth.AuthorizationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.context.annotation.RequestScope;
import javax.inject.Inject;
@Log
@Component("authorizationFilter")
@RequestScope
public class AuthorizationFilter {
@Autowired
@Inject
private AuthorizationService authorizationService;
private DpsHeaders headers;
@Autowired
@Inject
AuthorizationFilter(DpsHeaders headers) {
this.headers = headers;
}
public boolean hasPermission(String... requiredRoles) {
log.info("IN AUTH FILTER.....");
AuthorizationResponse authResponse = authorizationService.authorizeAny(headers, requiredRoles);
headers.put(DpsHeaders.USER_EMAIL, authResponse.getUser());
return true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment