Install an agent on a one-off PC from a single command
An admin generates a short-lived token in Settings > Endpoints > Endpoints and
copies the command it produces. A tech runs that one line in an elevated
PowerShell on a PC with no agent:
powershell -ExecutionPolicy Bypass -c "irm https://<server>/shopdb/api/
endpoints/siteagent/bootstrap.ps1?t=<token> | iex"
The script refuses to run unelevated, refuses a PC that already has the agent
(a managed bay gets it from GE-Enforce), downloads the package the existing
builder produces, checks both binaries against the hashes the server baked in,
installs with NO shared key, and reports what happened. The PC then asks to
enroll and waits for an admin to approve it, which the script watches for
locally for two minutes before exiting.
- New endpointbootstraptokens table and migration
endpoints0024bootstraptokens: hash only, expiry, use count, revoke.
- Admin routes to generate, list and revoke tokens; the secret is shown once.
- Two token-only routes: the script, and the package (which spends a use).
Anything wrong with the token answers 404 rather than confirming it exists,
both are rate limited per address and both are audited with the caller.
- The package builder is now shared rather than duplicated, and a bootstrap
package can never carry a collector key.
This commit is contained in:
@@ -380,6 +380,134 @@
|
||||
<p v-if="agentwarning" class="field-warning">{{ agentwarning }}</p>
|
||||
<p v-if="agenterror" class="field-error">{{ agenterror }}</p>
|
||||
|
||||
<!-- ================================================================
|
||||
One-line install. An admin mints a short-lived token and hands a
|
||||
tech one command; the token only fetches the installer. The
|
||||
package it serves never carries the shared key, so the PC waits
|
||||
in Pending until an admin approves its enrollment. -->
|
||||
<div class="card bootstrap-block">
|
||||
<h4>One-line install</h4>
|
||||
<p class="field-hint">
|
||||
Generate a short-lived token and give a technician the command.
|
||||
On a PC with no agent, run it from an <strong>elevated</strong>
|
||||
PowerShell. The token only fetches the installer: it carries no
|
||||
shared key and provisions nothing on its own. A managed bay should
|
||||
keep getting the agent from GE-Enforce instead.
|
||||
</p>
|
||||
|
||||
<div class="bootstrap-inputs">
|
||||
<div>
|
||||
<label class="field-label" for="bootstrap-hours">
|
||||
Valid for (hours)
|
||||
</label>
|
||||
<input
|
||||
id="bootstrap-hours"
|
||||
v-model.number="bootstraphours"
|
||||
class="form-control"
|
||||
type="number"
|
||||
min="1"
|
||||
max="168"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="field-label" for="bootstrap-maxuses">
|
||||
Maximum uses
|
||||
</label>
|
||||
<input
|
||||
id="bootstrap-maxuses"
|
||||
v-model.number="bootstrapmaxuses"
|
||||
class="form-control"
|
||||
type="number"
|
||||
min="1"
|
||||
max="500"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="button-row">
|
||||
<button
|
||||
class="btn btn-primary"
|
||||
type="button"
|
||||
:disabled="bootstrapbusy"
|
||||
@click="generateBootstrapToken"
|
||||
>
|
||||
{{ bootstrapbusy ? 'Generating...' : 'Generate install command' }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<template v-if="bootstrapcommand">
|
||||
<p class="field-warning">
|
||||
Copy this now. The token is shown once and cannot be recovered.
|
||||
</p>
|
||||
<label class="field-label" for="bootstrap-command">
|
||||
Install command
|
||||
</label>
|
||||
<div class="bootstrap-command-row">
|
||||
<input
|
||||
id="bootstrap-command"
|
||||
class="form-control mono"
|
||||
type="text"
|
||||
readonly
|
||||
:value="bootstrapcommand"
|
||||
/>
|
||||
<button
|
||||
class="btn btn-secondary"
|
||||
type="button"
|
||||
@click="copyBootstrapCommand"
|
||||
>
|
||||
{{ bootstrapcopied ? 'Copied' : 'Copy' }}
|
||||
</button>
|
||||
</div>
|
||||
<p v-if="bootstraptoken" class="field-hint">
|
||||
Expires {{ formatDate(bootstraptoken.expiresat) }}.
|
||||
{{ bootstraptoken.remaining }} of
|
||||
{{ bootstraptoken.maxuses }} uses remaining.
|
||||
</p>
|
||||
</template>
|
||||
|
||||
<p class="field-hint">
|
||||
The PC installs with no shared key and then waits for approval in
|
||||
Settings > Endpoints > Enrollment.
|
||||
</p>
|
||||
|
||||
<table v-if="bootstraptokens.length" class="versions-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Token</th>
|
||||
<th>State</th>
|
||||
<th>Expires</th>
|
||||
<th>Uses</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="entry in bootstraptokens" :key="entry.tokenid">
|
||||
<td class="mono">{{ entry.tokenprefix }}</td>
|
||||
<td>{{ entry.state }}</td>
|
||||
<td>{{ formatDate(entry.expiresat) }}</td>
|
||||
<td>{{ entry.usecount }} / {{ entry.maxuses }}</td>
|
||||
<td>
|
||||
<button
|
||||
v-if="entry.state === 'active'"
|
||||
class="btn-link"
|
||||
type="button"
|
||||
:disabled="bootstrapbusy"
|
||||
@click="revokeBootstrapToken(entry.tokenid)"
|
||||
>
|
||||
Revoke
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p v-else class="field-hint">No install tokens yet.</p>
|
||||
|
||||
<p v-if="bootstrapmessage" class="field-hint">
|
||||
{{ bootstrapmessage }}
|
||||
</p>
|
||||
<p v-if="bootstraperror" class="field-error">{{ bootstraperror }}</p>
|
||||
</div>
|
||||
|
||||
<!-- ================================================================
|
||||
Agent binary versions: upload a new build, keep the last few,
|
||||
and roll the current pointer back to a retained version. Staging
|
||||
@@ -610,6 +738,19 @@ const agentincludesharedkey = ref(true)
|
||||
const agentnextserverpin = ref('')
|
||||
const agentserverpin = ref('')
|
||||
|
||||
// One-line install tokens. bootstrapcommand holds the secret ONLY for the
|
||||
// response that minted it: the list read never carries one, so a reload leaves
|
||||
// the field empty rather than re-showing a token nobody can recover.
|
||||
const bootstraphours = ref(24)
|
||||
const bootstrapmaxuses = ref(25)
|
||||
const bootstrapbusy = ref(false)
|
||||
const bootstrapcommand = ref('')
|
||||
const bootstraptoken = ref(null)
|
||||
const bootstrapcopied = ref(false)
|
||||
const bootstraptokens = ref([])
|
||||
const bootstrapmessage = ref('')
|
||||
const bootstraperror = ref('')
|
||||
|
||||
function agentnextpininvalid() {
|
||||
const pin = agentnextserverpin.value
|
||||
return !!pin && !/^[0-9a-f]{64}$/.test(pin)
|
||||
@@ -708,6 +849,7 @@ onMounted(async () => {
|
||||
loading.value = false
|
||||
}
|
||||
loadEnrollment()
|
||||
loadBootstrapTokens()
|
||||
try {
|
||||
const response = await api.get('/endpoints/siteagent')
|
||||
const status = response.data.data || {}
|
||||
@@ -723,6 +865,68 @@ onMounted(async () => {
|
||||
}
|
||||
})
|
||||
|
||||
async function loadBootstrapTokens() {
|
||||
try {
|
||||
const response = await api.get('/endpoints/siteagent/bootstrap/tokens')
|
||||
bootstraptokens.value = response.data.data?.tokens || []
|
||||
} catch (loadError) {
|
||||
bootstraptokens.value = []
|
||||
console.error(loadError)
|
||||
}
|
||||
}
|
||||
|
||||
async function generateBootstrapToken() {
|
||||
bootstrapbusy.value = true
|
||||
bootstrapmessage.value = ''
|
||||
bootstraperror.value = ''
|
||||
bootstrapcommand.value = ''
|
||||
bootstraptoken.value = null
|
||||
bootstrapcopied.value = false
|
||||
try {
|
||||
const response = await api.post('/endpoints/siteagent/bootstrap/tokens', {
|
||||
hours: bootstraphours.value,
|
||||
maxuses: bootstrapmaxuses.value
|
||||
})
|
||||
const data = response.data.data || {}
|
||||
bootstrapcommand.value = data.command || ''
|
||||
bootstraptoken.value = data.token || null
|
||||
bootstrapmessage.value = 'Install command generated.'
|
||||
await loadBootstrapTokens()
|
||||
} catch (generateError) {
|
||||
bootstraperror.value = generateError.response?.data?.data?.error?.message
|
||||
|| 'Could not generate an install token'
|
||||
console.error(generateError)
|
||||
} finally {
|
||||
bootstrapbusy.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function copyBootstrapCommand() {
|
||||
try {
|
||||
await navigator.clipboard.writeText(bootstrapcommand.value)
|
||||
bootstrapcopied.value = true
|
||||
} catch (copyError) {
|
||||
console.error(copyError)
|
||||
}
|
||||
}
|
||||
|
||||
async function revokeBootstrapToken(tokenid) {
|
||||
bootstrapbusy.value = true
|
||||
bootstrapmessage.value = ''
|
||||
bootstraperror.value = ''
|
||||
try {
|
||||
await api.post(`/endpoints/siteagent/bootstrap/tokens/${tokenid}/revoke`)
|
||||
bootstrapmessage.value = 'Install token revoked.'
|
||||
await loadBootstrapTokens()
|
||||
} catch (revokeError) {
|
||||
bootstraperror.value = revokeError.response?.data?.data?.error?.message
|
||||
|| 'Could not revoke the install token'
|
||||
console.error(revokeError)
|
||||
} finally {
|
||||
bootstrapbusy.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function applyBinaryStatus(binkey, current, versions) {
|
||||
const binary = binaryFor(binkey)
|
||||
if (!binary) return
|
||||
@@ -1131,6 +1335,23 @@ function editConfiguration() {
|
||||
padding: 0.3rem 0.5rem;
|
||||
border-bottom: 1px solid var(--color-border, #333);
|
||||
}
|
||||
.bootstrap-block {
|
||||
margin-top: 1rem;
|
||||
padding: 1rem;
|
||||
}
|
||||
.bootstrap-inputs {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
.bootstrap-inputs .form-control { max-width: 9rem; }
|
||||
.bootstrap-command-row {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
align-items: center;
|
||||
}
|
||||
.bootstrap-command-row .form-control { flex: 1; }
|
||||
.current-tag {
|
||||
font-size: 0.8rem;
|
||||
color: var(--color-success, #4caf50);
|
||||
|
||||
Reference in New Issue
Block a user