Skip to content
Snippets Groups Projects
Commit 35e69074 authored by Martin Weise's avatar Martin Weise
Browse files

Hotfix secrets 2

parent 42fdf99d
No related branches found
No related tags found
2 merge requests!302Dev,!301Hotfix secrets 2
Showing
with 190 additions and 201 deletions
...@@ -27,11 +27,8 @@ public class S3Config { ...@@ -27,11 +27,8 @@ public class S3Config {
@Value("${dbrepo.s3.secretAccessKey}") @Value("${dbrepo.s3.secretAccessKey}")
private String s3SecretAccessKey; private String s3SecretAccessKey;
@Value("${dbrepo.s3.importBucket}") @Value("${dbrepo.s3.bucket}")
private String s3ImportBucket; private String s3Bucket;
@Value("${dbrepo.s3.exportBucket}")
private String s3ExportBucket;
@Bean @Bean
public S3Client s3client() { public S3Client s3client() {
......
...@@ -23,14 +23,15 @@ public interface KeycloakGateway { ...@@ -23,14 +23,15 @@ public interface KeycloakGateway {
* @throws UserExistsException The user already exists at the Authentication Service. * @throws UserExistsException The user already exists at the Authentication Service.
* @throws EmailExistsException The user email already exists in the metadata database. * @throws EmailExistsException The user email already exists in the metadata database.
*/ */
void createUser(UserCreateDto data) throws AuthServiceException, AuthServiceConnectionException, EmailExistsException, UserExistsException, CredentialsInvalidException; void createUser(UserCreateDto data) throws AuthServiceException, AuthServiceConnectionException,
EmailExistsException, UserExistsException;
/** /**
* Deletes a user at the Authentication Service with given user id. * Deletes a user at the Authentication Service with given user id.
* *
* @param id The user id. * @param id The user id.
*/ */
void deleteUser(UUID id) throws AuthServiceException, AuthServiceConnectionException, UserNotFoundException, CredentialsInvalidException; void deleteUser(UUID id) throws AuthServiceException, AuthServiceConnectionException, UserNotFoundException;
/** /**
* Update the credentials for a given user. * Update the credentials for a given user.
...@@ -38,7 +39,8 @@ public interface KeycloakGateway { ...@@ -38,7 +39,8 @@ public interface KeycloakGateway {
* @param id The user id. * @param id The user id.
* @param password The user credential. * @param password The user credential.
*/ */
void updateUserCredentials(UUID id, UserPasswordDto password) throws AuthServiceException, AuthServiceConnectionException, CredentialsInvalidException; void updateUserCredentials(UUID id, UserPasswordDto password) throws AuthServiceException,
AuthServiceConnectionException;
/** /**
* Finds a user in the metadata database by given username. * Finds a user in the metadata database by given username.
...@@ -46,8 +48,8 @@ public interface KeycloakGateway { ...@@ -46,8 +48,8 @@ public interface KeycloakGateway {
* @param username The user username. * @param username The user username.
* @return The updated user. * @return The updated user.
*/ */
UserDto findByUsername(String username) throws AuthServiceException, AuthServiceConnectionException, UserNotFoundException, CredentialsInvalidException; UserDto findByUsername(String username) throws AuthServiceException, AuthServiceConnectionException,
UserNotFoundException;
UserDto findById(UUID id) throws AuthServiceException, AuthServiceConnectionException, UserDto findById(UUID id) throws AuthServiceException, AuthServiceConnectionException, UserNotFoundException;
UserNotFoundException, CredentialsInvalidException;
} }
...@@ -2,12 +2,14 @@ package at.tuwien.gateway.impl; ...@@ -2,12 +2,14 @@ package at.tuwien.gateway.impl;
import at.tuwien.gateway.ApiTemplateInterceptor; import at.tuwien.gateway.ApiTemplateInterceptor;
import org.springframework.http.HttpRequest; import org.springframework.http.HttpRequest;
import org.springframework.http.MediaType;
import org.springframework.http.client.ClientHttpRequestExecution; import org.springframework.http.client.ClientHttpRequestExecution;
import org.springframework.http.client.ClientHttpRequestInterceptor; import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.http.client.ClientHttpResponse; import org.springframework.http.client.ClientHttpResponse;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.IOException; import java.io.IOException;
import java.util.List;
@Service @Service
public class ApiTemplateInterceptorImpl implements ApiTemplateInterceptor, ClientHttpRequestInterceptor { public class ApiTemplateInterceptorImpl implements ApiTemplateInterceptor, ClientHttpRequestInterceptor {
...@@ -15,8 +17,8 @@ public class ApiTemplateInterceptorImpl implements ApiTemplateInterceptor, Clien ...@@ -15,8 +17,8 @@ public class ApiTemplateInterceptorImpl implements ApiTemplateInterceptor, Clien
@Override @Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)
throws IOException { throws IOException {
request.getHeaders().set("Content-Type", "application/json"); request.getHeaders().setAccept(List.of(MediaType.APPLICATION_JSON));
request.getHeaders().set("Accept", "application/json"); request.getHeaders().setContentType(MediaType.APPLICATION_JSON);
return execution.execute(request, body); return execution.execute(request, body);
} }
} }
...@@ -31,10 +31,11 @@ public class BrokerServiceGatewayImpl implements BrokerServiceGateway { ...@@ -31,10 +31,11 @@ public class BrokerServiceGatewayImpl implements BrokerServiceGateway {
@Override @Override
public void grantTopicPermission(String username, ExchangeUpdatePermissionsDto data) public void grantTopicPermission(String username, ExchangeUpdatePermissionsDto data)
throws BrokerServiceConnectionException, BrokerServiceException { throws BrokerServiceConnectionException, BrokerServiceException {
final String url = "/api/topic-permissions/" + rabbitConfig.getVirtualHost() + "/" + username; final String path = "/api/topic-permissions/" + rabbitConfig.getVirtualHost() + "/" + username;
log.trace("grant topic permission at endpoint {} with path {}", rabbitConfig.getBrokerEndpoint(), path);
final ResponseEntity<Void> response; final ResponseEntity<Void> response;
try { try {
response = restTemplate.exchange(url, HttpMethod.PUT, new HttpEntity<>(data), Void.class); response = restTemplate.exchange(path, HttpMethod.PUT, new HttpEntity<>(data), Void.class);
} catch (HttpServerErrorException e) { } catch (HttpServerErrorException e) {
log.error("Failed to grant topic permissions: {}", e.getMessage()); log.error("Failed to grant topic permissions: {}", e.getMessage());
throw new BrokerServiceConnectionException("Failed to grant topic permissions: " + e.getMessage()); throw new BrokerServiceConnectionException("Failed to grant topic permissions: " + e.getMessage());
...@@ -51,10 +52,11 @@ public class BrokerServiceGatewayImpl implements BrokerServiceGateway { ...@@ -51,10 +52,11 @@ public class BrokerServiceGatewayImpl implements BrokerServiceGateway {
@Override @Override
public void grantVirtualHostPermission(String username, GrantVirtualHostPermissionsDto data) public void grantVirtualHostPermission(String username, GrantVirtualHostPermissionsDto data)
throws BrokerServiceConnectionException, BrokerServiceException { throws BrokerServiceConnectionException, BrokerServiceException {
final String url = "/api/permissions/" + rabbitConfig.getVirtualHost() + "/" + username; final String path = "/api/permissions/" + rabbitConfig.getVirtualHost() + "/" + username;
log.trace("grant virtual host permission at endpoint {} with path {}", rabbitConfig.getBrokerEndpoint(), path);
final ResponseEntity<Void> response; final ResponseEntity<Void> response;
try { try {
response = restTemplate.exchange(url, HttpMethod.PUT, new HttpEntity<>(data), Void.class); response = restTemplate.exchange(path, HttpMethod.PUT, new HttpEntity<>(data), Void.class);
} catch (HttpServerErrorException e) { } catch (HttpServerErrorException e) {
log.error("Failed to grant virtual host permissions: {}", e.getMessage()); log.error("Failed to grant virtual host permissions: {}", e.getMessage());
throw new BrokerServiceConnectionException("Failed to grant virtual host permissions: " + e.getMessage()); throw new BrokerServiceConnectionException("Failed to grant virtual host permissions: " + e.getMessage());
...@@ -71,10 +73,11 @@ public class BrokerServiceGatewayImpl implements BrokerServiceGateway { ...@@ -71,10 +73,11 @@ public class BrokerServiceGatewayImpl implements BrokerServiceGateway {
@Override @Override
public void grantExchangePermission(String username, GrantExchangePermissionsDto data) public void grantExchangePermission(String username, GrantExchangePermissionsDto data)
throws BrokerServiceConnectionException, BrokerServiceException { throws BrokerServiceConnectionException, BrokerServiceException {
final String url = "/api/topic-permissions/" + rabbitConfig.getVirtualHost() + "/" + username; final String path = "/api/topic-permissions/" + rabbitConfig.getVirtualHost() + "/" + username;
log.trace("grant exchange permission at endpoint {} with path {}", rabbitConfig.getBrokerEndpoint(), path);
final ResponseEntity<Void> response; final ResponseEntity<Void> response;
try { try {
response = restTemplate.exchange(url, HttpMethod.PUT, new HttpEntity<>(data), Void.class); response = restTemplate.exchange(path, HttpMethod.PUT, new HttpEntity<>(data), Void.class);
} catch (HttpServerErrorException e) { } catch (HttpServerErrorException e) {
log.error("Failed to grant exchange permissions: {}", e.getMessage()); log.error("Failed to grant exchange permissions: {}", e.getMessage());
throw new BrokerServiceConnectionException("Failed to grant exchange permissions: " + e.getMessage()); throw new BrokerServiceConnectionException("Failed to grant exchange permissions: " + e.getMessage());
......
package at.tuwien.gateway.impl; package at.tuwien.gateway.impl;
import at.tuwien.api.crossref.CrossrefDto; import at.tuwien.api.crossref.CrossrefDto;
import at.tuwien.config.GatewayConfig;
import at.tuwien.exception.DoiNotFoundException; import at.tuwien.exception.DoiNotFoundException;
import at.tuwien.gateway.CrossrefGateway; import at.tuwien.gateway.CrossrefGateway;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
...@@ -19,24 +20,24 @@ import org.springframework.web.client.RestTemplate; ...@@ -19,24 +20,24 @@ import org.springframework.web.client.RestTemplate;
public class CrossrefGatewayImpl implements CrossrefGateway { public class CrossrefGatewayImpl implements CrossrefGateway {
private final RestTemplate restTemplate; private final RestTemplate restTemplate;
private final GatewayConfig gatewayConfig;
@Autowired @Autowired
public CrossrefGatewayImpl(RestTemplate restTemplate) { public CrossrefGatewayImpl(RestTemplate restTemplate, GatewayConfig gatewayConfig) {
this.restTemplate = restTemplate; this.restTemplate = restTemplate;
this.gatewayConfig = gatewayConfig;
} }
@Override @Override
public CrossrefDto findById(String id) throws DoiNotFoundException { public CrossrefDto findById(String id) throws DoiNotFoundException {
final HttpHeaders headers = new HttpHeaders(); final String path = "/fundingdata/funder/" + id;
headers.set("Accept", "application/json"); log.trace("find crossref metadata by id from endpoint {} with path {}", gatewayConfig.getCrossRefEndpoint(), path);
final String url = "http://data.crossref.org/fundingdata/funder/" + id;
final ResponseEntity<CrossrefDto> response; final ResponseEntity<CrossrefDto> response;
try { try {
log.trace("find crossref doi from url {}", url); response = restTemplate.exchange(gatewayConfig.getCrossRefEndpoint() + path, HttpMethod.GET, HttpEntity.EMPTY, CrossrefDto.class);
response = restTemplate.exchange(url, HttpMethod.GET, new HttpEntity<>(null, headers), CrossrefDto.class);
} catch (HttpServerErrorException e) { } catch (HttpServerErrorException e) {
log.error("Failed to retrieve CrossRef metadata from URL {}: {}", url, e.getMessage()); log.error("Failed to retrieve crossref metadata: {}", e.getMessage());
throw new DoiNotFoundException("Failed to retrieve CrossRef metadata from URL " + url + ": " + e.getMessage()); throw new DoiNotFoundException("Failed to retrieve crossref metadata: " + e.getMessage());
} }
return response.getBody(); return response.getBody();
} }
......
...@@ -8,6 +8,7 @@ import at.tuwien.api.database.table.TableCreateDto; ...@@ -8,6 +8,7 @@ import at.tuwien.api.database.table.TableCreateDto;
import at.tuwien.api.database.table.TableDto; import at.tuwien.api.database.table.TableDto;
import at.tuwien.api.database.table.TableStatisticDto; import at.tuwien.api.database.table.TableStatisticDto;
import at.tuwien.api.user.internal.UpdateUserPasswordDto; import at.tuwien.api.user.internal.UpdateUserPasswordDto;
import at.tuwien.config.GatewayConfig;
import at.tuwien.exception.*; import at.tuwien.exception.*;
import at.tuwien.gateway.DataServiceGateway; import at.tuwien.gateway.DataServiceGateway;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
...@@ -27,18 +28,22 @@ import java.util.UUID; ...@@ -27,18 +28,22 @@ import java.util.UUID;
public class DataServiceGatewayImpl implements DataServiceGateway { public class DataServiceGatewayImpl implements DataServiceGateway {
private final RestTemplate restTemplate; private final RestTemplate restTemplate;
private final GatewayConfig gatewayConfig;
public DataServiceGatewayImpl(@Qualifier("dataServiceRestTemplate") RestTemplate restTemplate) { public DataServiceGatewayImpl(@Qualifier("dataServiceRestTemplate") RestTemplate restTemplate,
GatewayConfig gatewayConfig) {
this.restTemplate = restTemplate; this.restTemplate = restTemplate;
this.gatewayConfig = gatewayConfig;
} }
@Override @Override
public void createAccess(Long databaseId, UUID userId, AccessTypeDto access) public void createAccess(Long databaseId, UUID userId, AccessTypeDto access)
throws DataServiceConnectionException, DataServiceException, DatabaseNotFoundException { throws DataServiceConnectionException, DataServiceException, DatabaseNotFoundException {
final ResponseEntity<Void> response; final ResponseEntity<Void> response;
final String url = "/api/database/" + databaseId + "/access/" + userId; final String path = "/api/database/" + databaseId + "/access/" + userId;
log.trace("create access at endpoint {} with path {}", gatewayConfig.getDataEndpoint(), path);
try { try {
response = restTemplate.exchange(url, HttpMethod.POST, response = restTemplate.exchange(path, HttpMethod.POST,
new HttpEntity<>(UpdateDatabaseAccessDto.builder().type(access).build()), Void.class); new HttpEntity<>(UpdateDatabaseAccessDto.builder().type(access).build()), Void.class);
} catch (HttpServerErrorException e) { } catch (HttpServerErrorException e) {
log.error("Failed to create access: {}", e.getMessage()); log.error("Failed to create access: {}", e.getMessage());
...@@ -60,9 +65,10 @@ public class DataServiceGatewayImpl implements DataServiceGateway { ...@@ -60,9 +65,10 @@ public class DataServiceGatewayImpl implements DataServiceGateway {
public void updateAccess(Long databaseId, UUID userId, AccessTypeDto access) public void updateAccess(Long databaseId, UUID userId, AccessTypeDto access)
throws DataServiceConnectionException, DataServiceException, AccessNotFoundException { throws DataServiceConnectionException, DataServiceException, AccessNotFoundException {
final ResponseEntity<Void> response; final ResponseEntity<Void> response;
final String url = "/api/database/" + databaseId + "/access/" + userId; final String path = "/api/database/" + databaseId + "/access/" + userId;
log.trace("update access at endpoint {} with path {}", gatewayConfig.getDataEndpoint(), path);
try { try {
response = restTemplate.exchange(url, HttpMethod.PUT, response = restTemplate.exchange(path, HttpMethod.PUT,
new HttpEntity<>(UpdateDatabaseAccessDto.builder().type(access).build()), Void.class); new HttpEntity<>(UpdateDatabaseAccessDto.builder().type(access).build()), Void.class);
} catch (HttpServerErrorException e) { } catch (HttpServerErrorException e) {
log.error("Failed to update access: {}", e.getMessage()); log.error("Failed to update access: {}", e.getMessage());
...@@ -84,9 +90,10 @@ public class DataServiceGatewayImpl implements DataServiceGateway { ...@@ -84,9 +90,10 @@ public class DataServiceGatewayImpl implements DataServiceGateway {
public void deleteAccess(Long databaseId, UUID userId) throws DataServiceConnectionException, DataServiceException, public void deleteAccess(Long databaseId, UUID userId) throws DataServiceConnectionException, DataServiceException,
AccessNotFoundException { AccessNotFoundException {
final ResponseEntity<Void> response; final ResponseEntity<Void> response;
final String url = "/api/database/" + databaseId + "/access/" + userId; final String path = "/api/database/" + databaseId + "/access/" + userId;
log.trace("delete access at endpoint {} with path {}", gatewayConfig.getDataEndpoint(), path);
try { try {
response = restTemplate.exchange(url, HttpMethod.DELETE, HttpEntity.EMPTY, Void.class); response = restTemplate.exchange(path, HttpMethod.DELETE, HttpEntity.EMPTY, Void.class);
} catch (HttpServerErrorException e) { } catch (HttpServerErrorException e) {
log.error("Failed to delete access: {}", e.getMessage()); log.error("Failed to delete access: {}", e.getMessage());
throw new DataServiceConnectionException("Failed to delete access: " + e.getMessage(), e); throw new DataServiceConnectionException("Failed to delete access: " + e.getMessage(), e);
...@@ -107,9 +114,10 @@ public class DataServiceGatewayImpl implements DataServiceGateway { ...@@ -107,9 +114,10 @@ public class DataServiceGatewayImpl implements DataServiceGateway {
public DatabaseDto createDatabase(CreateDatabaseDto data) throws DataServiceConnectionException, public DatabaseDto createDatabase(CreateDatabaseDto data) throws DataServiceConnectionException,
DataServiceException, DatabaseNotFoundException { DataServiceException, DatabaseNotFoundException {
final ResponseEntity<DatabaseDto> response; final ResponseEntity<DatabaseDto> response;
final String url = "/api/database"; final String path = "/api/database";
log.trace("create database at endpoint {} with path {}", gatewayConfig.getDataEndpoint(), path);
try { try {
response = restTemplate.exchange(url, HttpMethod.POST, new HttpEntity<>(data), DatabaseDto.class); response = restTemplate.exchange(path, HttpMethod.POST, new HttpEntity<>(data), DatabaseDto.class);
} catch (HttpServerErrorException e) { } catch (HttpServerErrorException e) {
log.error("Failed to create database: {}", e.getMessage()); log.error("Failed to create database: {}", e.getMessage());
throw new DataServiceConnectionException("Failed to create database: " + e.getMessage(), e); throw new DataServiceConnectionException("Failed to create database: " + e.getMessage(), e);
...@@ -131,9 +139,10 @@ public class DataServiceGatewayImpl implements DataServiceGateway { ...@@ -131,9 +139,10 @@ public class DataServiceGatewayImpl implements DataServiceGateway {
public void updateDatabase(Long databaseId, UpdateUserPasswordDto data) throws DataServiceConnectionException, public void updateDatabase(Long databaseId, UpdateUserPasswordDto data) throws DataServiceConnectionException,
DataServiceException, DatabaseNotFoundException { DataServiceException, DatabaseNotFoundException {
final ResponseEntity<Void> response; final ResponseEntity<Void> response;
final String url = "/api/database/" + databaseId; final String path = "/api/database/" + databaseId;
log.trace("update database at endpoint {} with path {}", gatewayConfig.getDataEndpoint(), path);
try { try {
response = restTemplate.exchange(url, HttpMethod.PUT, new HttpEntity<>(data), Void.class); response = restTemplate.exchange(path, HttpMethod.PUT, new HttpEntity<>(data), Void.class);
} catch (HttpServerErrorException e) { } catch (HttpServerErrorException e) {
log.error("Failed to update user password in database: {}", e.getMessage()); log.error("Failed to update user password in database: {}", e.getMessage());
throw new DataServiceConnectionException("Failed to update user password in database: " + e.getMessage(), e); throw new DataServiceConnectionException("Failed to update user password in database: " + e.getMessage(), e);
...@@ -154,9 +163,10 @@ public class DataServiceGatewayImpl implements DataServiceGateway { ...@@ -154,9 +163,10 @@ public class DataServiceGatewayImpl implements DataServiceGateway {
public void createTable(Long databaseId, TableCreateDto data) throws DataServiceConnectionException, DataServiceException, public void createTable(Long databaseId, TableCreateDto data) throws DataServiceConnectionException, DataServiceException,
DatabaseNotFoundException, TableExistsException { DatabaseNotFoundException, TableExistsException {
final ResponseEntity<Void> response; final ResponseEntity<Void> response;
final String url = "/api/database/" + databaseId + "/table"; final String path = "/api/database/" + databaseId + "/table";
log.trace("create table at endpoint {} with path {}", gatewayConfig.getDataEndpoint(), path);
try { try {
response = restTemplate.exchange(url, HttpMethod.POST, new HttpEntity<>(data), Void.class); response = restTemplate.exchange(path, HttpMethod.POST, new HttpEntity<>(data), Void.class);
} catch (HttpServerErrorException e) { } catch (HttpServerErrorException e) {
log.error("Failed to create table: {}", e.getMessage()); log.error("Failed to create table: {}", e.getMessage());
throw new DataServiceConnectionException("Failed to create table: " + e.getMessage(), e); throw new DataServiceConnectionException("Failed to create table: " + e.getMessage(), e);
...@@ -180,9 +190,10 @@ public class DataServiceGatewayImpl implements DataServiceGateway { ...@@ -180,9 +190,10 @@ public class DataServiceGatewayImpl implements DataServiceGateway {
public void deleteTable(Long databaseId, Long tableId) throws DataServiceConnectionException, DataServiceException, public void deleteTable(Long databaseId, Long tableId) throws DataServiceConnectionException, DataServiceException,
TableNotFoundException { TableNotFoundException {
final ResponseEntity<Void> response; final ResponseEntity<Void> response;
final String url = "/api/database/" + databaseId + "/table/" + tableId; final String path = "/api/database/" + databaseId + "/table/" + tableId;
log.trace("delete table at endpoint {} with path {}", gatewayConfig.getDataEndpoint(), path);
try { try {
response = restTemplate.exchange(url, HttpMethod.DELETE, HttpEntity.EMPTY, Void.class); response = restTemplate.exchange(path, HttpMethod.DELETE, HttpEntity.EMPTY, Void.class);
} catch (HttpServerErrorException e) { } catch (HttpServerErrorException e) {
log.error("Failed to delete table: {}", e.getMessage()); log.error("Failed to delete table: {}", e.getMessage());
throw new DataServiceConnectionException("Failed to delete table: " + e.getMessage(), e); throw new DataServiceConnectionException("Failed to delete table: " + e.getMessage(), e);
...@@ -202,9 +213,10 @@ public class DataServiceGatewayImpl implements DataServiceGateway { ...@@ -202,9 +213,10 @@ public class DataServiceGatewayImpl implements DataServiceGateway {
@Override @Override
public ViewDto createView(Long databaseId, ViewCreateDto data) throws DataServiceConnectionException, DataServiceException { public ViewDto createView(Long databaseId, ViewCreateDto data) throws DataServiceConnectionException, DataServiceException {
final ResponseEntity<ViewDto> response; final ResponseEntity<ViewDto> response;
final String url = "/api/database/" + databaseId + "/view"; final String path = "/api/database/" + databaseId + "/view";
log.trace("delete table at endpoint {} with path {}", gatewayConfig.getDataEndpoint(), path);
try { try {
response = restTemplate.exchange(url, HttpMethod.POST, new HttpEntity<>(data), ViewDto.class); response = restTemplate.exchange(path, HttpMethod.POST, new HttpEntity<>(data), ViewDto.class);
} catch (HttpServerErrorException e) { } catch (HttpServerErrorException e) {
log.error("Failed to create view: {}", e.getMessage()); log.error("Failed to create view: {}", e.getMessage());
throw new DataServiceConnectionException("Failed to create view: " + e.getMessage(), e); throw new DataServiceConnectionException("Failed to create view: " + e.getMessage(), e);
...@@ -227,9 +239,10 @@ public class DataServiceGatewayImpl implements DataServiceGateway { ...@@ -227,9 +239,10 @@ public class DataServiceGatewayImpl implements DataServiceGateway {
public void deleteView(Long databaseId, Long viewId) throws DataServiceConnectionException, DataServiceException, public void deleteView(Long databaseId, Long viewId) throws DataServiceConnectionException, DataServiceException,
ViewNotFoundException { ViewNotFoundException {
final ResponseEntity<Void> response; final ResponseEntity<Void> response;
final String url = "/api/database/" + databaseId + "/view/" + viewId; final String path = "/api/database/" + databaseId + "/view/" + viewId;
log.trace("delete view at endpoint {} with path {}", gatewayConfig.getDataEndpoint(), path);
try { try {
response = restTemplate.exchange(url, HttpMethod.DELETE, HttpEntity.EMPTY, Void.class); response = restTemplate.exchange(path, HttpMethod.DELETE, HttpEntity.EMPTY, Void.class);
} catch (HttpServerErrorException e) { } catch (HttpServerErrorException e) {
log.error("Failed to delete view: {}", e.getMessage()); log.error("Failed to delete view: {}", e.getMessage());
throw new DataServiceConnectionException("Failed to delete view: " + e.getMessage(), e); throw new DataServiceConnectionException("Failed to delete view: " + e.getMessage(), e);
...@@ -250,9 +263,9 @@ public class DataServiceGatewayImpl implements DataServiceGateway { ...@@ -250,9 +263,9 @@ public class DataServiceGatewayImpl implements DataServiceGateway {
public QueryDto findQuery(Long databaseId, Long queryId) throws DataServiceConnectionException, DataServiceException, public QueryDto findQuery(Long databaseId, Long queryId) throws DataServiceConnectionException, DataServiceException,
QueryNotFoundException { QueryNotFoundException {
final ResponseEntity<QueryDto> response; final ResponseEntity<QueryDto> response;
final String url = "/api/database/" + databaseId + "/subset/" + queryId; final String path = "/api/database/" + databaseId + "/subset/" + queryId;
try { try {
response = restTemplate.exchange(url, HttpMethod.GET, HttpEntity.EMPTY, QueryDto.class); response = restTemplate.exchange(path, HttpMethod.GET, HttpEntity.EMPTY, QueryDto.class);
} catch (HttpServerErrorException e) { } catch (HttpServerErrorException e) {
log.error("Failed to find query: {}", e.getMessage()); log.error("Failed to find query: {}", e.getMessage());
throw new DataServiceConnectionException("Failed to find query", e); throw new DataServiceConnectionException("Failed to find query", e);
...@@ -277,9 +290,9 @@ public class DataServiceGatewayImpl implements DataServiceGateway { ...@@ -277,9 +290,9 @@ public class DataServiceGatewayImpl implements DataServiceGateway {
public ExportResourceDto exportQuery(Long databaseId, Long queryId) throws DataServiceConnectionException, public ExportResourceDto exportQuery(Long databaseId, Long queryId) throws DataServiceConnectionException,
DataServiceException, QueryNotFoundException { DataServiceException, QueryNotFoundException {
final ResponseEntity<ExportResourceDto> response; final ResponseEntity<ExportResourceDto> response;
final String url = "/api/database/" + databaseId + "/subset/" + queryId; final String path = "/api/database/" + databaseId + "/subset/" + queryId;
try { try {
response = restTemplate.exchange(url, HttpMethod.GET, HttpEntity.EMPTY, ExportResourceDto.class); response = restTemplate.exchange(path, HttpMethod.GET, HttpEntity.EMPTY, ExportResourceDto.class);
} catch (HttpServerErrorException e) { } catch (HttpServerErrorException e) {
log.error("Failed to export query: {}", e.getMessage()); log.error("Failed to export query: {}", e.getMessage());
throw new DataServiceConnectionException("Failed to export query: " + e.getMessage(), e); throw new DataServiceConnectionException("Failed to export query: " + e.getMessage(), e);
...@@ -301,9 +314,9 @@ public class DataServiceGatewayImpl implements DataServiceGateway { ...@@ -301,9 +314,9 @@ public class DataServiceGatewayImpl implements DataServiceGateway {
public List<TableDto> getTableSchemas(Long databaseId) throws DataServiceConnectionException, DataServiceException, public List<TableDto> getTableSchemas(Long databaseId) throws DataServiceConnectionException, DataServiceException,
TableNotFoundException { TableNotFoundException {
final ResponseEntity<TableDto[]> response; final ResponseEntity<TableDto[]> response;
final String url = "/api/database/" + databaseId + "/table"; final String path = "/api/database/" + databaseId + "/table";
try { try {
response = restTemplate.exchange(url, HttpMethod.GET, HttpEntity.EMPTY, TableDto[].class); response = restTemplate.exchange(path, HttpMethod.GET, HttpEntity.EMPTY, TableDto[].class);
} catch (HttpServerErrorException e) { } catch (HttpServerErrorException e) {
log.error("Failed to get table schemas: {}", e.getMessage()); log.error("Failed to get table schemas: {}", e.getMessage());
throw new DataServiceConnectionException("Failed to get table schemas: " + e.getMessage(), e); throw new DataServiceConnectionException("Failed to get table schemas: " + e.getMessage(), e);
...@@ -331,9 +344,10 @@ public class DataServiceGatewayImpl implements DataServiceGateway { ...@@ -331,9 +344,10 @@ public class DataServiceGatewayImpl implements DataServiceGateway {
public List<ViewDto> getViewSchemas(Long databaseId) throws DataServiceConnectionException, DataServiceException, public List<ViewDto> getViewSchemas(Long databaseId) throws DataServiceConnectionException, DataServiceException,
ViewNotFoundException { ViewNotFoundException {
final ResponseEntity<ViewDto[]> response; final ResponseEntity<ViewDto[]> response;
final String url = "/api/database/" + databaseId + "/view"; final String path = "/api/database/" + databaseId + "/view";
log.trace("get view schemas at endpoint {} with path {}", gatewayConfig.getDataEndpoint(), path);
try { try {
response = restTemplate.exchange(url, HttpMethod.GET, HttpEntity.EMPTY, ViewDto[].class); response = restTemplate.exchange(path, HttpMethod.GET, HttpEntity.EMPTY, ViewDto[].class);
} catch (HttpServerErrorException e) { } catch (HttpServerErrorException e) {
log.error("Failed to get view schemas: {}", e.getMessage()); log.error("Failed to get view schemas: {}", e.getMessage());
throw new DataServiceConnectionException("Failed to get view schemas: " + e.getMessage(), e); throw new DataServiceConnectionException("Failed to get view schemas: " + e.getMessage(), e);
...@@ -360,9 +374,10 @@ public class DataServiceGatewayImpl implements DataServiceGateway { ...@@ -360,9 +374,10 @@ public class DataServiceGatewayImpl implements DataServiceGateway {
@Override @Override
public TableStatisticDto getTableStatistics(Long databaseId, Long tableId) throws DataServiceConnectionException, DataServiceException, TableNotFoundException { public TableStatisticDto getTableStatistics(Long databaseId, Long tableId) throws DataServiceConnectionException, DataServiceException, TableNotFoundException {
final ResponseEntity<TableStatisticDto> response; final ResponseEntity<TableStatisticDto> response;
final String url = "/api/database/" + databaseId + "/table/" + tableId + "/statistic"; final String path = "/api/database/" + databaseId + "/table/" + tableId + "/statistic";
log.trace("get table statistics at endpoint {} with path {}", gatewayConfig.getDataEndpoint(), path);
try { try {
response = restTemplate.exchange(url, HttpMethod.GET, HttpEntity.EMPTY, TableStatisticDto.class); response = restTemplate.exchange(path, HttpMethod.GET, HttpEntity.EMPTY, TableStatisticDto.class);
} catch (HttpServerErrorException e) { } catch (HttpServerErrorException e) {
log.error("Failed to analyse table statistic: {}", e.getMessage()); log.error("Failed to analyse table statistic: {}", e.getMessage());
throw new DataServiceConnectionException("Failed to analyse table statistic: " + e.getMessage(), e); throw new DataServiceConnectionException("Failed to analyse table statistic: " + e.getMessage(), e);
......
...@@ -16,6 +16,7 @@ import org.springframework.util.MultiValueMap; ...@@ -16,6 +16,7 @@ import org.springframework.util.MultiValueMap;
import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.HttpServerErrorException; import org.springframework.web.client.HttpServerErrorException;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.DefaultUriBuilderFactory;
import java.util.UUID; import java.util.UUID;
...@@ -31,39 +32,13 @@ public class KeycloakGatewayImpl implements KeycloakGateway { ...@@ -31,39 +32,13 @@ public class KeycloakGatewayImpl implements KeycloakGateway {
public KeycloakGatewayImpl(@Qualifier("restTemplate") RestTemplate restTemplate, public KeycloakGatewayImpl(@Qualifier("restTemplate") RestTemplate restTemplate,
@Qualifier("keycloakRestTemplate") RestTemplate keycloakRestTemplate, @Qualifier("keycloakRestTemplate") RestTemplate keycloakRestTemplate,
KeycloakConfig keycloakConfig, MetadataMapper metadataMapper) { KeycloakConfig keycloakConfig, MetadataMapper metadataMapper) {
restTemplate.setUriTemplateHandler(new DefaultUriBuilderFactory(keycloakConfig.getKeycloakEndpoint()));
this.restTemplate = restTemplate; this.restTemplate = restTemplate;
this.keycloakRestTemplate = keycloakRestTemplate; this.keycloakRestTemplate = keycloakRestTemplate;
this.keycloakConfig = keycloakConfig; this.keycloakConfig = keycloakConfig;
this.metadataMapper = metadataMapper; this.metadataMapper = metadataMapper;
} }
public TokenDto obtainToken() throws AuthServiceConnectionException, AuthServiceException,
CredentialsInvalidException {
final HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
final MultiValueMap<String, String> payload = new LinkedMultiValueMap<>();
payload.add("username", keycloakConfig.getKeycloakUsername());
payload.add("password", keycloakConfig.getKeycloakPassword());
payload.add("grant_type", "password");
payload.add("client_id", "admin-cli");
final String url = keycloakConfig.getKeycloakEndpoint() + "/realms/master/protocol/openid-connect/token";
log.trace("request admin token from url: {}", url);
final ResponseEntity<TokenDto> response;
try {
response = keycloakRestTemplate.exchange(url, HttpMethod.POST, new HttpEntity<>(payload, headers), TokenDto.class);
} catch (HttpServerErrorException e) {
log.error("Failed to obtain admin token: {}", e.getMessage());
throw new AuthServiceConnectionException("Service unavailable", e);
} catch (HttpClientErrorException.Unauthorized e) {
log.error("Failed to obtain admin token: invalid credentials: {}", e.getMessage(), e);
throw new CredentialsInvalidException("Invalid credentials: " + e.getMessage(), e);
} catch (HttpClientErrorException.BadRequest e) {
log.error("Failed to obtain admin token: unexpected response: {}", e.getMessage(), e);
throw new AuthServiceException("Unexpected response: " + e.getMessage(), e);
}
return response.getBody();
}
@Override @Override
public TokenDto obtainUserToken(String username, String password) throws AuthServiceConnectionException, public TokenDto obtainUserToken(String username, String password) throws AuthServiceConnectionException,
CredentialsInvalidException, AccountNotSetupException { CredentialsInvalidException, AccountNotSetupException {
...@@ -76,11 +51,11 @@ public class KeycloakGatewayImpl implements KeycloakGateway { ...@@ -76,11 +51,11 @@ public class KeycloakGatewayImpl implements KeycloakGateway {
payload.add("scope", "openid roles"); payload.add("scope", "openid roles");
payload.add("client_id", keycloakConfig.getKeycloakClient()); payload.add("client_id", keycloakConfig.getKeycloakClient());
payload.add("client_secret", keycloakConfig.getKeycloakClientSecret()); payload.add("client_secret", keycloakConfig.getKeycloakClientSecret());
final String url = keycloakConfig.getKeycloakEndpoint() + "/realms/dbrepo/protocol/openid-connect/token"; final String path = "/realms/dbrepo/protocol/openid-connect/token";
log.trace("request admin token from url: {}", url); log.trace("obtain user token at endpoint {} with path {}", keycloakConfig.getKeycloakEndpoint(), path);
final ResponseEntity<TokenDto> response; final ResponseEntity<TokenDto> response;
try { try {
response = restTemplate.exchange(url, HttpMethod.POST, new HttpEntity<>(payload, headers), TokenDto.class); response = restTemplate.exchange(path, HttpMethod.POST, new HttpEntity<>(payload, headers), TokenDto.class);
} catch (HttpServerErrorException e) { } catch (HttpServerErrorException e) {
log.error("Failed to obtain user token: {}", e.getMessage()); log.error("Failed to obtain user token: {}", e.getMessage());
throw new AuthServiceConnectionException("Service unavailable", e); throw new AuthServiceConnectionException("Service unavailable", e);
...@@ -109,11 +84,11 @@ public class KeycloakGatewayImpl implements KeycloakGateway { ...@@ -109,11 +84,11 @@ public class KeycloakGatewayImpl implements KeycloakGateway {
payload.add("grant_type", "refresh_token"); payload.add("grant_type", "refresh_token");
payload.add("client_id", keycloakConfig.getKeycloakClient()); payload.add("client_id", keycloakConfig.getKeycloakClient());
payload.add("client_secret", keycloakConfig.getKeycloakClientSecret()); payload.add("client_secret", keycloakConfig.getKeycloakClientSecret());
final String url = keycloakConfig.getKeycloakEndpoint() + "/realms/dbrepo/protocol/openid-connect/token"; final String path = "/realms/dbrepo/protocol/openid-connect/token";
log.trace("request user token from url: {}", url); log.trace("refresh user token at endpoint {} with path {}", keycloakConfig.getKeycloakEndpoint(), path);
final ResponseEntity<TokenDto> response; final ResponseEntity<TokenDto> response;
try { try {
response = restTemplate.exchange(url, HttpMethod.POST, new HttpEntity<>(payload, headers), TokenDto.class); response = restTemplate.exchange(path, HttpMethod.POST, new HttpEntity<>(payload, headers), TokenDto.class);
} catch (HttpServerErrorException e) { } catch (HttpServerErrorException e) {
log.error("Failed to refresh user token: {}", e.getMessage()); log.error("Failed to refresh user token: {}", e.getMessage());
throw new AuthServiceConnectionException("Service unavailable", e); throw new AuthServiceConnectionException("Service unavailable", e);
...@@ -133,15 +108,12 @@ public class KeycloakGatewayImpl implements KeycloakGateway { ...@@ -133,15 +108,12 @@ public class KeycloakGatewayImpl implements KeycloakGateway {
@Override @Override
public void createUser(UserCreateDto data) throws AuthServiceException, AuthServiceConnectionException, public void createUser(UserCreateDto data) throws AuthServiceException, AuthServiceConnectionException,
EmailExistsException, UserExistsException, CredentialsInvalidException { EmailExistsException, UserExistsException {
/* obtain admin token */ final String path = "/admin/realms/dbrepo/users";
final HttpHeaders headers = new HttpHeaders(); log.trace("create user at endpoint {} with path {}", keycloakConfig.getKeycloakEndpoint(), path);
headers.set("Authorization", "Bearer " + obtainToken().getAccessToken());
final String url = keycloakConfig.getKeycloakEndpoint() + "/admin/realms/dbrepo/users";
log.debug("create user at url {}", url);
final ResponseEntity<Void> response; final ResponseEntity<Void> response;
try { try {
response = keycloakRestTemplate.exchange(url, HttpMethod.POST, new HttpEntity<>(data, headers), Void.class); response = keycloakRestTemplate.exchange(path, HttpMethod.POST, new HttpEntity<>(data), Void.class);
} catch (HttpServerErrorException e) { } catch (HttpServerErrorException e) {
log.error("Failed to create user: {}", e.getMessage()); log.error("Failed to create user: {}", e.getMessage());
throw new AuthServiceConnectionException("Service unavailable", e); throw new AuthServiceConnectionException("Service unavailable", e);
...@@ -164,16 +136,12 @@ public class KeycloakGatewayImpl implements KeycloakGateway { ...@@ -164,16 +136,12 @@ public class KeycloakGatewayImpl implements KeycloakGateway {
} }
@Override @Override
public void deleteUser(UUID id) throws AuthServiceException, AuthServiceConnectionException, UserNotFoundException, public void deleteUser(UUID id) throws AuthServiceException, AuthServiceConnectionException, UserNotFoundException {
CredentialsInvalidException { final String path = "/admin/realms/dbrepo/users/" + id;
/* obtain admin token */ log.trace("delete user at endpoint {} with path {}", keycloakConfig.getKeycloakEndpoint(), path);
final HttpHeaders headers = new HttpHeaders();
headers.set("Authorization", "Bearer " + obtainToken().getAccessToken());
final String url = keycloakConfig.getKeycloakEndpoint() + "/admin/realms/dbrepo/users/" + id;
log.debug("delete user at url {}", url);
final ResponseEntity<Void> response; final ResponseEntity<Void> response;
try { try {
response = keycloakRestTemplate.exchange(url, HttpMethod.DELETE, new HttpEntity<>(null, headers), Void.class); response = keycloakRestTemplate.exchange(path, HttpMethod.DELETE, HttpEntity.EMPTY, Void.class);
} catch (HttpServerErrorException e) { } catch (HttpServerErrorException e) {
log.error("Failed to delete user: {}", e.getMessage()); log.error("Failed to delete user: {}", e.getMessage());
throw new AuthServiceConnectionException("Service unavailable", e); throw new AuthServiceConnectionException("Service unavailable", e);
...@@ -193,16 +161,13 @@ public class KeycloakGatewayImpl implements KeycloakGateway { ...@@ -193,16 +161,13 @@ public class KeycloakGatewayImpl implements KeycloakGateway {
@Override @Override
public void updateUserCredentials(UUID id, UserPasswordDto data) throws AuthServiceException, public void updateUserCredentials(UUID id, UserPasswordDto data) throws AuthServiceException,
AuthServiceConnectionException, CredentialsInvalidException { AuthServiceConnectionException {
/* obtain admin token */
final HttpHeaders headers = new HttpHeaders();
headers.set("Authorization", "Bearer " + obtainToken().getAccessToken());
final UpdateCredentialsDto payload = metadataMapper.passwordToUpdateCredentialsDto(data.getPassword()); final UpdateCredentialsDto payload = metadataMapper.passwordToUpdateCredentialsDto(data.getPassword());
final String url = keycloakConfig.getKeycloakEndpoint() + "/admin/realms/dbrepo/users/" + id; final String path = "/admin/realms/dbrepo/users/" + id;
log.debug("update user credentials at url {}", url); log.trace("update user credentials at endpoint {} with path {}", keycloakConfig.getKeycloakEndpoint(), path);
final ResponseEntity<Void> response; final ResponseEntity<Void> response;
try { try {
response = keycloakRestTemplate.exchange(url, HttpMethod.PUT, new HttpEntity<>(payload, headers), Void.class); response = keycloakRestTemplate.exchange(path, HttpMethod.PUT, new HttpEntity<>(payload), Void.class);
} catch (HttpServerErrorException e) { } catch (HttpServerErrorException e) {
log.error("Failed to update user credentials: {}", e.getMessage()); log.error("Failed to update user credentials: {}", e.getMessage());
throw new AuthServiceConnectionException("Service unavailable", e); throw new AuthServiceConnectionException("Service unavailable", e);
...@@ -219,15 +184,12 @@ public class KeycloakGatewayImpl implements KeycloakGateway { ...@@ -219,15 +184,12 @@ public class KeycloakGatewayImpl implements KeycloakGateway {
@Override @Override
public UserDto findByUsername(String username) throws AuthServiceException, AuthServiceConnectionException, public UserDto findByUsername(String username) throws AuthServiceException, AuthServiceConnectionException,
UserNotFoundException, CredentialsInvalidException { UserNotFoundException {
/* obtain admin token */ final String path = "/admin/realms/dbrepo/users/?username=" + username;
final HttpHeaders headers = new HttpHeaders(); log.trace("find user by username at endpoint {} with path {}", keycloakConfig.getKeycloakEndpoint(), path);
headers.set("Authorization", "Bearer " + obtainToken().getAccessToken());
final String url = keycloakConfig.getKeycloakEndpoint() + "/admin/realms/dbrepo/users/?username=" + username;
log.debug("find user from url {}", url);
final ResponseEntity<UserDto[]> response; final ResponseEntity<UserDto[]> response;
try { try {
response = keycloakRestTemplate.exchange(url, HttpMethod.GET, new HttpEntity<>(null, headers), UserDto[].class); response = keycloakRestTemplate.exchange(path, HttpMethod.GET, HttpEntity.EMPTY, UserDto[].class);
} catch (HttpServerErrorException e) { } catch (HttpServerErrorException e) {
log.error("Failed to find user: {}", e.getMessage()); log.error("Failed to find user: {}", e.getMessage());
throw new AuthServiceConnectionException("Service unavailable", e); throw new AuthServiceConnectionException("Service unavailable", e);
...@@ -245,15 +207,12 @@ public class KeycloakGatewayImpl implements KeycloakGateway { ...@@ -245,15 +207,12 @@ public class KeycloakGatewayImpl implements KeycloakGateway {
@Override @Override
public UserDto findById(UUID id) throws AuthServiceException, AuthServiceConnectionException, public UserDto findById(UUID id) throws AuthServiceException, AuthServiceConnectionException,
UserNotFoundException, CredentialsInvalidException { UserNotFoundException {
/* obtain admin token */ final String path = "/admin/realms/dbrepo/users/" + id;
final HttpHeaders headers = new HttpHeaders(); log.trace("find user by id at endpoint {} with path {}", keycloakConfig.getKeycloakEndpoint(), path);
headers.set("Authorization", "Bearer " + obtainToken().getAccessToken());
final String url = keycloakConfig.getKeycloakEndpoint() + "/admin/realms/dbrepo/users/" + id;
log.debug("find user from url {}", url);
final ResponseEntity<UserDto> response; final ResponseEntity<UserDto> response;
try { try {
response = keycloakRestTemplate.exchange(url, HttpMethod.GET, new HttpEntity<>(null, headers), UserDto.class); response = keycloakRestTemplate.exchange(path, HttpMethod.GET, HttpEntity.EMPTY, UserDto.class);
} catch (HttpServerErrorException e) { } catch (HttpServerErrorException e) {
log.error("Failed to find user: {}", e.getMessage()); log.error("Failed to find user: {}", e.getMessage());
throw new AuthServiceConnectionException("Service unavailable", e); throw new AuthServiceConnectionException("Service unavailable", e);
......
...@@ -27,15 +27,13 @@ public class OrcidGatewayImpl implements OrcidGateway { ...@@ -27,15 +27,13 @@ public class OrcidGatewayImpl implements OrcidGateway {
@Override @Override
public OrcidDto findByUrl(String url) throws OrcidNotFoundException { public OrcidDto findByUrl(String url) throws OrcidNotFoundException {
final HttpHeaders headers = new HttpHeaders(); log.trace("find orcid by url at endpoint {}", url);
headers.set("Accept", "application/json");
final ResponseEntity<OrcidDto> response; final ResponseEntity<OrcidDto> response;
try { try {
log.debug("find orcid from url {}", url); response = restTemplate.exchange(url, HttpMethod.GET, HttpEntity.EMPTY, OrcidDto.class);
response = restTemplate.exchange(url, HttpMethod.GET, new HttpEntity<>(null, headers), OrcidDto.class);
} catch (HttpServerErrorException e) { } catch (HttpServerErrorException e) {
log.error("Failed to retrieve ORCID metadata from URL {}: {}", url, e.getMessage()); log.error("Failed to retrieve orcid metadata: {}", e.getMessage());
throw new OrcidNotFoundException("Failed to retrieve ORCID metadata from URL " + url + ": " + e.getMessage()); throw new OrcidNotFoundException("Failed to retrieve orcid metadata: " + e.getMessage());
} }
return response.getBody(); return response.getBody();
} }
......
package at.tuwien.gateway.impl; package at.tuwien.gateway.impl;
import at.tuwien.api.ror.RorDto; import at.tuwien.api.ror.RorDto;
import at.tuwien.config.GatewayConfig;
import at.tuwien.exception.RorNotFoundException; import at.tuwien.exception.RorNotFoundException;
import at.tuwien.gateway.RorGateway; import at.tuwien.gateway.RorGateway;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
...@@ -19,24 +20,24 @@ import org.springframework.web.client.RestTemplate; ...@@ -19,24 +20,24 @@ import org.springframework.web.client.RestTemplate;
public class RorGatewayImpl implements RorGateway { public class RorGatewayImpl implements RorGateway {
private final RestTemplate restTemplate; private final RestTemplate restTemplate;
private final GatewayConfig gatewayConfig;
@Autowired @Autowired
public RorGatewayImpl(RestTemplate restTemplate) { public RorGatewayImpl(RestTemplate restTemplate, GatewayConfig gatewayConfig) {
this.restTemplate = restTemplate; this.restTemplate = restTemplate;
this.gatewayConfig = gatewayConfig;
} }
@Override @Override
public RorDto findById(String id) throws RorNotFoundException { public RorDto findById(String id) throws RorNotFoundException {
final HttpHeaders headers = new HttpHeaders(); final String path = "/organizations/" + id;
headers.set("Accept", "application/json"); log.trace("find ror by id at endpoint {} with path {}", gatewayConfig.getRorEndpoint(), path);
final String url = "https://api.ror.org/organizations/" + id;
final ResponseEntity<RorDto> response; final ResponseEntity<RorDto> response;
try { try {
log.trace("find ror from url {}", url); response = restTemplate.exchange(gatewayConfig.getRorEndpoint() + path, HttpMethod.GET, HttpEntity.EMPTY, RorDto.class);
response = restTemplate.exchange(url, HttpMethod.GET, new HttpEntity<>(null, headers), RorDto.class);
} catch (HttpServerErrorException e) { } catch (HttpServerErrorException e) {
log.error("Failed to retrieve ROR metadata from URL {}: {}", url, e.getMessage()); log.error("Failed to retrieve ror metadata: {}", e.getMessage());
throw new RorNotFoundException("Failed to retrieve ROR metadata from URL " + url + ": " + e.getMessage(), e); throw new RorNotFoundException("Failed to retrieve ror metadata: " + e.getMessage(), e);
} }
return response.getBody(); return response.getBody();
} }
......
package at.tuwien.gateway.impl; package at.tuwien.gateway.impl;
import at.tuwien.api.database.DatabaseDto; import at.tuwien.api.database.DatabaseDto;
import at.tuwien.config.GatewayConfig;
import at.tuwien.entities.database.Database; import at.tuwien.entities.database.Database;
import at.tuwien.exception.*; import at.tuwien.exception.*;
import at.tuwien.gateway.SearchServiceGateway; import at.tuwien.gateway.SearchServiceGateway;
...@@ -20,12 +21,14 @@ import org.springframework.web.client.RestTemplate; ...@@ -20,12 +21,14 @@ import org.springframework.web.client.RestTemplate;
public class SearchServiceGatewayImpl implements SearchServiceGateway { public class SearchServiceGatewayImpl implements SearchServiceGateway {
private final RestTemplate restTemplate; private final RestTemplate restTemplate;
private final GatewayConfig gatewayConfig;
private final MetadataMapper metadataMapper; private final MetadataMapper metadataMapper;
@Autowired @Autowired
public SearchServiceGatewayImpl(@Qualifier("searchServiceRestTemplate") RestTemplate restTemplate, public SearchServiceGatewayImpl(@Qualifier("searchServiceRestTemplate") RestTemplate restTemplate,
MetadataMapper metadataMapper) { GatewayConfig gatewayConfig, MetadataMapper metadataMapper) {
this.restTemplate = restTemplate; this.restTemplate = restTemplate;
this.gatewayConfig = gatewayConfig;
this.metadataMapper = metadataMapper; this.metadataMapper = metadataMapper;
} }
...@@ -35,9 +38,10 @@ public class SearchServiceGatewayImpl implements SearchServiceGateway { ...@@ -35,9 +38,10 @@ public class SearchServiceGatewayImpl implements SearchServiceGateway {
final HttpHeaders headers = new HttpHeaders(); final HttpHeaders headers = new HttpHeaders();
headers.set("Accept", "application/json"); headers.set("Accept", "application/json");
headers.set("Content-Type", "application/json"); headers.set("Content-Type", "application/json");
final String url = "/api/search/database/" + database.getId(); final String path = "/api/search/database/" + database.getId();
log.trace("update database at endpoint {} with path {}", gatewayConfig.getSearchEndpoint(), path);
try { try {
response = restTemplate.exchange(url, HttpMethod.PUT, new HttpEntity<>( response = restTemplate.exchange(path, HttpMethod.PUT, new HttpEntity<>(
metadataMapper.customDatabaseToDatabaseDto(database), headers), DatabaseDto.class); metadataMapper.customDatabaseToDatabaseDto(database), headers), DatabaseDto.class);
} catch (ResourceAccessException | HttpServerErrorException.ServiceUnavailable | } catch (ResourceAccessException | HttpServerErrorException.ServiceUnavailable |
HttpServerErrorException.InternalServerError e) { HttpServerErrorException.InternalServerError e) {
...@@ -60,9 +64,10 @@ public class SearchServiceGatewayImpl implements SearchServiceGateway { ...@@ -60,9 +64,10 @@ public class SearchServiceGatewayImpl implements SearchServiceGateway {
@Override @Override
public void delete(Long databaseId) throws SearchServiceConnectionException, SearchServiceException, DatabaseNotFoundException { public void delete(Long databaseId) throws SearchServiceConnectionException, SearchServiceException, DatabaseNotFoundException {
final ResponseEntity<Void> response; final ResponseEntity<Void> response;
final String url = "/api/search/database/" + databaseId; final String path = "/api/search/database/" + databaseId;
log.trace("delete database at endpoint {} with path {}", gatewayConfig.getSearchEndpoint(), path);
try { try {
response = restTemplate.exchange(url, HttpMethod.DELETE, new HttpEntity<>(null), Void.class); response = restTemplate.exchange(path, HttpMethod.DELETE, new HttpEntity<>(null), Void.class);
} catch (ResourceAccessException | HttpServerErrorException.ServiceUnavailable | } catch (ResourceAccessException | HttpServerErrorException.ServiceUnavailable |
HttpServerErrorException.InternalServerError e) { HttpServerErrorException.InternalServerError e) {
log.error("Failed to delete database: {}", e.getMessage()); log.error("Failed to delete database: {}", e.getMessage());
......
...@@ -11,6 +11,7 @@ import org.springframework.util.MultiValueMap; ...@@ -11,6 +11,7 @@ import org.springframework.util.MultiValueMap;
import org.springframework.web.client.HttpServerErrorException; import org.springframework.web.client.HttpServerErrorException;
import org.springframework.web.client.ResourceAccessException; import org.springframework.web.client.ResourceAccessException;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.DefaultUriBuilderFactory;
import java.io.IOException; import java.io.IOException;
...@@ -20,17 +21,20 @@ public class KeycloakInterceptor implements ClientHttpRequestInterceptor { ...@@ -20,17 +21,20 @@ public class KeycloakInterceptor implements ClientHttpRequestInterceptor {
private final String adminUsername; private final String adminUsername;
private final String adminPassword; private final String adminPassword;
private final String keycloakEndpoint; private final String keycloakEndpoint;
private final RestTemplate restTemplate;
public KeycloakInterceptor(String adminUsername, String adminPassword, String keycloakEndpoint) { public KeycloakInterceptor(RestTemplate restTemplate, String adminUsername, String adminPassword,
String keycloakEndpoint) {
this.adminUsername = adminUsername; this.adminUsername = adminUsername;
this.adminPassword = adminPassword; this.adminPassword = adminPassword;
this.keycloakEndpoint = keycloakEndpoint; this.keycloakEndpoint = keycloakEndpoint;
this.restTemplate = restTemplate;
} }
@Override @Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)
throws IOException { throws IOException {
final RestTemplate restTemplate = new RestTemplate(); restTemplate.setUriTemplateHandler(new DefaultUriBuilderFactory(keycloakEndpoint));
final HttpHeaders headers = new HttpHeaders(); final HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
final MultiValueMap<String, String> payload = new LinkedMultiValueMap<>(); final MultiValueMap<String, String> payload = new LinkedMultiValueMap<>();
...@@ -38,10 +42,11 @@ public class KeycloakInterceptor implements ClientHttpRequestInterceptor { ...@@ -38,10 +42,11 @@ public class KeycloakInterceptor implements ClientHttpRequestInterceptor {
payload.add("password", adminPassword); payload.add("password", adminPassword);
payload.add("grant_type", "password"); payload.add("grant_type", "password");
payload.add("client_id", "admin-cli"); payload.add("client_id", "admin-cli");
final String path = "/realms/master/protocol/openid-connect/token";
log.trace("obtain admin token at endpoint {} with path {}", keycloakEndpoint, path);
final ResponseEntity<TokenDto> response; final ResponseEntity<TokenDto> response;
try { try {
response = restTemplate.exchange(keycloakEndpoint + "/realms/master/protocol/openid-connect/token", response = restTemplate.exchange(path, HttpMethod.POST, new HttpEntity<>(payload, headers), TokenDto.class);
HttpMethod.POST, new HttpEntity<>(payload, headers), TokenDto.class);
} catch (ResourceAccessException | HttpServerErrorException.ServiceUnavailable e) { } catch (ResourceAccessException | HttpServerErrorException.ServiceUnavailable e) {
log.error("Failed to obtain admin token: {}", e.getMessage()); log.error("Failed to obtain admin token: {}", e.getMessage());
return execution.execute(request, body); return execution.execute(request, body);
......
...@@ -46,8 +46,8 @@ public class StorageServiceS3Impl implements StorageService { ...@@ -46,8 +46,8 @@ public class StorageServiceS3Impl implements StorageService {
@Override @Override
public byte[] getBytes(String key) throws StorageNotFoundException, StorageUnavailableException { public byte[] getBytes(String key) throws StorageNotFoundException, StorageUnavailableException {
log.trace("get bytes with key {} from bucket {}", key, s3Config.getS3ImportBucket()); log.trace("get bytes with key {} from bucket {}", key, s3Config.getS3Bucket());
return getBytes(s3Config.getS3ImportBucket(), key); return getBytes(s3Config.getS3Bucket(), key);
} }
@Override @Override
......
#!/bin/bash #!/bin/bash
S3_BUCKET=${S3_BUCKET:-dbrepo}
function log { function log {
echo "$(date '+%Y-%m-%d %H:%M:%S') $1" echo "$(date '+%Y-%m-%d %H:%M:%S') $1"
} }
log "SeaweedFS master is set to ${SEAWEEDFS_ENDPOINT}" log "SeaweedFS master is set to ${WEED_CLUSTER_SW_MASTER}"
log "Starting to create buckets dbrepo-upload, dbrepo-download" log "Starting to create bucket ${S3_BUCKET}"
echo "s3.bucket.create -name dbrepo-upload" | weed shell -master="${SEAWEEDFS_ENDPOINT}" echo "s3.bucket.create -name ${S3_BUCKET}" | weed shell -master="${WEED_CLUSTER_SW_MASTER}"
log "Created bucket dbrepo-upload" log "Created bucket ${S3_BUCKET}"
echo "s3.bucket.create -name dbrepo-download" | weed shell -master="${SEAWEEDFS_ENDPOINT}"
log "Created bucket dbrepo-download"
\ No newline at end of file
File added
...@@ -31,20 +31,20 @@ export default { ...@@ -31,20 +31,20 @@ export default {
if (!this.file || this.file.length === 0) { if (!this.file || this.file.length === 0) {
return return
} }
console.debug('upload file', this.file)
const uploadService = useUploadService() const uploadService = useUploadService()
uploadService.create(this.file[0]) uploadService.create(this.file)
.then((filename) => { .then((filename) => {
console.debug('uploaded file', filename) console.debug('uploaded file', filename)
this.filename = filename this.filename = filename
this.value = filename this.value = filename
this.$emit('blob', { column: this.column, s3key: filename }) this.$emit('blob', { column: this.column, s3key: filename })
}) })
.catch(({code}) => { .catch((error) => {
console.error('Failed to upload dataset', error)
const toast = useToastInstance() const toast = useToastInstance()
if (typeof code !== 'string') { toast.error(this.$t('error.upload.dataset'))
return this.loading = false
}
toast.error(this.$t(code))
}) })
} }
} }
......
...@@ -174,7 +174,7 @@ ...@@ -174,7 +174,7 @@
<v-row> <v-row>
<v-col cols="8"> <v-col cols="8">
<v-file-input <v-file-input
v-model="fileModel" v-model="file"
accept=".csv,.tsv" accept=".csv,.tsv"
:show-size="1000" :show-size="1000"
counter counter
...@@ -279,8 +279,7 @@ export default { ...@@ -279,8 +279,7 @@ export default {
step: 1, step: 1,
validStep1: false, validStep1: false,
validStep2: false, validStep2: false,
fileModel: null, file: null,
previousFile: null,
loading: false, loading: false,
rowCount: null, rowCount: null,
suggestedAnalyseSeparator: null, suggestedAnalyseSeparator: null,
...@@ -328,10 +327,10 @@ export default { ...@@ -328,10 +327,10 @@ export default {
return this.cacheStore.getTable return this.cacheStore.getTable
}, },
isAnalyseAllowed () { isAnalyseAllowed () {
if (!this.fileModel || this.fileModel.length === 0) { if (!this.file || this.file.length === 0) {
return true return false
} }
return this.previousFile !== this.fileModel[0] return true
}, },
hasCompatibleSchema () { hasCompatibleSchema () {
if (this.create) { if (this.create) {
...@@ -422,15 +421,16 @@ export default { ...@@ -422,15 +421,16 @@ export default {
}, },
uploadAndAnalyse() { uploadAndAnalyse() {
this.loading = true this.loading = true
this.previousFile = this.fileModel[0] console.debug('upload file', this.file)
const uploadService = useUploadService() const uploadService = useUploadService()
return uploadService.create(this.previousFile) return uploadService.create(this.file)
.then((s3key) => { .then((s3key) => {
const toast = useToastInstance() const toast = useToastInstance()
toast.success(this.$t('success.upload.dataset')) toast.success(this.$t('success.upload.dataset'))
this.analyse(s3key) this.analyse(s3key)
}) })
.catch(() => { .catch((error) => {
console.error('Failed to upload dataset', error)
const toast = useToastInstance() const toast = useToastInstance()
toast.error(this.$t('error.upload.dataset')) toast.error(this.$t('error.upload.dataset'))
this.loading = false this.loading = false
......
...@@ -3,8 +3,8 @@ import * as tus from 'tus-js-client' ...@@ -3,8 +3,8 @@ import * as tus from 'tus-js-client'
export const useUploadService = (): any => { export const useUploadService = (): any => {
function create (data: File) { function create (data: File) {
const config = useRuntimeConfig() const config = useRuntimeConfig()
const endpoint = config.public.upload.client
return new Promise<string>((resolve, reject) => { return new Promise<string>((resolve, reject) => {
const endpoint = `${config.public.api.client}/api/upload/files`
if (!tus.isSupported) { if (!tus.isSupported) {
console.error('Your browser does not support uploads!') console.error('Your browser does not support uploads!')
return return
...@@ -12,10 +12,6 @@ export const useUploadService = (): any => { ...@@ -12,10 +12,6 @@ export const useUploadService = (): any => {
const uploadClient: tus.Upload = new tus.Upload(data, { const uploadClient: tus.Upload = new tus.Upload(data, {
endpoint, endpoint,
retryDelays: [0, 3000, 5000, 10000, 20000], retryDelays: [0, 3000, 5000, 10000, 20000],
metadata: {
filename: data.name,
filetype: data.type
},
onError (error) { onError (error) {
console.error('Failed to upload:', error) console.error('Failed to upload:', error)
reject(error) reject(error)
......
...@@ -76,6 +76,9 @@ export default defineNuxtConfig({ ...@@ -76,6 +76,9 @@ export default defineNuxtConfig({
client: 'http://localhost', client: 'http://localhost',
server: 'http://gateway-service', server: 'http://gateway-service',
}, },
upload: {
client: 'http://localhost/api/upload/files'
},
database: { database: {
unsupported: '*,AVG,BIT_AND,BIT_OR,BIT_XOR,COUNT,COUNTDISTINCT,GROUP_CONCAT,JSON_ARRAYAGG,JSON_OBJECTAGG,MAX,MIN,STD,STDDEV,STDDEV_POP,STDDEV_SAMP,SUM,VARIANCE,VAR_POP,VAR_SAMP,--', unsupported: '*,AVG,BIT_AND,BIT_OR,BIT_XOR,COUNT,COUNTDISTINCT,GROUP_CONCAT,JSON_ARRAYAGG,JSON_OBJECTAGG,MAX,MIN,STD,STDDEV,STDDEV_POP,STDDEV_SAMP,SUM,VARIANCE,VAR_POP,VAR_SAMP,--',
image: { image: {
...@@ -102,12 +105,6 @@ export default defineNuxtConfig({ ...@@ -102,12 +105,6 @@ export default defineNuxtConfig({
text: 'Keycloak Admin', text: 'Keycloak Admin',
href: '/api/auth/' href: '/api/auth/'
} }
},
keycloak: {
client: {
id: 'dbrepo-client',
secret: 'MUwRc7yfXSJwX8AdRMWaQC3Nep1VjwgG'
}
} }
} }
}, },
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
<v-row dense> <v-row dense>
<v-col md="8"> <v-col md="8">
<v-file-input <v-file-input
v-model="fileModel" v-model="file"
accept="image/*" accept="image/*"
:hint="$t('pages.database.subpages.settings.image.hint')" :hint="$t('pages.database.subpages.settings.image.hint')"
persistent-hint persistent-hint
...@@ -229,7 +229,7 @@ export default { ...@@ -229,7 +229,7 @@ export default {
loadingSchema: false, loadingSchema: false,
validUpload: false, validUpload: false,
loadingDeleteImage: false, loadingDeleteImage: false,
fileModel: null, file: null,
loadingUsers: false, loadingUsers: false,
editAccessDialog: false, editAccessDialog: false,
editVisibilityDialog: false, editVisibilityDialog: false,
...@@ -366,10 +366,10 @@ export default { ...@@ -366,10 +366,10 @@ export default {
return this.roles.includes('modify-database-image') return this.roles.includes('modify-database-image')
}, },
databaseImage () { databaseImage () {
if (!this.fileModel) { if (!this.file) {
return null return null
} }
return URL.createObjectURL(this.fileModel[0]) return URL.createObjectURL(this.file[0])
}, },
maxWidth () { maxWidth () {
return this.$config.public.database.image.width return this.$config.public.database.image.width
...@@ -431,8 +431,9 @@ export default { ...@@ -431,8 +431,9 @@ export default {
}, },
uploadFile () { uploadFile () {
this.loadingUpload = true this.loadingUpload = true
console.debug('upload file', this.file)
const uploadService = useUploadService() const uploadService = useUploadService()
uploadService.create(this.fileModel[0]) uploadService.create(this.file)
.then((s3key) => { .then((s3key) => {
console.debug('uploaded image', s3key) console.debug('uploaded image', s3key)
const toast = useToastInstance() const toast = useToastInstance()
...@@ -440,6 +441,12 @@ export default { ...@@ -440,6 +441,12 @@ export default {
this.modifyImage.key = s3key this.modifyImage.key = s3key
this.loadingUpload = false this.loadingUpload = false
}) })
.catch((error) => {
console.error('Failed to upload dataset', error)
const toast = useToastInstance()
toast.error(this.$t('error.upload.dataset'))
this.loading = false
})
.finally(() => { .finally(() => {
this.loadingUpload = false this.loadingUpload = false
}) })
......
...@@ -39,9 +39,8 @@ services: ...@@ -39,9 +39,8 @@ services:
hostname: data-db hostname: data-db
image: docker.io/bitnami/mariadb:11.1.3-debian-11-r6 image: docker.io/bitnami/mariadb:11.1.3-debian-11-r6
volumes: volumes:
- ./dbrepo-data-db/enable_history_insert.cnf:/opt/bitnami/mariadb/conf.default/enable_history_insert.cnf
- "${SHARED_VOLUME:-/tmp}:/tmp"
- data-db-data:/bitnami/mariadb - data-db-data:/bitnami/mariadb
- "${SHARED_VOLUME:-/tmp}:/tmp"
ports: ports:
- "3307:3306" - "3307:3306"
environment: environment:
...@@ -68,7 +67,7 @@ services: ...@@ -68,7 +67,7 @@ services:
MARIADB_ROOT_PASSWORD: "${AUTH_PASSWORD:-dbrepo}" MARIADB_ROOT_PASSWORD: "${AUTH_PASSWORD:-dbrepo}"
healthcheck: healthcheck:
test: mysqladmin ping --user="${AUTH_USERNAME:-root}" --password="${AUTH_PASSWORD:-dbrepo}" --silent test: mysqladmin ping --user="${AUTH_USERNAME:-root}" --password="${AUTH_PASSWORD:-dbrepo}" --silent
interval: 10s interval: 15s
timeout: 5s timeout: 5s
retries: 12 retries: 12
logging: logging:
...@@ -86,7 +85,7 @@ services: ...@@ -86,7 +85,7 @@ services:
network: host network: host
healthcheck: healthcheck:
test: curl -sSL 'http://0.0.0.0:8080/realms/dbrepo' | grep "dbrepo" || exit 1 test: curl -sSL 'http://0.0.0.0:8080/realms/dbrepo' | grep "dbrepo" || exit 1
interval: 10s interval: 15s
timeout: 5s timeout: 5s
retries: 12 retries: 12
environment: environment:
...@@ -132,6 +131,7 @@ services: ...@@ -132,6 +131,7 @@ services:
BROKER_SERVICE_ENDPOINT: ${BROKER_SERVICE_ENDPOINT:-http://gateway-service/admin/broker} BROKER_SERVICE_ENDPOINT: ${BROKER_SERVICE_ENDPOINT:-http://gateway-service/admin/broker}
BROKER_USERNAME: ${BROKER_USERNAME:-admin} BROKER_USERNAME: ${BROKER_USERNAME:-admin}
BROKER_VIRTUALHOST: "${BROKER_VIRTUALHOST:-dbrepo}" BROKER_VIRTUALHOST: "${BROKER_VIRTUALHOST:-dbrepo}"
CROSSREF_ENDPOINT: "${CROSSREF_ENDPOINT:-http://data.crossref.org}"
DATA_SERVICE_ENDPOINT: ${DATA_SERVICE_ENDPOINT:-http://data-service:8080} DATA_SERVICE_ENDPOINT: ${DATA_SERVICE_ENDPOINT:-http://data-service:8080}
DELETED_RECORD: "${DELETED_RECORD:-persistent}" DELETED_RECORD: "${DELETED_RECORD:-persistent}"
GRANULARITY: "${GRANULARITY:-YYYY-MM-DDThh:mm:ssZ}" GRANULARITY: "${GRANULARITY:-YYYY-MM-DDThh:mm:ssZ}"
...@@ -144,11 +144,11 @@ services: ...@@ -144,11 +144,11 @@ services:
METADATA_PASSWORD: "${METADATA_PASSWORD:-dbrepo}" METADATA_PASSWORD: "${METADATA_PASSWORD:-dbrepo}"
PID_BASE: ${PID_BASE:-http://localhost/pid/} PID_BASE: ${PID_BASE:-http://localhost/pid/}
REPOSITORY_NAME: "${REPOSITORY_NAME:-Database Repository}" REPOSITORY_NAME: "${REPOSITORY_NAME:-Database Repository}"
ROR_ENDPOINT: "${ROR_ENDPOINT:-https://api.ror.org}"
SEARCH_SERVICE_ENDPOINT: "${SEARCH_SERVICE_ENDPOINT:-http://gateway-service}" SEARCH_SERVICE_ENDPOINT: "${SEARCH_SERVICE_ENDPOINT:-http://gateway-service}"
S3_ACCESS_KEY_ID: "${S3_ACCESS_KEY_ID:-seaweedfsadmin}" S3_ACCESS_KEY_ID: "${S3_ACCESS_KEY_ID:-seaweedfsadmin}"
S3_BUCKET: "${S3_BUCKET:-dbrepo}"
S3_ENDPOINT: "${S3_ENDPOINT:-http://storage-service:9000}" S3_ENDPOINT: "${S3_ENDPOINT:-http://storage-service:9000}"
S3_EXPORT_BUCKET: "${S3_EXPORT_BUCKET:-dbrepo-download}"
S3_IMPORT_BUCKET: "${S3_IMPORT_BUCKET:-dbrepo-upload}"
S3_SECRET_ACCESS_KEY: "${S3_SECRET_ACCESS_KEY:-seaweedfsadmin}" S3_SECRET_ACCESS_KEY: "${S3_SECRET_ACCESS_KEY:-seaweedfsadmin}"
SPARQL_CONNECTION_TIMEOUT: "${SPARQL_CONNECTION_TIMEOUT:-10000}" SPARQL_CONNECTION_TIMEOUT: "${SPARQL_CONNECTION_TIMEOUT:-10000}"
SYSTEM_USERNAME: "${SYSTEM_USERNAME:-admin}" SYSTEM_USERNAME: "${SYSTEM_USERNAME:-admin}"
...@@ -187,9 +187,8 @@ services: ...@@ -187,9 +187,8 @@ services:
GATEWAY_SERVICE_ENDPOINT: ${GATEWAY_SERVICE_ENDPOINT:-http://gateway-service} GATEWAY_SERVICE_ENDPOINT: ${GATEWAY_SERVICE_ENDPOINT:-http://gateway-service}
JWT_PUBKEY: "${JWT_PUBKEY:-MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqqnHQ2BWWW9vDNLRCcxD++xZg/16oqMo/c1l+lcFEjjAIJjJp/HqrPYU/U9GvquGE6PbVFtTzW1KcKawOW+FJNOA3CGo8Q1TFEfz43B8rZpKsFbJKvQGVv1Z4HaKPvLUm7iMm8Hv91cLduuoWx6Q3DPe2vg13GKKEZe7UFghF+0T9u8EKzA/XqQ0OiICmsmYPbwvf9N3bCKsB/Y10EYmZRb8IhCoV9mmO5TxgWgiuNeCTtNCv2ePYqL/U0WvyGFW0reasIK8eg3KrAUj8DpyOgPOVBn3lBGf+3KFSYi+0bwZbJZWqbC/Xlk20Go1YfeJPRIt7ImxD27R/lNjgDO/MwIDAQAB}" JWT_PUBKEY: "${JWT_PUBKEY:-MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqqnHQ2BWWW9vDNLRCcxD++xZg/16oqMo/c1l+lcFEjjAIJjJp/HqrPYU/U9GvquGE6PbVFtTzW1KcKawOW+FJNOA3CGo8Q1TFEfz43B8rZpKsFbJKvQGVv1Z4HaKPvLUm7iMm8Hv91cLduuoWx6Q3DPe2vg13GKKEZe7UFghF+0T9u8EKzA/XqQ0OiICmsmYPbwvf9N3bCKsB/Y10EYmZRb8IhCoV9mmO5TxgWgiuNeCTtNCv2ePYqL/U0WvyGFW0reasIK8eg3KrAUj8DpyOgPOVBn3lBGf+3KFSYi+0bwZbJZWqbC/Xlk20Go1YfeJPRIt7ImxD27R/lNjgDO/MwIDAQAB}"
S3_ACCESS_KEY_ID: "${S3_ACCESS_KEY_ID:-seaweedfsadmin}" S3_ACCESS_KEY_ID: "${S3_ACCESS_KEY_ID:-seaweedfsadmin}"
S3_BUCKET: "${S3_BUCKET:-dbrepo}"
S3_ENDPOINT: "${S3_ENDPOINT:-http://storage-service:9000}" S3_ENDPOINT: "${S3_ENDPOINT:-http://storage-service:9000}"
S3_EXPORT_BUCKET: "${S3_EXPORT_BUCKET:-dbrepo-download}"
S3_IMPORT_BUCKET: "${S3_IMPORT_BUCKET:-dbrepo-upload}"
S3_SECRET_ACCESS_KEY: "${S3_SECRET_ACCESS_KEY:-seaweedfsadmin}" S3_SECRET_ACCESS_KEY: "${S3_SECRET_ACCESS_KEY:-seaweedfsadmin}"
volumes: volumes:
- "${SHARED_FILESYSTEM:-/tmp}:/tmp" - "${SHARED_FILESYSTEM:-/tmp}:/tmp"
...@@ -287,10 +286,9 @@ services: ...@@ -287,10 +286,9 @@ services:
- "3305:8080" - "3305:8080"
environment: environment:
S3_ACCESS_KEY_ID: "${S3_ACCESS_KEY_ID:-seaweedfsadmin}" S3_ACCESS_KEY_ID: "${S3_ACCESS_KEY_ID:-seaweedfsadmin}"
S3_BUCKET: "${S3_BUCKET:-dbrepo}"
S3_ENDPOINT: "${S3_ENDPOINT:-http://storage-service:9000}" S3_ENDPOINT: "${S3_ENDPOINT:-http://storage-service:9000}"
S3_EXPORT_BUCKET: "${S3_EXPORT_BUCKET:-dbrepo-download}"
S3_FILE_PATH: "${S3_FILE_PATH:-/tmp}" S3_FILE_PATH: "${S3_FILE_PATH:-/tmp}"
S3_IMPORT_BUCKET: "${S3_IMPORT_BUCKET:-dbrepo-upload}"
S3_SECRET_ACCESS_KEY: "${S3_SECRET_ACCESS_KEY:-seaweedfsadmin}" S3_SECRET_ACCESS_KEY: "${S3_SECRET_ACCESS_KEY:-seaweedfsadmin}"
volumes: volumes:
- "${SHARED_FILESYSTEM:-/tmp}:/tmp" - "${SHARED_FILESYSTEM:-/tmp}:/tmp"
...@@ -439,7 +437,8 @@ services: ...@@ -439,7 +437,8 @@ services:
context: ./dbrepo-storage-service/init context: ./dbrepo-storage-service/init
network: host network: host
environment: environment:
SEAWEEDFS_ENDPOINT: "${STORAGE_SEAWEEDFS_ENDPOINT:-storage-service:9333}" WEED_CLUSTER_SW_MASTER: "${STORAGE_SERVICE_MASTER_ENDPOINT:-storage-service:9333}"
S3_BUCKET: "${S3_BUCKET:-dbrepo}"
depends_on: depends_on:
dbrepo-storage-service: dbrepo-storage-service:
condition: service_healthy condition: service_healthy
...@@ -452,9 +451,11 @@ services: ...@@ -452,9 +451,11 @@ services:
hostname: upload-service hostname: upload-service
image: docker.io/tusproject/tusd:v2.4.0 image: docker.io/tusproject/tusd:v2.4.0
command: command:
- "--base-path=/api/upload/files/" - "-behind-proxy"
- "-max-size=2000000000"
- "-base-path=/api/upload/files/"
- "-s3-endpoint=${STORAGE_ENDPOINT:-http://storage-service:9000}" - "-s3-endpoint=${STORAGE_ENDPOINT:-http://storage-service:9000}"
- "-s3-bucket=dbrepo-upload" - "-s3-bucket=dbrepo"
environment: environment:
AWS_ACCESS_KEY_ID: "${STORAGE_USERNAME:-seaweedfsadmin}" AWS_ACCESS_KEY_ID: "${STORAGE_USERNAME:-seaweedfsadmin}"
AWS_SECRET_ACCESS_KEY: "${STORAGE_PASSWORD:-seaweedfsadmin}" AWS_SECRET_ACCESS_KEY: "${STORAGE_PASSWORD:-seaweedfsadmin}"
...@@ -509,8 +510,8 @@ services: ...@@ -509,8 +510,8 @@ services:
REQUEUE_REJECTED: ${REQUEUE_REJECTED:-false} REQUEUE_REJECTED: ${REQUEUE_REJECTED:-false}
ROUTING_KEY: "${ROUTING_KEY:-dbrepo.#}" ROUTING_KEY: "${ROUTING_KEY:-dbrepo.#}"
S3_ACCESS_KEY_ID: "${S3_ACCESS_KEY_ID:-seaweedfsadmin}" S3_ACCESS_KEY_ID: "${S3_ACCESS_KEY_ID:-seaweedfsadmin}"
S3_BUCKET: "${S3_BUCKET:-dbrepo}"
S3_ENDPOINT: "${S3_ENDPOINT:-http://storage-service:9000}" S3_ENDPOINT: "${S3_ENDPOINT:-http://storage-service:9000}"
S3_EXPORT_BUCKET: "${S3_EXPORT_BUCKET:-dbrepo-download}"
S3_FILE_PATH: "${S3_FILE_PATH:-/tmp}" S3_FILE_PATH: "${S3_FILE_PATH:-/tmp}"
S3_IMPORT_BUCKET: "${S3_IMPORT_BUCKET:-dbrepo-upload}" S3_IMPORT_BUCKET: "${S3_IMPORT_BUCKET:-dbrepo-upload}"
S3_SECRET_ACCESS_KEY: "${S3_SECRET_ACCESS_KEY:-seaweedfsadmin}" S3_SECRET_ACCESS_KEY: "${S3_SECRET_ACCESS_KEY:-seaweedfsadmin}"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment