Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit34593e3

Browse files
authored
chore: ticket provider interface (#6915)
1 parente0f7f01 commit34593e3

File tree

16 files changed

+665
-675
lines changed

16 files changed

+665
-675
lines changed

‎coderd/coderd.go‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ type Options struct {
123123
SwaggerEndpointbool
124124
SetUserGroupsfunc(ctx context.Context,tx database.Store,userID uuid.UUID,groupNames []string)error
125125
TemplateScheduleStore schedule.TemplateScheduleStore
126-
// AppSigningKey denotes the symmetric key to use for signingapp tickets.
127-
// The key must be 64 bytes long.
126+
// AppSigningKey denotes the symmetric key to use for signingtemporary app
127+
//tokens.The key must be 64 bytes long.
128128
AppSigningKey []byte
129129
HealthcheckFuncfunc(ctx context.Context) (*healthcheck.Report,error)
130130
HealthcheckTimeout time.Duration
@@ -297,7 +297,7 @@ func New(options *Options) *API {
297297
Authorizer:options.Authorizer,
298298
Logger:options.Logger,
299299
},
300-
WorkspaceAppsProvider:workspaceapps.New(
300+
WorkspaceAppsProvider:workspaceapps.NewDBTokenProvider(
301301
options.Logger.Named("workspaceapps"),
302302
options.AccessURL,
303303
options.Authorizer,
@@ -642,7 +642,7 @@ func New(options *Options) *API {
642642
r.Post("/metadata/{key}",api.workspaceAgentPostMetadata)
643643
})
644644
// No middleware on the PTY endpoint since it uses workspace
645-
// application auth andtickets.
645+
// application auth andsigned app tokens.
646646
r.Get("/{workspaceagent}/pty",api.workspaceAgentPTY)
647647
r.Route("/{workspaceagent}",func(r chi.Router) {
648648
r.Use(
@@ -788,7 +788,7 @@ type API struct {
788788
metricsCache*metricscache.Cache
789789
workspaceAgentCache*wsconncache.Cache
790790
updateChecker*updatecheck.Checker
791-
WorkspaceAppsProvider*workspaceapps.Provider
791+
WorkspaceAppsProvider workspaceapps.SignedTokenProvider
792792

793793
// Experiments contains the list of experiments currently enabled.
794794
// This is used to gate features that are not yet ready for production.

‎coderd/coderdtest/coderdtest.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ import (
8080
"github.com/coder/coder/testutil"
8181
)
8282

83-
// AppSigningKey is a 64-byte key used to sign JWTs for workspace apptickets in
83+
// AppSigningKey is a 64-byte key used to sign JWTs for workspace apptokens in
8484
// tests.
8585
varAppSigningKey=must(hex.DecodeString("64656164626565666465616462656566646561646265656664656164626565666465616462656566646561646265656664656164626565666465616462656566"))
8686

‎coderd/httpapi/cookie.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func StripCoderCookies(header string) string {
2424
name==codersdk.OAuth2StateCookie||
2525
name==codersdk.OAuth2RedirectCookie||
2626
name==codersdk.DevURLSessionTokenCookie||
27-
name==codersdk.DevURLSessionTicketCookie {
27+
name==codersdk.DevURLSignedAppTokenCookie {
2828
continue
2929
}
3030
cookies=append(cookies,part)

‎coderd/workspaceagents.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ func (api *API) workspaceAgentPTY(rw http.ResponseWriter, r *http.Request) {
564564
api.WebsocketWaitMutex.Unlock()
565565
deferapi.WebsocketWaitGroup.Done()
566566

567-
ticket,ok:=api.WorkspaceAppsProvider.ResolveRequest(rw,r, workspaceapps.Request{
567+
appToken,ok:=workspaceapps.ResolveRequest(api.Logger,api.AccessURL,api.WorkspaceAppsProvider,rw,r, workspaceapps.Request{
568568
AccessMethod:workspaceapps.AccessMethodTerminal,
569569
BasePath:r.URL.Path,
570570
AgentNameOrID:chi.URLParam(r,"workspaceagent"),
@@ -608,7 +608,7 @@ func (api *API) workspaceAgentPTY(rw http.ResponseWriter, r *http.Request) {
608608

609609
gohttpapi.Heartbeat(ctx,conn)
610610

611-
agentConn,release,err:=api.workspaceAgentCache.Acquire(ticket.AgentID)
611+
agentConn,release,err:=api.workspaceAgentCache.Acquire(appToken.AgentID)
612612
iferr!=nil {
613613
_=conn.Close(websocket.StatusInternalError,httpapi.WebsocketCloseSprintf("dial workspace agent: %s",err))
614614
return

‎coderd/workspaceapps.go‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func (api *API) workspaceAppsProxyPath(rw http.ResponseWriter, r *http.Request)
124124
chiPath="/"+chiPath
125125
}
126126

127-
ticket,ok:=api.WorkspaceAppsProvider.ResolveRequest(rw,r, workspaceapps.Request{
127+
token,ok:=workspaceapps.ResolveRequest(api.Logger,api.AccessURL,api.WorkspaceAppsProvider,rw,r, workspaceapps.Request{
128128
AccessMethod:workspaceapps.AccessMethodPath,
129129
BasePath:basePath,
130130
UsernameOrID:chi.URLParam(r,"user"),
@@ -137,7 +137,7 @@ func (api *API) workspaceAppsProxyPath(rw http.ResponseWriter, r *http.Request)
137137
return
138138
}
139139

140-
api.proxyWorkspaceApplication(rw,r,*ticket,chiPath)
140+
api.proxyWorkspaceApplication(rw,r,*token,chiPath)
141141
}
142142

143143
// handleSubdomainApplications handles subdomain-based application proxy
@@ -247,7 +247,7 @@ func (api *API) handleSubdomainApplications(middlewares ...func(http.Handler) ht
247247
return
248248
}
249249

250-
ticket,ok:=api.WorkspaceAppsProvider.ResolveRequest(rw,r, workspaceapps.Request{
250+
token,ok:=workspaceapps.ResolveRequest(api.Logger,api.AccessURL,api.WorkspaceAppsProvider,rw,r, workspaceapps.Request{
251251
AccessMethod:workspaceapps.AccessMethodSubdomain,
252252
BasePath:"/",
253253
UsernameOrID:app.Username,
@@ -263,7 +263,7 @@ func (api *API) handleSubdomainApplications(middlewares ...func(http.Handler) ht
263263
// app.
264264
mws:=chi.Middlewares(middlewares)
265265
mws.Handler(http.HandlerFunc(func(rw http.ResponseWriter,r*http.Request) {
266-
api.proxyWorkspaceApplication(rw,r,*ticket,r.URL.Path)
266+
api.proxyWorkspaceApplication(rw,r,*token,r.URL.Path)
267267
})).ServeHTTP(rw,r.WithContext(ctx))
268268
})
269269
}
@@ -561,7 +561,7 @@ func (api *API) setWorkspaceAppCookie(rw http.ResponseWriter, r *http.Request, t
561561
returntrue
562562
}
563563

564-
func (api*API)proxyWorkspaceApplication(rw http.ResponseWriter,r*http.Request,ticket workspaceapps.Ticket,pathstring) {
564+
func (api*API)proxyWorkspaceApplication(rw http.ResponseWriter,r*http.Request,appToken workspaceapps.SignedToken,pathstring) {
565565
ctx:=r.Context()
566566

567567
// Filter IP headers from untrusted origins.
@@ -573,12 +573,12 @@ func (api *API) proxyWorkspaceApplication(rw http.ResponseWriter, r *http.Reques
573573
return
574574
}
575575

576-
appURL,err:=url.Parse(ticket.AppURL)
576+
appURL,err:=url.Parse(appToken.AppURL)
577577
iferr!=nil {
578578
site.RenderStaticErrorPage(rw,r, site.ErrorPageData{
579579
Status:http.StatusBadRequest,
580580
Title:"Bad Request",
581-
Description:fmt.Sprintf("Application has an invalid URL %q: %s",ticket.AppURL,err.Error()),
581+
Description:fmt.Sprintf("Application has an invalid URL %q: %s",appToken.AppURL,err.Error()),
582582
RetryEnabled:true,
583583
DashboardURL:api.AccessURL.String(),
584584
})
@@ -592,7 +592,7 @@ func (api *API) proxyWorkspaceApplication(rw http.ResponseWriter, r *http.Reques
592592
portInt,err:=strconv.Atoi(port)
593593
iferr!=nil {
594594
httpapi.Write(ctx,rw,http.StatusBadRequest, codersdk.Response{
595-
Message:fmt.Sprintf("App URL %q has an invalid port %q.",ticket.AppURL,port),
595+
Message:fmt.Sprintf("App URL %q has an invalid port %q.",appToken.AppURL,port),
596596
Detail:err.Error(),
597597
})
598598
return
@@ -639,7 +639,7 @@ func (api *API) proxyWorkspaceApplication(rw http.ResponseWriter, r *http.Reques
639639
})
640640
}
641641

642-
conn,release,err:=api.workspaceAgentCache.Acquire(ticket.AgentID)
642+
conn,release,err:=api.workspaceAgentCache.Acquire(appToken.AgentID)
643643
iferr!=nil {
644644
site.RenderStaticErrorPage(rw,r, site.ErrorPageData{
645645
Status:http.StatusBadGateway,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp