Skip to content
Snippets Groups Projects
Commit 017ea5c5 authored by 천 진강's avatar 천 진강
Browse files

fix: 프로젝트 역할과 권한이 일치하지 않던 문제 해결

parent 1b407531
No related branches found
No related tags found
2 merge requests!15Feat/certificate,!14Feat/main 자잘한 변경 사항들
......@@ -43,10 +43,10 @@ public class AuthInterceptor implements HandlerInterceptor {
if (projectId != null) {
try {
String role = authService.getBestRoleWithinProject(token, projectId).get("role");
if (!role.equals("admin")) {
log.error("Unauthorized Token for URI {}: {}", request.getRequestURI(), request.getRemoteAddr());
authService.getBestRoleWithinProject(token, projectId).get("role");
if (!request.getMethod().equals("GET") && !authService.getBestRoleWithinProject(token, projectId).get("role").equals("admin")) {
throw new CustomException(ErrorCode.UNAUTHORIZED_USER, request.getRequestURI());
}
} catch (Exception e) {
throw new CustomException(ErrorCode.UNAUTHORIZED_USER, request.getRequestURI());
......
......@@ -96,7 +96,6 @@ public class AuthService {
try {
res = restTemplate.postForEntity(url, requestEntity, Map.class);
} catch (Exception e) {
e.printStackTrace();
throw new CustomException(ErrorCode.INVALID_USER_INFO);
}
Map<String, Object> resToken = (Map<String, Object>) res.getBody().get("token");
......@@ -140,7 +139,7 @@ public class AuthService {
try {
requestEntity = new HttpEntity<>(requestBody, headers);
res = restTemplate.postForEntity(url, requestEntity, Map.class);
} catch (RuntimeException e) {
} catch (Exception e) {
return null;
}
......@@ -185,8 +184,7 @@ public class AuthService {
} catch (HttpClientErrorException.Forbidden e) {
return unscopedToken;
}
catch (RuntimeException e) {
e.printStackTrace();
catch (Exception e) {
throw new CustomException(ErrorCode.INVALID_TOKEN);
}
......@@ -290,7 +288,7 @@ public class AuthService {
ResponseEntity<String> res;
try {
res = restTemplate.exchange(url, HttpMethod.GET, requestEntity, String.class);
} catch (HttpClientErrorException.NotFound e) {
} catch (Exception e) {
throw new CustomException(ErrorCode.INVALID_TOKEN);
}
return objectMapper.readTree(res.getBody()).path("token").path("user").path("id").asText();
......@@ -305,7 +303,7 @@ public class AuthService {
ResponseEntity<String> res;
try {
res = restTemplate.exchange(url, HttpMethod.GET, requestEntity, String.class);
} catch (HttpClientErrorException.NotFound e) {
} catch (Exception e) {
throw new CustomException(ErrorCode.INVALID_TOKEN);
}
......@@ -338,8 +336,7 @@ public class AuthService {
ResponseEntity<String> res;
try {
res = restTemplate.exchange(url, HttpMethod.GET, requestEntity, String.class);
} catch (RuntimeException e) {
e.printStackTrace();
} catch (Exception e) {
return false;
}
JsonNode node = objectMapper.readTree(res.getBody()).path("role_assignments");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment