@@ -107,6 +107,7 @@ func (r *RootCmd) proxyServer() *clibase.Cmd {
107
107
}
108
108
proxySessionToken clibase.String
109
109
primaryAccessURL clibase.URL
110
+ appSecuritYKey clibase.String
110
111
)
111
112
opts .Add (
112
113
// Options only for external workspace proxies
@@ -134,6 +135,20 @@ func (r *RootCmd) proxyServer() *clibase.Cmd {
134
135
Group :& externalProxyOptionGroup ,
135
136
Hidden :false ,
136
137
},
138
+
139
+ // TODO: Make sure this is kept secret. Idk if a flag is the best option
140
+ clibase.Option {
141
+ Name :"App Security Key" ,
142
+ Description :"App security key used for decrypting/verifying app tokens sent from coderd." ,
143
+ Flag :"app-security-key" ,
144
+ Env :"CODER_APP_SECURITY_KEY" ,
145
+ YAML :"appSecurityKey" ,
146
+ Default :"" ,
147
+ Value :& appSecuritYKey ,
148
+ Group :& externalProxyOptionGroup ,
149
+ Hidden :false ,
150
+ Annotations : clibase.Annotations {}.Mark ("secret" ,"true" ),
151
+ },
137
152
)
138
153
139
154
client := new (codersdk.Client )
@@ -153,6 +168,11 @@ func (r *RootCmd) proxyServer() *clibase.Cmd {
153
168
return xerrors .Errorf ("primary access URL must be http or https: url=%s" ,primaryAccessURL )
154
169
}
155
170
171
+ secKey ,err := workspaceapps .KeyFromString (appSecuritYKey .Value ())
172
+ if err != nil {
173
+ return xerrors .Errorf ("app security key: %w" ,err )
174
+ }
175
+
156
176
var closers closers
157
177
// Main command context for managing cancellation of running
158
178
// services.
@@ -272,15 +292,13 @@ func (r *RootCmd) proxyServer() *clibase.Cmd {
272
292
}
273
293
274
294
proxy ,err := wsproxy .New (& wsproxy.Options {
275
- Logger :logger ,
276
- // TODO: PrimaryAccessURL
277
- PrimaryAccessURL :primaryAccessURL .Value (),
278
- AccessURL :cfg .AccessURL .Value (),
279
- AppHostname :appHostname ,
280
- AppHostnameRegex :appHostnameRegex ,
281
- RealIPConfig :realIPConfig ,
282
- // TODO: AppSecurityKey
283
- AppSecurityKey : workspaceapps.SecurityKey {},
295
+ Logger :logger ,
296
+ PrimaryAccessURL :primaryAccessURL .Value (),
297
+ AccessURL :cfg .AccessURL .Value (),
298
+ AppHostname :appHostname ,
299
+ AppHostnameRegex :appHostnameRegex ,
300
+ RealIPConfig :realIPConfig ,
301
+ AppSecurityKey :secKey ,
284
302
Tracing :tracer ,
285
303
PrometheusRegistry :prometheusRegistry ,
286
304
APIRateLimit :int (cfg .RateLimit .API .Value ()),