Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/github_actions/actions/cache-4.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
programmiri authored Dec 18, 2024
2 parents 9095869 + 3dc59c2 commit 6906573
Show file tree
Hide file tree
Showing 39 changed files with 1,711 additions and 1,924 deletions.
4 changes: 2 additions & 2 deletions coral/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"react-hook-form": "^7.53.2",
"react-markdown": "^9.0.1",
"react-router-dom": "^6.27.0",
"react-syntax-highlighter": "^15.5.0",
"react-syntax-highlighter": "^15.6.1",
"rehype-parse": "^9.0.1",
"rehype-remark": "^10.0.0",
"rehype-sanitize": "^6.0.0",
Expand Down Expand Up @@ -96,7 +96,7 @@
"openapi-typescript": "^7.4.3",
"prettier": "^3.3.3",
"prop-types": "^15.8.1",
"react-aria": "^3.34.3",
"react-aria": "^3.36.0",
"react-test-renderer": "^18.3.1",
"rollup-plugin-visualizer": "^5.12.0",
"ts-jest": "^29.2.5",
Expand Down
2,490 changes: 1,200 additions & 1,290 deletions coral/pnpm-lock.yaml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<apachecommons.version>2.16.1</apachecommons.version>
<apachepoi.version>5.3.0</apachepoi.version>
<commons-text.version>1.12.0</commons-text.version>
<exec-maven-plugin.version>3.4.1</exec-maven-plugin.version>
<exec-maven-plugin.version>3.5.0</exec-maven-plugin.version>
<clean-maven-plugin.version>3.4.0</clean-maven-plugin.version>
<front-end-maven-plugin.version>1.12.1</front-end-maven-plugin.version>
<h2.version>2.1.214</h2.version>
Expand All @@ -33,7 +33,7 @@
<node.version>v18.12.1</node.version>
<npm.version>8.19.2</npm.version>
<pnpm.version>8.7.1</pnpm.version>
<shedlock.version>5.16.0</shedlock.version>
<shedlock.version>6.0.2</shedlock.version>
<snakeyaml.version>1.33</snakeyaml.version>
<springdoc-openapi-maven-plugin.version>1.4</springdoc-openapi-maven-plugin.version>
<springdoc-openapi-ui.version>2.6.0</springdoc-openapi-ui.version>
Expand Down
19 changes: 7 additions & 12 deletions core/src/main/java/io/aiven/klaw/service/AclControllerService.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;

@Service
Expand Down Expand Up @@ -100,7 +99,7 @@ public ApiResponse createAcl(AclRequestsModel aclRequestsModel) throws KlawExcep
aclRequestsModel.setRequestingteam(commonUtilsService.getTeamId(currentUserName));

if (commonUtilsService.isNotAuthorizedUser(
getPrincipal(), PermissionType.REQUEST_CREATE_SUBSCRIPTIONS)) {
commonUtilsService.getPrincipal(), PermissionType.REQUEST_CREATE_SUBSCRIPTIONS)) {
return ApiResponse.NOT_AUTHORIZED;
}

Expand Down Expand Up @@ -454,7 +453,7 @@ public List<AclRequestsResponseModel> getAclRequestsForApprover(

// get requests relevant to your teams or all teams
if (commonUtilsService.isNotAuthorizedUser(
getPrincipal(), PermissionType.APPROVE_ALL_REQUESTS_TEAMS)) {
commonUtilsService.getPrincipal(), PermissionType.APPROVE_ALL_REQUESTS_TEAMS)) {
createdAclReqs =
manageDatabase
.getHandleDbRequests()
Expand Down Expand Up @@ -521,7 +520,7 @@ private List<AclRequestsResponseModel> updateCreatAclReqsList(
public ApiResponse deleteAclRequests(String req_no) throws KlawException {
try {
if (commonUtilsService.isNotAuthorizedUser(
getPrincipal(), PermissionType.REQUEST_CREATE_SUBSCRIPTIONS)) {
commonUtilsService.getPrincipal(), PermissionType.REQUEST_CREATE_SUBSCRIPTIONS)) {
return ApiResponse.NOT_AUTHORIZED;
}
String userName = getCurrentUserName();
Expand All @@ -544,7 +543,7 @@ public ApiResponse claimAcl(int aclId) throws KlawException {
log.info("claimAcl {}", aclId);

if (commonUtilsService.isNotAuthorizedUser(
getPrincipal(), PermissionType.REQUEST_CREATE_SUBSCRIPTIONS)) {
commonUtilsService.getPrincipal(), PermissionType.REQUEST_CREATE_SUBSCRIPTIONS)) {
return ApiResponse.NOT_AUTHORIZED;
}

Expand Down Expand Up @@ -619,7 +618,7 @@ public ApiResponse createDeleteAclSubscriptionRequest(String req_no) throws Klaw
log.info("createDeleteAclSubscriptionRequest {}", req_no);
final String userName = getCurrentUserName();
if (commonUtilsService.isNotAuthorizedUser(
getPrincipal(), PermissionType.REQUEST_DELETE_SUBSCRIPTIONS)) {
commonUtilsService.getPrincipal(), PermissionType.REQUEST_DELETE_SUBSCRIPTIONS)) {
return ApiResponse.NOT_AUTHORIZED;
}

Expand Down Expand Up @@ -677,7 +676,7 @@ public ApiResponse approveAclRequests(String req_no)
final String userDetails = getCurrentUserName();
int tenantId = commonUtilsService.getTenantId(userDetails);
if (commonUtilsService.isNotAuthorizedUser(
getPrincipal(), PermissionType.APPROVE_SUBSCRIPTIONS)) {
commonUtilsService.getPrincipal(), PermissionType.APPROVE_SUBSCRIPTIONS)) {
return ApiResponse.NOT_AUTHORIZED;
}

Expand Down Expand Up @@ -1033,7 +1032,7 @@ public ApiResponse declineAclRequests(String req_no, String reasonToDecline)

String userDetails = getCurrentUserName();
if (commonUtilsService.isNotAuthorizedUser(
getPrincipal(), PermissionType.APPROVE_SUBSCRIPTIONS)) {
commonUtilsService.getPrincipal(), PermissionType.APPROVE_SUBSCRIPTIONS)) {
return ApiResponse.NOT_AUTHORIZED;
}

