Skip to content

Commit 321a145

Browse files
committed
fixup previous authorize
1 parent c855447 commit 321a145

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

coderd/httpmw/organizationparam_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,6 @@ func TestOrganizationParam(t *testing.T) {
226226
rtr.ServeHTTP(rw, r)
227227
res = rw.Result()
228228
defer res.Body.Close()
229-
require.Equal(t, http.StatusOK, res.StatusCode, "by default keyword")
229+
require.Equal(t, http.StatusOK, res.StatusCode, "by nil uuid (legacy)")
230230
})
231231
}

enterprise/coderd/provisionerdaemons.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package coderd
22

33
import (
44
"context"
5-
"crypto/subtle"
65
"database/sql"
76
"errors"
87
"fmt"
@@ -115,13 +114,10 @@ func (p *provisionerDaemonAuth) authorize(r *http.Request, tags map[string]strin
115114
}
116115

117116
// Check for PSK
118-
if p.psk != "" {
119-
psk := r.Header.Get(codersdk.ProvisionerDaemonPSK)
120-
if subtle.ConstantTimeCompare([]byte(p.psk), []byte(psk)) == 1 {
121-
// If using PSK auth, the daemon is, by definition, scoped to the organization.
122-
tags = provisionersdk.MutateTags(uuid.Nil, tags)
123-
return tags, true
124-
}
117+
provAuth := httpmw.ProvisionerDaemonAuthenticated(r)
118+
if provAuth {
119+
// If using PSK auth, the daemon is, by definition, scoped to the organization.
120+
return tags, true
125121
}
126122
return nil, false
127123
}

0 commit comments

Comments
 (0)