Skip to content

Commit 34ef0a7

Browse files
committed
unconditionally set tag scope to org for psk auth
1 parent 3e1a94b commit 34ef0a7

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

coderd/provisionerdserver/provisionertags.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ func MutateTags(userID uuid.UUID, tags map[string]string) map[string]string {
2424
}
2525
switch tags[TagScope] {
2626
case ScopeUser:
27-
if userID != uuid.Nil {
28-
tags[TagOwner] = userID.String()
29-
}
27+
tags[TagOwner] = userID.String()
3028
case ScopeOrganization:
3129
default:
3230
tags[TagScope] = ScopeOrganization

enterprise/coderd/provisionerdaemons.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,8 @@ func (p *provisionerDaemonAuth) authorize(r *http.Request, tags map[string]strin
117117
if p.psk != "" {
118118
psk := r.Header.Get(codersdk.ProvisionerDaemonPSK)
119119
if subtle.ConstantTimeCompare([]byte(p.psk), []byte(psk)) == 1 {
120-
if len(tags) == 0 {
121-
// Directly scope to organization if no tags are provided.
122-
// MutateTags is only meant for scoping based on users.
123-
tags = map[string]string{
124-
provisionerdserver.TagScope: provisionerdserver.ScopeOrganization,
125-
}
126-
}
120+
// If using PSK auth, the daemon is, by definition, scoped to the organization.
121+
tags[provisionerdserver.TagScope] = provisionerdserver.ScopeOrganization
127122
return tags, true
128123
}
129124
}

0 commit comments

Comments
 (0)