feat(license): the paste form is self-hosted only
Server Deploy / deploy (push) Successful in 2m14s

A cloud instance's licence is issued in HQ and written into the control
plane by admin/internal/inject, straight to the database. The customer has
nothing to paste, so /settings/license offered them a form that could only
ever fail — and on an expired cloud instance, failed at the exact moment
they were looking for a way out.

GET /license now reports `deployment`, and the page swaps the paste form
for a short panel saying where the licence comes from, with a link to the
portal when HQ_URL is set. That is the same treatment hq-managed members
already get in the members table: read-only here, and a pointer to where
it is actually managed.

POST /license refuses with 409 cloud_managed on a cloud deployment. Hiding
a form is a courtesy; this codebase's rule is that the API is the boundary,
and the endpoint was reachable regardless of what the page rendered. It
cannot break injection, which never goes through HTTP at all.

Verified: server builds and vets clean, web builds clean.
This commit is contained in:
mrhid6
2026-07-26 20:42:53 +01:00
parent fa75d70475
commit dd306e4757
4 changed files with 50 additions and 0 deletions
+18
View File
@@ -102,6 +102,10 @@ type licenceResponse struct {
Features map[string]bool `json:"features"`
Usage licenceUsageResponse `json:"usage"`
Source string `json:"source"`
// Deployment is what tells the UI whether this instance owns its licence.
// On cloud the licence is injected by admin and there is nothing for a
// customer to paste, so the UI sends them to the portal instead.
Deployment string `json:"deployment"`
}
type licenceUsageResponse struct {
@@ -125,6 +129,7 @@ func getLicence(c *gin.Context) {
Features: st.Features,
Usage: licenceUsageResponse{Servers: servers, SecretGroups: groups, Channels: channels},
Source: st.Source,
Deployment: services.DeploymentMode(),
}
if st.ExpiresAt != nil {
d := int(time.Until(*st.ExpiresAt).Hours() / 24)
@@ -163,6 +168,19 @@ func licencePostAllowed(instanceID string) bool {
func postLicence(c *gin.Context) {
instanceID := auth.InstanceID(c)
// A cloud instance's licence is written by admin straight into the database
// (admin/internal/inject), never through this endpoint, so refusing here
// cannot break injection. Hiding the form in web/ is a courtesy; this is the
// boundary, the same split as an hq-managed user's role.
if services.DeploymentMode() == license.DeploymentCloud {
c.JSON(http.StatusConflict, gin.H{
"error": "This instance's licence is managed in Vantage HQ and cannot be set here.",
"reason": "cloud_managed",
})
return
}
if !licencePostAllowed(instanceID) {
c.JSON(http.StatusTooManyRequests, gin.H{
"error": "Too many licence attempts. Try again later.",