Skip to content

Commit 1bda8a0

Browse files
authored
feat: add deployment_id to the ui and licenses (coder#13096)
* feat: expose `deployment_id` in the user dropdown * feat: add license deployment_id verification * Ignore wireguard.com from mlc config
1 parent 0e3dc2a commit 1bda8a0

File tree

15 files changed

+115
-26
lines changed

15 files changed

+115
-26
lines changed

.github/workflows/mlc_config.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
},
1818
{
1919
"pattern": "tailscale.com"
20+
},
21+
{
22+
"pattern": "wireguard.com"
2023
}
2124
],
2225
"aliveStatusCodes": [200, 0]

coderd/apidoc/docs.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/coderd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ func New(options *Options) *API {
735735
// All CSP errors will be logged
736736
r.Post("/csp/reports", api.logReportCSPViolations)
737737

738-
r.Get("/buildinfo", buildInfo(api.AccessURL, api.DeploymentValues.CLIUpgradeMessage.String()))
738+
r.Get("/buildinfo", buildInfo(api.AccessURL, api.DeploymentValues.CLIUpgradeMessage.String(), api.DeploymentID))
739739
// /regions is overridden in the enterprise version
740740
r.Group(func(r chi.Router) {
741741
r.Use(apiKeyMiddleware)

coderd/deployment.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func (api *API) deploymentStats(rw http.ResponseWriter, r *http.Request) {
6868
// @Tags General
6969
// @Success 200 {object} codersdk.BuildInfoResponse
7070
// @Router /buildinfo [get]
71-
func buildInfo(accessURL *url.URL, upgradeMessage string) http.HandlerFunc {
71+
func buildInfo(accessURL *url.URL, upgradeMessage, deploymentID string) http.HandlerFunc {
7272
return func(rw http.ResponseWriter, r *http.Request) {
7373
httpapi.Write(r.Context(), rw, http.StatusOK, codersdk.BuildInfoResponse{
7474
ExternalURL: buildinfo.ExternalURL(),
@@ -77,6 +77,7 @@ func buildInfo(accessURL *url.URL, upgradeMessage string) http.HandlerFunc {
7777
DashboardURL: accessURL.String(),
7878
WorkspaceProxy: false,
7979
UpgradeMessage: upgradeMessage,
80+
DeploymentID: deploymentID,
8081
})
8182
}
8283
}

codersdk/deployment.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2151,6 +2151,9 @@ type BuildInfoResponse struct {
21512151
// UpgradeMessage is the message displayed to users when an outdated client
21522152
// is detected.
21532153
UpgradeMessage string `json:"upgrade_message"`
2154+
2155+
// DeploymentID is the unique identifier for this deployment.
2156+
DeploymentID string `json:"deployment_id"`
21542157
}
21552158

21562159
type WorkspaceProxyBuildInfo struct {

docs/api/general.md

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/api/schemas.md

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

enterprise/coderd/coderdenttest/coderdenttest.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,14 @@ func NewWithAPI(t *testing.T, options *Options) (
147147
}
148148

149149
type LicenseOptions struct {
150-
AccountType string
151-
AccountID string
152-
Trial bool
153-
AllFeatures bool
154-
GraceAt time.Time
155-
ExpiresAt time.Time
156-
Features license.Features
150+
AccountType string
151+
AccountID string
152+
DeploymentIDs []string
153+
Trial bool
154+
AllFeatures bool
155+
GraceAt time.Time
156+
ExpiresAt time.Time
157+
Features license.Features
157158
}
158159

159160
// AddFullLicense generates a license with all features enabled.
@@ -190,6 +191,7 @@ func GenerateLicense(t *testing.T, options LicenseOptions) string {
190191
LicenseExpires: jwt.NewNumericDate(options.GraceAt),
191192
AccountType: options.AccountType,
192193
AccountID: options.AccountID,
194+
DeploymentIDs: options.DeploymentIDs,
193195
Trial: options.Trial,
194196
Version: license.CurrentVersion,
195197
AllFeatures: options.AllFeatures,

enterprise/coderd/license/license.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -257,14 +257,16 @@ type Claims struct {
257257
// the end of the grace period (identical to LicenseExpires if there is no grace period).
258258
// The reason we use the standard claim for the end of the grace period is that we want JWT
259259
// processing libraries to consider the token "valid" until then.
260-
LicenseExpires *jwt.NumericDate `json:"license_expires,omitempty"`
261-
AccountType string `json:"account_type,omitempty"`
262-
AccountID string `json:"account_id,omitempty"`
263-
Trial bool `json:"trial"`
264-
AllFeatures bool `json:"all_features"`
265-
Version uint64 `json:"version"`
266-
Features Features `json:"features"`
267-
RequireTelemetry bool `json:"require_telemetry,omitempty"`
260+
LicenseExpires *jwt.NumericDate `json:"license_expires,omitempty"`
261+
AccountType string `json:"account_type,omitempty"`
262+
AccountID string `json:"account_id,omitempty"`
263+
// DeploymentIDs enforces the license can only be used on a set of deployments.
264+
DeploymentIDs []string `json:"deployment_ids,omitempty"`
265+
Trial bool `json:"trial"`
266+
AllFeatures bool `json:"all_features"`
267+
Version uint64 `json:"version"`
268+
Features Features `json:"features"`
269+
RequireTelemetry bool `json:"require_telemetry,omitempty"`
268270
}
269271

270272
// ParseRaw consumes a license and returns the claims.

0 commit comments

Comments
 (0)