Merge pull request #4203 from rackerlabs/fix-device-code

fix: device code should not require scope
This commit is contained in:
Márk Sági-Kazár
2025-07-29 15:54:19 +02:00
committed by GitHub
2 changed files with 14 additions and 0 deletions
+6
View File
@@ -85,6 +85,12 @@ func (s *Server) handleDeviceCode(w http.ResponseWriter, r *http.Request) {
return
}
if len(scopes) == 0 {
// per RFC8628 section 3.1, https://datatracker.ietf.org/doc/html/rfc8628#section-3.1
// scope is optional but dex requires that it is always at least 'openid' so default it
scopes = []string{"openid"}
}
s.logger.InfoContext(r.Context(), "received device request", "client_id", clientID, "scoped", scopes)
// Make device code
+8
View File
@@ -90,6 +90,14 @@ func TestHandleDeviceCode(t *testing.T) {
expectedResponseCode: http.StatusBadRequest,
expectedContentType: "application/json",
},
{
testName: "New Code without scope",
clientID: "test",
requestType: "POST",
scopes: []string{},
expectedResponseCode: http.StatusOK,
expectedContentType: "application/json",
},
}
for _, tc := range tests {
t.Run(tc.testName, func(t *testing.T) {