Expand Down Expand Up @@ -1111,10 +1110,6 @@ public List<OffsetDetails> getConsumerOffsets(
return consumerOffsetInfoList;
}

private Object getPrincipal() {
return SecurityContextHolder.getContext().getAuthentication().getPrincipal();
}

public ServiceAccountDetails getAivenServiceAccountDetails(
String envId, String topicName, String serviceAccount, String aclReqNo) {
String loggedInUser = getCurrentUserName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;

@Service
Expand Down Expand Up @@ -82,7 +81,8 @@ public ApiResponse updateSyncAcls(List<SyncAclUpdates> syncAclUpdates) throws Kl
String userName = getUserName();
int tenantId = commonUtilsService.getTenantId(userName);

if (commonUtilsService.isNotAuthorizedUser(getPrincipal(), PermissionType.SYNC_SUBSCRIPTIONS)) {
if (commonUtilsService.isNotAuthorizedUser(
commonUtilsService.getPrincipal(), PermissionType.SYNC_SUBSCRIPTIONS)) {
return ApiResponse.NOT_AUTHORIZED;
}

Expand Down Expand Up @@ -179,7 +179,7 @@ public ApiResponse updateSyncBackAcls(SyncBackAcls syncBackAcls) throws KlawExce
logArray.add("Type of Sync " + syncBackAcls.getTypeOfSync());

if (commonUtilsService.isNotAuthorizedUser(
getPrincipal(), PermissionType.SYNC_BACK_SUBSCRIPTIONS)) {
commonUtilsService.getPrincipal(), PermissionType.SYNC_BACK_SUBSCRIPTIONS)) {
return ApiResponse.NOT_AUTHORIZED;
}

Expand Down Expand Up @@ -395,7 +395,8 @@ public List<AclInfo> getSyncAcls(
topicNameSearch = topicNameSearch.trim();
}

if (commonUtilsService.isNotAuthorizedUser(getPrincipal(), PermissionType.SYNC_SUBSCRIPTIONS)) {
if (commonUtilsService.isNotAuthorizedUser(
commonUtilsService.getPrincipal(), PermissionType.SYNC_SUBSCRIPTIONS)) {
return null;
}

Expand Down Expand Up @@ -440,7 +441,7 @@ public List<AclInfo> getSyncBackAcls(

int tenantId = commonUtilsService.getTenantId(userName);
if (commonUtilsService.isNotAuthorizedUser(
getPrincipal(), PermissionType.SYNC_BACK_SUBSCRIPTIONS)) {
commonUtilsService.getPrincipal(), PermissionType.SYNC_BACK_SUBSCRIPTIONS)) {
return null;
}

Expand Down Expand Up @@ -698,7 +699,7 @@ private boolean verifyIfTopicExists(

private List<String> tenantFiltering(List<String> teamList) {
if (!commonUtilsService.isNotAuthorizedUser(
getPrincipal(),
commonUtilsService.getPrincipal(),
Set.of(
PermissionType.SYNC_BACK_SUBSCRIPTIONS,
PermissionType.SYNC_TOPICS,
Expand Down Expand Up @@ -726,7 +727,7 @@ private int counterIncrement() {
}

private String getUserName() {
return mailService.getUserName(getPrincipal());
return mailService.getUserName(commonUtilsService.getPrincipal());
}

public Env getEnvDetails(String envId, int tenantId) {
Expand All @@ -737,8 +738,4 @@ public Env getEnvDetails(String envId, int tenantId) {
.findFirst();
return envFound.orElse(null);
}

private Object getPrincipal() {
return SecurityContextHolder.getContext().getAuthentication().getPrincipal();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;

@Service
Expand Down Expand Up @@ -343,7 +342,8 @@ public List<TeamOverview> getTeamsOverview(String forTeam, int numberOfDays) {
final String currentUserName = getCurrentUserName();
Integer userTeamId = commonUtilsService.getTeamId(currentUserName);

if (commonUtilsService.isNotAuthorizedUser(getPrincipal(), PermissionType.ALL_TEAMS_REPORTS)) {
if (commonUtilsService.isNotAuthorizedUser(
commonUtilsService.getPrincipal(), PermissionType.ALL_TEAMS_REPORTS)) {
int tenantId = commonUtilsService.getTenantId(currentUserName);

teamOverview.setProducerAclsPerTeamsOverview(
Expand Down Expand Up @@ -593,7 +593,8 @@ private Map<String, List<String>> getTopicNames(int tenantId) {
final Set<String> allowedEnvIdSet = commonUtilsService.getEnvsFromUserId(getCurrentUserName());

Map<String, List<String>> topicsPerEnv = new HashMap<>();
if (commonUtilsService.isNotAuthorizedUser(getPrincipal(), PermissionType.ALL_TEAMS_REPORTS)) {
if (commonUtilsService.isNotAuthorizedUser(
commonUtilsService.getPrincipal(), PermissionType.ALL_TEAMS_REPORTS)) {
// normal user
Integer userTeamId = commonUtilsService.getTeamId(getCurrentUserName());
List<Topic> topics =
Expand Down Expand Up @@ -630,7 +631,8 @@ private Map<String, List<String>> getConsumerGroups(int tenantId) {
final Set<String> allowedEnvIdSet = commonUtilsService.getEnvsFromUserId(getCurrentUserName());

Map<String, List<String>> aclsPerEnv = new HashMap<>();
if (commonUtilsService.isNotAuthorizedUser(getPrincipal(), PermissionType.ALL_TEAMS_REPORTS)) {
if (commonUtilsService.isNotAuthorizedUser(
commonUtilsService.getPrincipal(), PermissionType.ALL_TEAMS_REPORTS)) {
// normal user
Integer userTeamId = commonUtilsService.getTeamId(getCurrentUserName());
List<Acl> acls =
Expand Down Expand Up @@ -665,8 +667,4 @@ private Map<String, List<String>> getConsumerGroups(int tenantId) {

return aclsPerEnv;
}

private Object getPrincipal() {
return SecurityContextHolder.getContext().getAuthentication().getPrincipal();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;

@Slf4j
Expand Down Expand Up @@ -333,11 +332,7 @@ protected void generatePromotionDetails(
}

protected String getUserName() {
return mailService.getUserName(getPrincipal());
}

protected Object getPrincipal() {
return SecurityContextHolder.getContext().getAuthentication().getPrincipal();
return mailService.getUserName(commonUtilsService.getPrincipal());
}

protected Env getEnvDetails(String envId, int tenantId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void setServices(ClusterApiService clusterApiService, MailUtils mailServi
}

private boolean isAuthorizedFor(PermissionType type) {
return !commonUtilsService.isNotAuthorizedUser(getPrincipal(), type);
return !commonUtilsService.isNotAuthorizedUser(commonUtilsService.getPrincipal(), type);
}

public synchronized EnvModelResponse getEnvDetails(String envSelected, String clusterType) {
Expand Down Expand Up @@ -392,7 +392,8 @@ public List<EnvModelResponse> getKafkaConnectEnvs() {
int tenantId = getUserDetails(userName).getTenantId();
List<Env> listEnvs = manageDatabase.getKafkaConnectEnvList(tenantId);

if (commonUtilsService.isNotAuthorizedUser(getPrincipal(), ADD_EDIT_DELETE_ENVS)) {
if (commonUtilsService.isNotAuthorizedUser(
commonUtilsService.getPrincipal(), ADD_EDIT_DELETE_ENVS)) {
final Set<String> allowedEnvIdSet = commonUtilsService.getEnvsFromUserId(userName);
listEnvs =
listEnvs.stream().filter(env -> allowedEnvIdSet.contains(env.getId())).collect(toList());
Expand Down Expand Up @@ -730,7 +731,7 @@ private void associateWithKafkaEnv(EnvTag envTag, String envId, String envName,
}

private String getUserName() {
return mailService.getUserName(getPrincipal());
return mailService.getUserName(commonUtilsService.getPrincipal());
}

private Boolean isUserSuperAdmin() {
Expand Down Expand Up @@ -858,10 +859,6 @@ public KwTenantModel getMyTenantInfo() {
return kwTenantModel;
}

private Object getPrincipal() {
return SecurityContextHolder.getContext().getAuthentication().getPrincipal();
}

public ApiResponse deleteTenant() throws KlawException {
if (!isAuthorizedFor(UPDATE_DELETE_MY_TENANT)) {
return ApiResponse.NOT_AUTHORIZED;
Expand Down Expand Up @@ -907,7 +904,7 @@ public ApiResponse deleteTenant() throws KlawException {

public ApiResponse updateTenant(KwTenantModel kwTenantModel) throws KlawException {
if (commonUtilsService.isNotAuthorizedUser(
getPrincipal(), PermissionType.UPDATE_DELETE_MY_TENANT)) {
commonUtilsService.getPrincipal(), PermissionType.UPDATE_DELETE_MY_TENANT)) {
return ApiResponse.NOT_AUTHORIZED;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
import org.jasypt.util.text.BasicTextEncryptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.HttpServerErrorException;
Expand Down Expand Up @@ -111,7 +110,7 @@ public ApiResponse createConnectorRequest(KafkaConnectorRequestModel connectorRe
String userName = getUserName();

if (commonUtilsService.isNotAuthorizedUser(
getPrincipal(), PermissionType.REQUEST_CREATE_CONNECTORS)) {
commonUtilsService.getPrincipal(), PermissionType.REQUEST_CREATE_CONNECTORS)) {
return ApiResponse.NOT_AUTHORIZED;
}

Expand Down Expand Up @@ -504,7 +503,7 @@ public ApiResponse restartConnector(KafkaConnectorRestartModel kafkaConnectorRes
int tenantId = commonUtilsService.getTenantId(getUserName());
try {
if (commonUtilsService.isNotAuthorizedUser(
getPrincipal(), PermissionType.MANAGE_CONNECTORS)) {
commonUtilsService.getPrincipal(), PermissionType.MANAGE_CONNECTORS)) {
return ApiResponse.NOT_AUTHORIZED;
}
return clusterApiService.restartConnector(kafkaConnectorRestartModel, tenantId);
Expand All @@ -528,7 +527,7 @@ public List<KafkaConnectorRequestsResponseModel> getCreatedConnectorRequests(

// get requests relevant to your teams or all teams
if (commonUtilsService.isNotAuthorizedUser(
getPrincipal(), PermissionType.APPROVE_ALL_REQUESTS_TEAMS))
commonUtilsService.getPrincipal(), PermissionType.APPROVE_ALL_REQUESTS_TEAMS))
createdTopicReqList =
manageDatabase
.getHandleDbRequests()
Expand Down Expand Up @@ -637,7 +636,8 @@ public ApiResponse approveConnectorRequests(String connectorId)
String userDetails = getUserName();
int tenantId = commonUtilsService.getTenantId(getUserName());

if (commonUtilsService.isNotAuthorizedUser(getPrincipal(), PermissionType.APPROVE_CONNECTORS)) {
if (commonUtilsService.isNotAuthorizedUser(
commonUtilsService.getPrincipal(), PermissionType.APPROVE_CONNECTORS)) {
return ApiResponse.NOT_AUTHORIZED;
}

Expand Down Expand Up @@ -788,7 +788,8 @@ public ApiResponse declineConnectorRequests(String connectorId, String reasonFor
throws KlawException {
log.info("declineConnectorRequests {} {}", connectorId, reasonForDecline);
String userDetails = getUserName();
if (commonUtilsService.isNotAuthorizedUser(getPrincipal(), PermissionType.APPROVE_CONNECTORS)) {
if (commonUtilsService.isNotAuthorizedUser(
commonUtilsService.getPrincipal(), PermissionType.APPROVE_CONNECTORS)) {
return ApiResponse.NOT_AUTHORIZED;
}

Expand Down Expand Up @@ -837,7 +838,7 @@ public ApiResponse createConnectorDeleteRequest(String connectorName, String env
String userDetails = getUserName();

if (commonUtilsService.isNotAuthorizedUser(
getPrincipal(), PermissionType.REQUEST_DELETE_CONNECTORS)) {
commonUtilsService.getPrincipal(), PermissionType.REQUEST_DELETE_CONNECTORS)) {
return ApiResponse.NOT_AUTHORIZED;
}

Expand Down Expand Up @@ -1553,11 +1554,7 @@ private List<KwKafkaConnector> getFilteredConnectorsForTenant(
}

private String getUserName() {
return mailService.getUserName(getPrincipal());
}

private Object getPrincipal() {
return SecurityContextHolder.getContext().getAuthentication().getPrincipal();
return mailService.getUserName(commonUtilsService.getPrincipal());
}

public Env getKafkaConnectEnvDetails(String envId) {
Expand Down
Loading

0 comments on commit 6906573

Please sign in to comment.