@@ -14,7 +14,6 @@ import (
14
14
"github.com/coder/coder/coderd/database"
15
15
"github.com/coder/coder/coderd/database/dbauthz"
16
16
"github.com/coder/coder/coderd/httpapi"
17
- "github.com/coder/coder/coderd/rbac"
18
17
"github.com/coder/coder/codersdk"
19
18
)
20
19
@@ -136,23 +135,22 @@ func ExtractExternalProxy(opts ExtractExternalProxyConfig) func(http.Handler) ht
136
135
137
136
ctx = r .Context ()
138
137
ctx = context .WithValue (ctx , externalProxyContextKey {}, proxy )
139
- ctx = context .WithValue (ctx , userAuthKey {}, Authorization {
140
- Actor : rbac.Subject {
141
- ID : "proxy:" + proxy .ID .String (),
142
- // We don't have a system role currently so just use owner
143
- // for now.
144
- // TODO: add a system role
145
- Roles : rbac.RoleNames {rbac .RoleOwner ()},
146
- Groups : []string {},
147
- Scope : rbac .ScopeAll ,
148
- },
149
- ActorName : "proxy_" + proxy .Name ,
150
- })
151
138
//nolint:gocritic // Workspace proxies have full permissions. The
152
139
// workspace proxy auth middleware is not mounted to every route, so
153
140
// they can still only access the routes that the middleware is
154
141
// mounted to.
155
142
ctx = dbauthz .AsSystemRestricted (ctx )
143
+ subj , ok := dbauthz .ActorFromContext (ctx )
144
+ if ! ok {
145
+ // This should never happen
146
+ httpapi .InternalServerError (w , xerrors .New ("developer error: ExtractExternalProxy missing rbac actor" ))
147
+ return
148
+ }
149
+ // Use the same subject for the userAuthKey
150
+ ctx = context .WithValue (ctx , userAuthKey {}, Authorization {
151
+ Actor : subj ,
152
+ ActorName : "proxy_" + proxy .Name ,
153
+ })
156
154
157
155
next .ServeHTTP (w , r .WithContext (ctx ))
158
156
})
0 commit comments