Skip to content
Snippets Groups Projects
Commit ceceacf6 authored by Tucker Gary Siegel's avatar Tucker Gary Siegel
Browse files

update

parent e181eb34
No related branches found
Tags 0.10.3
No related merge requests found
...@@ -10,10 +10,8 @@ import java.util.Enumeration; ...@@ -10,10 +10,8 @@ import java.util.Enumeration;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.apache.logging.log4j.Level; import org.apache.logging.log4j.Level;
import org.slf4j.MDC; import org.slf4j.MDC;
...@@ -112,7 +110,9 @@ public class RequestInterceptor implements HandlerInterceptor { ...@@ -112,7 +110,9 @@ public class RequestInterceptor implements HandlerInterceptor {
userId = claims.getUserId(); userId = claims.getUserId();
} }
String ipString = request.getHeader("X-FORWARDED-FOR") != null ? request.getHeader("X-FORWARDED-FOR") : request.getRemoteAddr(); String ipString = request.getHeader("X-FORWARDED-FOR") != null
? request.getHeader("X-FORWARDED-FOR")
: request.getRemoteAddr();
List<String> ips = List.of(); List<String> ips = List.of();
if (ipString != null) { if (ipString != null) {
......
...@@ -7,6 +7,7 @@ import com.mongodb.client.MongoDatabase; ...@@ -7,6 +7,7 @@ import com.mongodb.client.MongoDatabase;
import edu.umd.dawn.common.enums.Role; import edu.umd.dawn.common.enums.Role;
import edu.umd.dawn.common.exceptions.BaseExceptions; import edu.umd.dawn.common.exceptions.BaseExceptions;
import edu.umd.dawn.common.exceptions.DawnException; import edu.umd.dawn.common.exceptions.DawnException;
import edu.umd.dawn.common.exceptions.DawnExceptionParameters;
import java.util.Optional; import java.util.Optional;
import org.bson.Document; import org.bson.Document;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
...@@ -18,13 +19,21 @@ public class UserAuthService { ...@@ -18,13 +19,21 @@ public class UserAuthService {
private MongoClient mongoClient; private MongoClient mongoClient;
private MongoDatabase mongoDatabase; private MongoDatabase mongoDatabase;
@Value("${common.annotation.mongodb.uri}") @Value("${common.annotation.mongodb.uri:empty}")
private String uri; private String uri;
@Value("${common.annotation.mongodb.database}") @Value("${common.annotation.mongodb.database:empty}")
private String db; private String db;
protected MongoDatabase getDatabase() { protected MongoDatabase getDatabase() {
if (uri.equals("empty") || db.equals("empty")) {
throw new DawnException(new DawnExceptionParameters(
500,
"INTERNAL",
"internal server error",
"mongodb uri or db for authentication via annotation is not provided. Required properties"
+ " are 'common.annotation.mongodb.uri' and 'common.annotation.mongodb.database'"));
}
if (mongoClient == null) { if (mongoClient == null) {
mongoClient = MongoClients.create(uri); mongoClient = MongoClients.create(uri);
} }
......
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