Skip to content

Agent Mesh

make console relative paths

Antonio Ojeaaefc71b75d2d
diff --git a/.github/k8s/dex-config.yaml b/.github/k8s/dex-config.yaml
index 15f86ff7..46c00789 100644
--- a/.github/k8s/dex-config.yaml
+++ b/.github/k8s/dex-config.yaml
@@ -52,6 +52,8 @@ data:
- 'http://127.0.0.1:13002/callback'
- 'http://127.0.0.1/callback'
- 'http://localhost/callback'
+ - 'https://bananas.sam-mesh.dev/console/auth/callback'
+ - 'https://hub.sam-mesh.dev/console/auth/callback'
- 'https://auth.sam-mesh.dev/device/callback'
- 'urn:ietf:wg:oauth:2.0:oob'
- '/device/callback'
\ No newline at end of file
diff --git a/.github/k8s/sam-control-plane-template.yaml b/.github/k8s/sam-control-plane-template.yaml
index cce2db6b..8551c59a 100644
--- a/.github/k8s/sam-control-plane-template.yaml
+++ b/.github/k8s/sam-control-plane-template.yaml
@@ -260,3 +260,16 @@ spec:
backendRefs:
- name: sam-control-plane-${ENV_NAME}
port: 8080
+ - matches:
+ - path:
+ type: PathPrefix
+ value: /console/
+ filters:
+ - type: URLRewrite
+ urlRewrite:
+ path:
+ type: ReplacePrefixMatch
+ replacePrefixMatch: /
+ backendRefs:
+ - name: sam-console-${ENV_NAME}
+ port: 8081
diff --git a/cmd/sam-console/public/app.js b/cmd/sam-console/public/app.js
index 3449af28..ce885afd 100644
--- a/cmd/sam-console/public/app.js
+++ b/cmd/sam-console/public/app.js
@@ -26,7 +26,7 @@ document.addEventListener('DOMContentLoaded', () => {
async function checkAuthAndLoad() {
try {
- const infoResp = await fetch('/console/info');
+ const infoResp = await fetch('info');
if (infoResp.ok) {
const info = await infoResp.json();
const ssoGroup = document.getElementById('sso-login-group');
@@ -49,7 +49,7 @@ async function checkAuthAndLoad() {
}
window.redirectToSSO = function() {
- window.location.href = '/auth/login';
+ window.location.href = 'auth/login';
};
window.loginOIDC = function() {
@@ -84,7 +84,7 @@ function getAuthHeaders() {
async function loadData() {
try {
// 1. Fetch user-scoped status
- const response = await fetch('/api/user/status', {
+ const response = await fetch('api/user/status', {
headers: getAuthHeaders()
});
if (response.status === 401 || response.status === 403) {
@@ -106,7 +106,7 @@ async function loadData() {
// 2. If user is admin, fetch full unfiltered admin status
if (role === 'admin') {
- const adminResp = await fetch('/api/admin/status', {
+ const adminResp = await fetch('api/admin/status', {
headers: getAuthHeaders()
});
if (adminResp.ok) {
@@ -289,25 +289,25 @@ async function actionRequest(url, method = 'POST', body = null) {
function approveEnrollment(id) {
if (confirm('Are you sure you want to approve this enrollment?')) {
- actionRequest(`/api/admin/enrollments/${id}/approve`);
+ actionRequest(`api/admin/enrollments/${id}/approve`);
}
}
function rejectEnrollment(id) {
if (confirm('Are you sure you want to reject this enrollment?')) {
- actionRequest(`/api/admin/enrollments/${id}/reject`);
+ actionRequest(`api/admin/enrollments/${id}/reject`);
}
}
function revokeDevice(id) {
if (confirm('Are you sure you want to revoke this device? This will terminate its connection.')) {
- actionRequest(`/api/user/revoke?id=${id}`);
+ actionRequest(`api/user/revoke?id=${id}`);
}
}
window.logout = function() {
localStorage.removeItem('sam_admin_token');
- window.location.href = '/auth/logout';
+ window.location.href = 'auth/logout';
};
function updateUIForRole(role, userId) {
@@ -461,7 +461,7 @@ window.generateBootstrapToken = async function() {
};
try {
- const res = await actionRequest('/api/user/bootstrap-tokens', 'POST', payload);
+ const res = await actionRequest('api/user/bootstrap-tokens', 'POST', payload);
if (res && res.token) {
alert('Bootstrap Token Generated Successfully!\n\nToken: ' + res.token + '\n\nCopy this token now. It will not be shown again.');
document.getElementById('form-generate-token').reset();
@@ -497,7 +497,7 @@ window.savePolicy = async function() {
headers['Content-Type'] = 'application/x-protobuf';
try {
- const response = await fetch('/api/policies', {
+ const response = await fetch('api/policies', {
method: 'POST',
headers: headers,
body: pbBytes
diff --git a/internal/console/server.go b/internal/console/server.go
index 4346c758..75d9b0b4 100644
--- a/internal/console/server.go
+++ b/internal/console/server.go
@@ -121,7 +121,7 @@ func NewServer(cfg Config) (*Server, error) {
s.mux.HandleFunc("/auth/session", s.HandleSession)
}
s.mux.HandleFunc("/auth/logout", s.HandleLogout)
- s.mux.HandleFunc("/console/info", s.HandleInfo)
+ s.mux.HandleFunc("/info", s.HandleInfo)
return s, nil
}