@@ -306,11 +306,10 @@ func (r Wrapper) HandleAuthorizeRequest(ctx context.Context, request HandleAutho
306
306
queryParams := httpRequest .URL .Query ()
307
307
308
308
// parse and validate as JAR (RFC9101, JWT Authorization Request)
309
- ro , err := r .jar .Parse (ctx , * ownDID , queryParams )
309
+ authzParams , err := r .jar .Parse (ctx , * ownDID , queryParams )
310
310
if err != nil {
311
311
return nil , err
312
312
}
313
- authzParams := ro .Claims
314
313
315
314
session := createSession (authzParams , * ownDID )
316
315
@@ -354,24 +353,32 @@ func (r Wrapper) HandleAuthorizeRequest(ctx context.Context, request HandleAutho
354
353
// GetRequestJWT returns the Request Object referenced as 'request_uri' in an authorization request.
355
354
// RFC9101: The OAuth 2.0 Authorization Framework: JWT-Secured Authorization Request (JAR).
356
355
func (r Wrapper ) GetRequestJWT (ctx context.Context , request GetRequestJWTRequestObject ) (GetRequestJWTResponseObject , error ) {
357
- ro := new (requestObject )
356
+ ro := new (jarRequest )
358
357
err := r .authzRequestObjectStore ().Get (request .Id , ro )
359
358
if err != nil {
360
359
return nil , err
361
360
}
362
- if ro .client ().String () != request .Did {
361
+ // compare raw strings, don't waste a db call to see if we own the request.Did.
362
+ if ro .Client .String () != request .Did {
363
363
return nil , errors .New ("invalid request" )
364
364
}
365
- if ! ro .signed () {
365
+ if ro .RequestURIMethod != "get" {
366
+ // TODO: wallet does not support `request_uri_method=post`. Signing the current jarRequest would leave it without 'aud'.
367
+ // is this acceptable or should it fail?
366
368
return nil , oauth.OAuth2Error {
367
369
Code : oauth .InvalidRequest ,
368
370
Description : "used request_uri_method 'get' on a 'post' request_uri" ,
369
371
InternalError : errors .New ("wrong 'request_uri_method' authorization server or wallet probably does not support 'request_uri_method'" ),
370
372
}
371
373
}
374
+ token , err := r .jar .Sign (ctx , ro .Claims )
375
+ if err != nil {
376
+ // TODO: oauth.OAuth2Error?
377
+ return nil , err
378
+ }
372
379
return GetRequestJWT200ApplicationoauthAuthzReqJwtResponse {
373
- Body : bytes .NewReader ([]byte (ro . Token )),
374
- ContentLength : int64 (len (ro . Token )),
380
+ Body : bytes .NewReader ([]byte (token )),
381
+ ContentLength : int64 (len (token )),
375
382
}, nil
376
383
}
377
384
@@ -829,23 +836,21 @@ func (r Wrapper) CreateAuthorizationRequest(ctx context.Context, client did.DID,
829
836
}
830
837
831
838
// request_uri
832
- requestID := cryptoNuts .GenerateNonce ()
839
+ requestURIID := cryptoNuts .GenerateNonce ()
833
840
requestObj := r .jar .Create (client , & server , modifier )
834
- if err = r .jar .Sign (ctx , requestObj ); err != nil {
835
- return nil , fmt .Errorf ("sign authorization Request Object: %w" , err )
836
- }
837
- if err = r .authzRequestObjectStore ().Put (requestID , requestObj ); err != nil {
841
+ if err = r .authzRequestObjectStore ().Put (requestURIID , requestObj ); err != nil {
838
842
return nil , err
839
843
}
840
844
baseURL , err := createOAuth2BaseURL (client )
841
845
if err != nil {
842
846
return nil , err
843
847
}
844
- requestURI := baseURL .JoinPath ("request.jwt" , requestID )
848
+ requestURI := baseURL .JoinPath ("request.jwt" , requestURIID )
845
849
846
850
// JAR request
847
851
params := map [string ]string {
848
852
oauth .ClientIDParam : client .String (),
853
+ oauth .RequestURIMethodParam : requestObj .RequestURIMethod ,
849
854
oauth .RequestURIParam : requestURI .String (),
850
855
}
851
856
if metadata .RequireSignedRequestObject {
0 commit comments