Auto-login to code-server: POST password+href instead of GET redirect
Hardcodes 'zorro' password into auto-submit form so users skip the VS Code login screen. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
6535713cf5
commit
29d4b9389e
22
index.html
22
index.html
@ -2937,8 +2937,28 @@ const SCHEDULE = [
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Auto-login: POST password to code-server, then go to ?folder=... URL.
|
||||||
|
const CODE_PASSWORD = 'zorro';
|
||||||
function redirectTo(cdn, vscodeUrl) {
|
function redirectTo(cdn, vscodeUrl) {
|
||||||
window.location.href = vscodeUrl || (CODE_BASE + encodeURIComponent(cdn) + '/');
|
const fullUrl = vscodeUrl || (CODE_BASE + encodeURIComponent(cdn) + '/');
|
||||||
|
// href = query+hash portion (everything after origin), e.g. "?folder=/Users/..."
|
||||||
|
const u = new URL(fullUrl);
|
||||||
|
const href = u.search + u.hash;
|
||||||
|
|
||||||
|
const form = document.createElement('form');
|
||||||
|
form.method = 'POST';
|
||||||
|
form.action = u.origin + '/login';
|
||||||
|
form.style.display = 'none';
|
||||||
|
const add = (name, value) => {
|
||||||
|
const i = document.createElement('input');
|
||||||
|
i.type = 'hidden'; i.name = name; i.value = value;
|
||||||
|
form.appendChild(i);
|
||||||
|
};
|
||||||
|
add('password', CODE_PASSWORD);
|
||||||
|
add('base', '.');
|
||||||
|
add('href', href);
|
||||||
|
document.body.appendChild(form);
|
||||||
|
form.submit();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function apiCall(path, body) {
|
async function apiCall(path, body) {
|
||||||
|
|||||||
Reference in New Issue
Block a user