ai-agent/web_templates/permissions/validate.html

55 lines
No EOL
1.9 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>Permission Validation</title>
<style>
.validation-form { margin: 20px; padding: 15px; border: 1px solid #ddd; }
.results { margin-top: 20px; padding: 10px; background: #f5f5f5; }
</style>
</head>
<body>
<div class="validation-form">
<h2>RBAC Validation</h2>
<form id="validateForm">
<div>
<label for="userRole">User Role:</label>
<input type="text" id="userRole" required>
</div>
<div>
<label for="action">Action:</label>
<input type="text" id="action" required>
</div>
<div>
<label for="resource">Resource:</label>
<input type="text" id="resource" required>
</div>
<button type="submit">Validate</button>
</form>
</div>
<div id="results" class="results" style="display: none;">
<h3>Validation Result</h3>
<p id="resultText"></p>
</div>
<script>
document.getElementById('validateForm').addEventListener('submit', async (e) => {
e.preventDefault();
const response = await fetch('/permissions/validate', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
role: document.getElementById('userRole').value,
action: document.getElementById('action').value,
resource: document.getElementById('resource').value
})
});
const result = await response.json();
const resultDiv = document.getElementById('results');
document.getElementById('resultText').textContent =
result.allowed ? 'Permission GRANTED' : 'Permission DENIED';
resultDiv.style.display = 'block';
});
</script>
</body>
</html>