Skip to content

Commit 10f1512

Browse files
TECH_DEBT: Improvements (#1338)
* Moving most env variables from docker-compose.yml file to individual docker profiles within the services * Hardening the UI service (Node/Express) so that it responds with 404 on common routes used for attacks * Ensuring that indexes are auto-created in the report service's startup * CodeRabbit fixes to remove excessive routing block, and make query-dispatch dependent on mssql instead of mongo * Fixed issue with tenant service url being specified in the wrong location, and removed some defaults from the Docker. * Removing issuer uri from .env and associated references in docker-compose. Adding comments to code about the necessity of the `Dummy` class.
1 parent 657b926 commit 10f1512

4 files changed

Lines changed: 15 additions & 6 deletions

File tree

DotNet/Report/Domain/MongoIndexCreationService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public class MongoIndexCreationService : BackgroundService
77
{
88
private readonly ILogger<MongoIndexCreationService> _logger;
99
private readonly IServiceScopeFactory _serviceScopeFactory;
10-
public MongoIndexCreationService(ILogger<MongoIndexCreationService> logger, IServiceScopeFactory factory)
10+
public MongoIndexCreationService(ILogger<MongoIndexCreationService> logger, IServiceScopeFactory factory)
1111
{
1212
_logger = logger;
1313
_serviceScopeFactory = factory;

Java/measureeval/src/main/java/com/lantanagroup/link/measureeval/configs/SecurityConfig.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import com.lantanagroup.link.shared.auth.JwtAuthenticationEntryPoint;
44
import com.lantanagroup.link.shared.auth.JwtAuthenticationFilter;
55
import com.lantanagroup.link.shared.security.SecurityHelper;
6+
import org.slf4j.Logger;
7+
import org.slf4j.LoggerFactory;
68
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
79
import org.springframework.context.annotation.Bean;
810
import org.springframework.context.annotation.ComponentScan;
@@ -39,10 +41,20 @@ public SecurityFilterChain securityFilterChain (HttpSecurity http) throws Except
3941
}
4042
}
4143

44+
/**
45+
* This class is necessary to support @PreAuthorize and @PostAuthorize when
46+
* anonymous mode is enabled. The condition causes the Dummy class to get registered
47+
* and for the @EnableMethodSecurity to be applied, which affects all classes, enabling @PreAuthorize/@PostAuthorize
48+
*/
4249
@ConditionalOnProperty(prefix = "authentication",
43-
name = "enableAnonymousAccess",
50+
name = "anonymous",
4451
havingValue = "false")
4552
@EnableMethodSecurity(prePostEnabled = true)
4653
static class Dummy {
54+
private static final Logger logger = LoggerFactory.getLogger(Dummy.class);
55+
56+
public Dummy() {
57+
logger.info("Anonymous authentication disabled - @EnableMethodSecurity is being applied (authentication.anonymous=false)");
58+
}
4759
}
4860
}

Java/validation/src/main/resources/application-docker.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ spring:
2828
port: 6379
2929

3030
authentication:
31-
enableAnonymousAccess: true
3231
anonymous: true
3332

3433
secret-management:

docker-compose.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ services:
473473
condition: service_completed_successfully
474474
healthcheck:
475475
test: ["CMD", "curl", "-f", "http://localhost:8062/health"]
476-
476+
477477
census:
478478
image: link-census
479479
container_name: link-census
@@ -600,7 +600,6 @@ services:
600600
environment:
601601
SPRING_PROFILES_ACTIVE: docker
602602
spring.kafka.properties.sasl.jaas.config: org.apache.kafka.common.security.plain.PlainLoginModule required username="${KAFKA_SASL_CLIENT_USER}" password="${KAFKA_SASL_CLIENT_PASSWORD}";
603-
spring.security.oauth2.resourceserver.jwt.issuer-uri: ${ISSUER_URI}
604603
ports:
605604
- "8067:8067"
606605
build:
@@ -796,7 +795,6 @@ services:
796795
container_name: link-validation
797796
environment:
798797
SPRING_PROFILES_ACTIVE: docker
799-
spring.security.oauth2.resourceserver.jwt.issuer-uri: ${ISSUER_URI}
800798
spring.datasource.password: ${LINK_DB_PASS}
801799
spring.kafka.properties.sasl.jaas.config: org.apache.kafka.common.security.plain.PlainLoginModule required username="${KAFKA_SASL_CLIENT_USER}" password="${KAFKA_SASL_CLIENT_PASSWORD}";
802800
internal-blob-storage.connection-string: ${AZURITE_CONNECTION_STRING}

0 commit comments

Comments
 (0)