Skip to content

Conversation

@phrocker
Copy link
Contributor

@phrocker phrocker commented Jul 7, 2025

No description provided.

@phrocker phrocker requested a review from Copilot July 7, 2025 11:06
@phrocker
Copy link
Contributor Author

phrocker commented Jul 7, 2025

seems like there is a bug where revoking doesn't work. it causes an error:
DataTables warning: table id=denied-terminal-table - Requested unknown parameter '0' for row 0, column 0.

@copilot

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR replaces full-page reloads with targeted DataTable refreshes for Zero Trust AT management, adds new backend endpoints to filter requests by state/type, and enables conditional Adminer deployment in local Helm scripts.

  • Add DEPLOY_ADMINER flag in deploy-helm.sh for toggling Adminer
  • Expose /list/{state}/{type} API and corresponding service methods for denied/approved JIT requests
  • Refactor view_ztats.html to reload tables via AJAX and update DataTable initializations

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
ops-scripts/local/deploy-helm.sh Introduce DEPLOY_ADMINER default and use in Helm install
dataplane/src/main/java/.../ZeroTrustAccessTokenService.java Add methods for denied/approved terminal and ops requests
api/src/main/resources/templates/sso/ztats/view_ztats.html Replace location.reload() with reload* functions; restructure DataTable setup
api/src/main/java/.../ZeroTrustATApiController.java Add listTypedZtatRequests endpoint with state/type filtering
Comments suppressed due to low confidence (4)

api/src/main/java/io/sentrius/sso/controllers/api/ZeroTrustATApiController.java:330

  • The path parameters are declared as {state}/{type} but client calls use /list/{type} or /list/{state}/{type} inconsistently. Consider swapping the order to /list/{type}/{state} or overloading an endpoint for default state to match client usage.
    @GetMapping("/list/{state}/{type}")

api/src/main/java/io/sentrius/sso/controllers/api/ZeroTrustATApiController.java:399

  • The default switch case logs an invalid type but still returns 200 OK with an empty list. It would be clearer to return a 400 Bad Request for unknown types.
            default:

api/src/main/java/io/sentrius/sso/controllers/api/ZeroTrustATApiController.java:332

  • This new endpoint and its state/type branching logic lack corresponding unit or integration tests. Consider adding tests for each combination of type and state, as well as invalid values.
    public ResponseEntity<?> listTypedZtatRequests(@RequestHeader("Authorization") String token,

dataplane/src/main/java/io/sentrius/sso/core/services/security/ZeroTrustAccessTokenService.java:284

  • [nitpick] New service methods lack Javadoc. Adding brief method descriptions will help maintainers understand each new endpoint’s purpose.
  public List<ZtatDTO> getDeniedJITRequests(User operatingUser) {

Comment on lines 256 to 340
<script>
$(document).ready(function () {
$('#open-terminal-table, #open-ops-table, #approved-terminal-table, #approved-ops-table, #denied-terminal-table, #denied-ops-table').DataTable();
function reloadTerminalTATs() {
$.get('/api/v1/zerotrust/accesstoken/list/terminal', function (data) {
const $table = $('#open-terminal-table').DataTable();
$table.clear();

for (let s of data) {
let actions = '';
if (s.canApprove) {
actions += `<button id="app_btn_${s.id}" class="btn-secondary app_btn">Approve</button>`;
}
if (s.canDeny) {
actions += `<button id="den_btn_${s.id}" class="btn-secondary den_btn">Deny</button>`;
}
if (s.isCurrentUser) {
actions += `<button id="rev_btn_${s.id}" class="btn-secondary rev_btn">Revoke</button>`;
}

$table.row.add([
s.command,
s.userName,
s.hostName,
actions
]);
}

$table.draw();
attachZtatButtonHandlers(); // re-bind the click events
});

$.get('/api/v1/zerotrust/accesstoken/list/approved/terminal', function (data) {
const $table = $('#approved-terminal-table').DataTable();
$table.clear();

for (let s of data) {
let actions = '';
if (s.canApprove) {
actions += `<button id="app_btn_${s.id}" class="btn-secondary app_btn">Approve</button>`;
}
if (s.canDeny) {
actions += `<button id="den_btn_${s.id}" class="btn-secondary den_btn">Deny</button>`;
}
if (s.isCurrentUser) {
actions += `<button id="rev_btn_${s.id}" class="btn-secondary rev_btn">Revoke</button>`;
}

$table.row.add([
s.command,
s.userName,
s.hostName,
s.usesRemaining,
actions
]);
}

$table.draw();
attachZtatButtonHandlers(); // re-bind the click events
});

$.get('/api/v1/zerotrust/accesstoken/list/denied/terminal', function (data) {
const $table = $('#denied-terminal-table').DataTable();
$table.clear();

for (let s of data) {
let actions = '';
if (s.canApprove) {
actions += `<button id="app_btn_${s.id}" class="btn-secondary app_btn">Approve</button>`;
}
if (s.canDeny) {
actions += `<button id="den_btn_${s.id}" class="btn-secondary den_btn">Deny</button>`;
}

$table.row.add([
s.command,
s.userName,
s.hostName,
actions
]);
}

$table.draw();
attachZtatButtonHandlers(); // re-bind the click events
});
}

Copy link

Copilot AI Jul 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The reload functions for terminal and ops share a lot of duplicate logic. Consider extracting common table-refresh behavior into a helper to reduce repetition.

Copilot uses AI. Check for mistakes.
phrocker and others added 2 commits July 7, 2025 07:10
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Marc <phrocker@apache.org>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Marc <phrocker@apache.org>
@phrocker
Copy link
Contributor Author

phrocker commented Jul 7, 2025

After committing suggestions:

DataTables warning: table id=approved-ops-table - Requested unknown parameter '0' for row 0, column 0. For more information about this error, please see http://datatables.net/tn/4

Occurs when the page is loaded @copilot

@phrocker phrocker merged commit af13eaf into main Jul 7, 2025
7 checks passed
@phrocker phrocker deleted the refreshztats branch July 31, 2025 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants