@@ -20,6 +20,7 @@ import (
20
20
"cuelabs.dev/go/oci/ociregistry/ocimem"
21
21
"cuelabs.dev/go/oci/ociregistry/ociserver"
22
22
"github.com/go-quicktest/qt"
23
+ "golang.org/x/oauth2"
23
24
"golang.org/x/sync/errgroup"
24
25
"golang.org/x/tools/txtar"
25
26
@@ -210,14 +211,14 @@ package bar
210
211
auth := r .Header .Get ("Authorization" )
211
212
if ! strings .HasPrefix (auth , fmt .Sprintf ("Bearer access_%d_" , i )) {
212
213
w .WriteHeader (401 )
213
- w . Write ([] byte ( fmt .Sprintf ( "server %d: unexpected auth header: %s" , i , auth )) )
214
+ fmt .Fprintf ( w , "server %d: unexpected auth header: %s" , i , auth )
214
215
return
215
216
}
216
217
rh .ServeHTTP (w , r )
217
218
})
218
219
mux .HandleFunc ("/login/oauth/token" , func (w http.ResponseWriter , r * http.Request ) {
219
220
ctr := atomic .AddInt32 (& counter , 1 )
220
- writeJSON (w , 200 , wireToken {
221
+ writeJSON (w , 200 , oauth2. Token {
221
222
AccessToken : fmt .Sprintf ("access_%d_%d" , i , ctr ),
222
223
TokenType : "Bearer" ,
223
224
RefreshToken : fmt .Sprintf ("refresh_%d" , ctr ),
@@ -333,12 +334,3 @@ func writeJSON(w http.ResponseWriter, statusCode int, v any) {
333
334
w .WriteHeader (statusCode )
334
335
w .Write (b )
335
336
}
336
-
337
- // wireToken describes the JSON encoding for an OAuth 2.0 token
338
- // as specified in the RFC 6749.
339
- type wireToken struct {
340
- AccessToken string `json:"access_token,omitempty"`
341
- TokenType string `json:"token_type,omitempty"`
342
- RefreshToken string `json:"refresh_token,omitempty"`
343
- ExpiresIn int `json:"expires_in,omitempty"`
344
- }
0 commit comments