@@ -15,6 +15,7 @@ import (
1515 "strings"
1616 "time"
1717
18+ "github.com/dexidp/dex/server/oauth2"
1819 "github.com/dexidp/dex/storage"
1920)
2021
@@ -67,7 +68,7 @@ func (s *Server) handleDeviceCode(w http.ResponseWriter, r *http.Request) {
6768 err := r .ParseForm ()
6869 if err != nil {
6970 s .logger .ErrorContext (r .Context (), "could not parse Device Request body" , "err" , err )
70- s .tokenErrHelper (w , errInvalidRequest , "" , http .StatusNotFound )
71+ s .tokenErrHelper (w , oauth2 . InvalidRequest , "" , http .StatusNotFound )
7172 return
7273 }
7374
@@ -83,7 +84,7 @@ func (s *Server) handleDeviceCode(w http.ResponseWriter, r *http.Request) {
8384 }
8485 if codeChallengeMethod != codeChallengeMethodS256 && codeChallengeMethod != codeChallengeMethodPlain {
8586 description := fmt .Sprintf ("Unsupported PKCE challenge method (%q)." , codeChallengeMethod )
86- s .tokenErrHelper (w , errInvalidRequest , description , http .StatusBadRequest )
87+ s .tokenErrHelper (w , oauth2 . InvalidRequest , description , http .StatusBadRequest )
8788 return
8889 }
8990
@@ -116,14 +117,14 @@ func (s *Server) handleDeviceCode(w http.ResponseWriter, r *http.Request) {
116117
117118 if err := s .storage .CreateDeviceRequest (ctx , deviceReq ); err != nil {
118119 s .logger .ErrorContext (r .Context (), "failed to store device request" , "err" , err )
119- s .tokenErrHelper (w , errInvalidRequest , "" , http .StatusInternalServerError )
120+ s .tokenErrHelper (w , oauth2 . InvalidRequest , "" , http .StatusInternalServerError )
120121 return
121122 }
122123
123124 // Store the device token
124125 deviceToken := storage.DeviceToken {
125126 DeviceCode : deviceCode ,
126- Status : deviceTokenPending ,
127+ Status : oauth2 . DeviceTokenPending ,
127128 Expiry : expireTime ,
128129 LastRequestTime : s .now (),
129130 PollIntervalSeconds : 0 ,
@@ -135,14 +136,14 @@ func (s *Server) handleDeviceCode(w http.ResponseWriter, r *http.Request) {
135136
136137 if err := s .storage .CreateDeviceToken (ctx , deviceToken ); err != nil {
137138 s .logger .ErrorContext (r .Context (), "failed to store device token" , "err" , err )
138- s .tokenErrHelper (w , errInvalidRequest , "" , http .StatusInternalServerError )
139+ s .tokenErrHelper (w , oauth2 . InvalidRequest , "" , http .StatusInternalServerError )
139140 return
140141 }
141142
142143 u , err := url .Parse (s .issuerURL .String ())
143144 if err != nil {
144145 s .logger .ErrorContext (r .Context (), "could not parse issuer URL" , "err" , err )
145- s .tokenErrHelper (w , errInvalidRequest , "" , http .StatusInternalServerError )
146+ s .tokenErrHelper (w , oauth2 . InvalidRequest , "" , http .StatusInternalServerError )
146147 return
147148 }
148149 u .Path = path .Join (u .Path , "device" )
@@ -177,7 +178,7 @@ func (s *Server) handleDeviceCode(w http.ResponseWriter, r *http.Request) {
177178
178179 default :
179180 s .renderError (r , w , http .StatusBadRequest , "Invalid device code request type" )
180- s .tokenErrHelper (w , errInvalidRequest , "" , http .StatusBadRequest )
181+ s .tokenErrHelper (w , oauth2 . InvalidRequest , "" , http .StatusBadRequest )
181182 }
182183}
183184
@@ -225,7 +226,7 @@ func (s *Server) verifyUserCode(w http.ResponseWriter, r *http.Request) {
225226 q .Set ("client_secret" , deviceRequest .ClientSecret )
226227 q .Set ("state" , deviceRequest .UserCode )
227228 q .Set ("response_type" , "code" )
228- q .Set ("redirect_uri" , s .absPath (deviceCallbackURI ))
229+ q .Set ("redirect_uri" , s .absPath (oauth2 . DeviceCallbackURI ))
229230 q .Set ("scope" , strings .Join (deviceRequest .Scopes , " " ))
230231 u .RawQuery = q .Encode ()
231232
0 commit comments