Skip to content

Commit 357eec2

Browse files
committed
add session id to signed token
1 parent c9272c5 commit 357eec2

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

coderd/workspaceapps/stats.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func newStatsReportFromSignedToken(token SignedToken) StatsReport {
4242
AgentID: token.AgentID,
4343
AccessMethod: token.AccessMethod,
4444
SlugOrPort: token.AppSlugOrPort,
45-
SessionID: uuid.New(),
45+
SessionID: token.SessionID,
4646
SessionStartedAt: database.Now(),
4747
Requests: 1,
4848
}

coderd/workspaceapps/token.go

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ type SignedToken struct {
2727
// Request details.
2828
Request `json:"request"`
2929

30+
SessionID uuid.UUID `json:"session_id"`
31+
3032
// Trusted resolved details.
3133
Expiry time.Time `json:"expiry"` // set by GenerateToken if unset
3234
UserID uuid.UUID `json:"user_id"`
@@ -250,6 +252,8 @@ func FromRequest(r *http.Request, key SecurityKey) (*SignedToken, bool) {
250252

251253
err := req.Validate()
252254
if err == nil {
255+
token.SessionID = uuid.New()
256+
253257
// The request has a valid signed app token, which is a valid
254258
// token signed by us. The caller must check that it matches
255259
// the request.

0 commit comments

Comments
 (0)