Skip to content

Commit

Permalink
OP-22435: Bugfix spin cli trigger a pipeline user is admin or not for…
Browse files Browse the repository at this point in the history
… custom gate. (#483)
  • Loading branch information
emanipravallika authored Sep 13, 2024
1 parent e69c588 commit 4cb53a5
Show file tree
Hide file tree
Showing 10 changed files with 100 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class ApplicationIdRbacInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
log.debug("Start of the preHandle -- ApplicationIdRbacInterceptor");
try {
log.info(
"Request intercepted for authorizing if the user is having enough access to perform the action");
Expand All @@ -43,7 +44,7 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons
} catch (NumberFormatException nfe) {
log.debug("Ignoring the rbac check as it threw number format exception");
}

log.debug("End of the preHandle -- ApplicationIdRbacInterceptor");
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class ApprovalGateIdRbacInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {

log.debug("Start of the preHandle -- ApprovalGateIdRbacInterceptor");
try {
log.info(
"Request intercepted for authorizing if the user is having enough access to perform the action");
Expand All @@ -44,7 +44,7 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons
} catch (NumberFormatException nfe) {
log.debug("Ignoring the rbac check as it threw number format exception");
}

log.debug("End of the preHandle -- ApprovalGateIdRbacInterceptor");
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class ApprovalGateInstanceIdRbacInterceptor implements HandlerInterceptor
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {

log.debug("Start of the preHandle -- ApprovalGateInstanceIdRbacInterceptor");
try {
log.info(
"Request intercepted for authorizing if the user is having enough access to perform the action");
Expand All @@ -44,7 +44,7 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons
} catch (NumberFormatException nfe) {
log.debug("Ignoring the rbac check as it threw number format exception");
}

log.debug("End of the preHandle -- ApprovalGateInstanceIdRbacInterceptor");
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class ApprovalPolicyIdInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {

log.debug("Start of the preHandle -- ApprovalPolicyIdInterceptor");
try {
log.info(
"Request intercepted for authorizing if the user is having enough access to perform the action");
Expand All @@ -44,7 +44,7 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons
} catch (NumberFormatException nfe) {
log.debug("Ignoring the rbac check as it threw number format exception");
}

log.debug("End of the preHandle -- ApprovalPolicyIdInterceptor");
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class CustomGatesTriggerRbacInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {

log.debug("Start of the preHandle -- CustomGatesTriggerRbacInterceptor");
Optional.ofNullable(request.getHeader("x-spinnaker-user"))
.orElseThrow(
() -> new XSpinnakerUserHeaderMissingException("x-spinnaker-user header missing"));
Expand All @@ -50,7 +50,7 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons
} catch (NumberFormatException nfe) {
log.debug("Ignoring the rbac check as it threw number format exception");
}

log.debug("End of the preHandle -- CustomGatesTriggerRbacInterceptor");
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@ public class FeatureVisibilityRbacInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
log.info("request intercepted to authorize if the user is having feature visibility");
log.debug("Start of the preHandle -- FeatureVisibilityRbacInterceptor");
log.info("request intercepted to authorize if the user is having feature visibility ");
String origin = request.getHeader(HttpHeaders.ORIGIN);
if (origin != null && customGatePlugins.contains(origin)) {
return true;
}
applicationFeatureRbac.authorizeUserForFeatureVisibility(request.getUserPrincipal().getName());
log.debug("End of the preHandle -- FeatureVisibilityRbacInterceptor");
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class GateIdRbacInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {

log.debug("Start of the preHandle -- GateIdRbacInterceptor");
try {
log.info(
"Request intercepted for authorizing if the user is having enough access to perform the action");
Expand All @@ -44,7 +44,7 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons
} catch (NumberFormatException nfe) {
log.debug("Ignoring the rbac check as it threw number format exception");
}

log.debug("End of the preHandle -- GateIdRbacInterceptor");
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class PipelineIdRbacInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
log.debug("Start of the preHandle -- PipelineIdRbacInterceptor");
try {
log.info(
"Request intercepted for authorizing if the user is having enough access to perform the action");
Expand All @@ -59,7 +60,7 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons
} catch (NumberFormatException nfe) {
log.debug("Ignoring the rbac check as it threw number format exception");
}

log.debug("End of the preHandle -- PipelineIdRbacInterceptor");
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class ServiceIdRbacInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
log.debug("Start of the preHandle -- ServiceIdRbacInterceptor");
try {
log.info(
"Request intercepted for authorizing if the user is having enough access to perform the action");
Expand All @@ -43,7 +44,7 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons
} catch (NumberFormatException nfe) {
log.debug("Ignoring the rbac check as it threw number format exception");
}

log.debug("End of the preHandle -- ServiceIdRbacInterceptor");
return true;
}
}
Loading

0 comments on commit 4cb53a5

Please sign in to comment.