Skip to content

Commit 71e3149

Browse files
committed
Made requested changes
1 parent 23a546d commit 71e3149

File tree

6 files changed

+0
-17
lines changed

6 files changed

+0
-17
lines changed

deploy/docker/docker-compose.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ services:
4848
- TLS_KEYSTORE_PASSWORD=passw0rd
4949
- TLS_KEY_PASSWORD=passw0rd
5050
- TLS_KEY_ALIAS=identity
51-
5251
depends_on:
5352
postgresdb:
5453
condition: service_healthy

deploy/helm/templates/identity/config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,3 @@ data:
3737
TLS_KEYSTORE_PASSWORD: {{ .Values.identity.config.keyStorePassword }}
3838
TLS_KEY_PASSWORD: {{ .Values.identity.config.keyPassword }}
3939
TLS_KEY_ALIAS: {{ .Values.identity.config.keyAlias }}
40-
ADMIN_EMAILS: {{ .Values.identity.config.adminEmails | quote }}

deploy/helm/values.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ identity:
7777
keyStorePassword: passw0rd
7878
keyPassword: passw0rd
7979
keyAlias: identity
80-
adminEmails: [email protected]
8180
deploymentLabels:
8281
app: crapi-identity
8382
podLabels:

services/identity/src/main/java/com/crapi/service/Impl/UserServiceImpl.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,10 @@
3333
import jakarta.servlet.http.HttpServletRequest;
3434
import jakarta.transaction.Transactional;
3535
import java.text.ParseException;
36-
import java.util.Arrays;
37-
import java.util.List;
3836
import lombok.extern.slf4j.Slf4j;
3937
import org.apache.logging.log4j.LogManager;
4038
import org.apache.logging.log4j.core.impl.Log4jContextFactory;
4139
import org.springframework.beans.factory.annotation.Autowired;
42-
import org.springframework.beans.factory.annotation.Value;
4340
import org.springframework.http.HttpStatus;
4441
import org.springframework.http.ResponseEntity;
4542
import org.springframework.security.authentication.AuthenticationManager;
@@ -76,9 +73,6 @@ public class UserServiceImpl implements UserService {
7673

7774
@Autowired ChangePhoneRepository changePhoneRepository;
7875

79-
@Value("${app.admin.emails}")
80-
private String adminEmails;
81-
8276
public UserServiceImpl() {
8377
setFactory(log4jContextFactory);
8478
LOG4J_LOGGER = LogManager.getLogger(UserService.class);
@@ -491,11 +485,6 @@ public ApiKeyResponse generateApiKey(HttpServletRequest request, LoginForm login
491485
log.debug("User not found to generate API key");
492486
return new ApiKeyResponse(null, UserMessage.INVALID_CREDENTIALS);
493487
}
494-
List<String> adminEmailList = Arrays.asList(adminEmails.split(","));
495-
if (!adminEmailList.contains(user.getEmail())) {
496-
log.debug("User {} is not authorized to generate API Key", user.getEmail());
497-
return new ApiKeyResponse(null, UserMessage.API_KEY_GENERATION_FAILED);
498-
}
499488
// if apiKey is already generated
500489
if (user.getApiKey() != null) {
501490
log.debug("Api Key already generated for user: {}", user.getEmail());

services/identity/src/main/resources/application.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ mail.mailhog.domain=${MAILHOG_DOMAIN}
4242

4343
app.enable_shell_injection=${ENABLE_SHELL_INJECTION}
4444
app.service.name=crapi-identity
45-
app.admin.emails=${ADMIN_EMAILS}
4645

4746
api.gateway.url=${API_GATEWAY_URL}
4847

services/identity/src/test/java/com/crapi/service/Impl/UserServiceImplTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
6767
import org.springframework.security.core.Authentication;
6868
import org.springframework.security.crypto.password.PasswordEncoder;
69-
import org.springframework.test.util.ReflectionTestUtils;
7069

7170
@RunWith(MockitoJUnitRunner.class)
7271
public class UserServiceImplTest {
@@ -158,7 +157,6 @@ public void testAuthenticateUserApiKey() throws UnsupportedEncodingException {
158157
Mockito.when(authenticationManager.authenticate(Mockito.any(Authentication.class)))
159158
.thenReturn(mockAuth);
160159
Mockito.when(userRepository.findByEmail(Mockito.anyString())).thenReturn(user);
161-
ReflectionTestUtils.setField(userService, "adminEmails", user.getEmail());
162160
ApiKeyResponse jwtResponse = userService.generateApiKey(getMockHttpRequest(), loginForm);
163161
Assertions.assertEquals(jwtResponse.getApiKey(), "sampleApiKey");
164162
}

0 commit comments

Comments
 (0)