Skip to content
Snippets Groups Projects
Commit 59a2997a authored by Dmitrii Gerashchenko's avatar Dmitrii Gerashchenko
Browse files

Merge branch 'master' into 6912-whitesource

parents 98db80ac ea16a97d
No related branches found
No related tags found
1 merge request!117Upgrade vulnerable dependencies according to WhiteSource alerts
Showing with 66 additions and 15 deletions
......@@ -24,7 +24,7 @@ image:
branch: master
tag: latest
istioDnsHost: ""
istioDnsHost: "contoso.com"
env: demo
......
......@@ -4,7 +4,9 @@
package org.opengroup.osdu.partition.provider.ibm.security;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.partition.provider.interfaces.IAuthorizationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.security.core.Authentication;
......@@ -20,6 +22,9 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
public class AuthorizationService implements IAuthorizationService {
@Autowired
DpsHeaders dpsheaders;
@Value("${service.partition.admin.user}")
String partitionAdminUser;
......@@ -27,20 +32,15 @@ public class AuthorizationService implements IAuthorizationService {
@Override
public boolean isDomainAdminServiceAccount() {
try {
final Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
Jwt principal = (Jwt) authentication.getPrincipal();
String memberEmail = principal.getClaimAsString("email");
// @SuppressWarnings("unchecked")
// KeycloakPrincipal<KeycloakSecurityContext> principal = (KeycloakPrincipal<KeycloakSecurityContext>) auth.getPrincipal();
// String upn = principal.getName();
log.debug("email : "+memberEmail);
if(memberEmail.equals(partitionAdminUser)) {
String userId = dpsheaders.getUserId();
log.debug("logged in email : " + userId);
if(userId != null && partitionAdminUser != null && userId.equals(partitionAdminUser)) {
return true;
}
else {
} else {
throw AppException.createUnauthorized("Unauthorized. The user is not Service Principal");
}
}
catch (AppException e) {
throw e;
......
......@@ -15,8 +15,9 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.httpBasic().disable()
.csrf().disable().authorizeRequests().anyRequest()
.authenticated().and().oauth2ResourceServer().jwt();
.csrf().disable();
//.authorizeRequests().anyRequest()
//.authenticated().and().oauth2ResourceServer().jwt();
}
}
......
......@@ -3,10 +3,14 @@
package org.opengroup.osdu.partition.api;
import static org.junit.Assert.assertEquals;
import org.junit.After;
import org.junit.Before;
import org.opengroup.osdu.partition.util.IBMTestUtils;
import com.sun.jersey.api.client.ClientResponse;
public class TestCreatePartition extends CreatePartitionTest {
@Before
......@@ -20,6 +24,14 @@ public class TestCreatePartition extends CreatePartitionTest {
public void tearDown() {
this.testUtils = null;
}
//servicemesh changes response code - 403
@Override
public void should_return401_when_makingHttpRequestWithoutToken() throws Exception {
ClientResponse response = descriptor.run(getId(), "");
assertEquals(error(response.getEntity(String.class)), 403, response.getStatus());
}
}
......@@ -3,10 +3,14 @@
package org.opengroup.osdu.partition.api;
import static org.junit.Assert.assertEquals;
import org.junit.After;
import org.junit.Before;
import org.opengroup.osdu.partition.util.IBMTestUtils;
import com.sun.jersey.api.client.ClientResponse;
public class TestDeletePartition extends DeletePartitionTest {
@Before
......@@ -20,5 +24,12 @@ public class TestDeletePartition extends DeletePartitionTest {
public void tearDown() {
this.testUtils = null;
}
//servicemesh changes response code - 403
@Override
public void should_return401_when_makingHttpRequestWithoutToken() throws Exception {
ClientResponse response = descriptor.run(getId(), "");
assertEquals(error(response.getEntity(String.class)), 403, response.getStatus());
}
}
......@@ -25,5 +25,12 @@ public class TestGetPartitionById extends GetPartitionByIdApitTest {
public void tearDown() {
this.testUtils = null;
}
//servicemesh changes response code - 403
@Override
public void should_return401_when_makingHttpRequestWithoutToken() throws Exception {
ClientResponse response = descriptor.run(getId(), "");
assertEquals(error(response.getEntity(String.class)), 403, response.getStatus());
}
}
......@@ -3,10 +3,14 @@
package org.opengroup.osdu.partition.api;
import static org.junit.Assert.assertEquals;
import org.junit.After;
import org.junit.Before;
import org.opengroup.osdu.partition.util.IBMTestUtils;
import com.sun.jersey.api.client.ClientResponse;
public class TestListPartitions extends ListPartitionsApitTest {
@Before
......@@ -20,5 +24,13 @@ public class TestListPartitions extends ListPartitionsApitTest {
public void tearDown() {
this.testUtils = null;
}
//servicemesh changes response code - 403
@Override
public void should_return401_when_makingHttpRequestWithoutToken() throws Exception {
ClientResponse response = descriptor.run(getId(), "");
assertEquals(error(response.getEntity(String.class)), 403, response.getStatus());
}
}
......@@ -25,5 +25,13 @@ public class TestUpdatePartition extends UpdatePartitionTest {
public void tearDown() {
this.testUtils = null;
}
//servicemesh changes response code - 403
@Override
public void should_return401_when_makingHttpRequestWithoutToken() throws Exception {
ClientResponse response = descriptor.run(getId(), "");
assertEquals(error(response.getEntity(String.class)), 403, response.getStatus());
}
}
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