66from idpyoidc .client .client_auth import CLIENT_AUTHN_METHOD
77from idpyoidc .message import Message
88from idpyoidc .message .oauth2 import JWTSecuredAuthorizationRequest
9+ from idpyoidc .server .util import execute
910from idpyoidc .util import instantiate
1011from requests import request
1112
@@ -21,24 +22,41 @@ def push_authorization(request_args, service, **kwargs):
2122
2223 _context = service .upstream_get ("context" )
2324 method_args = _context .add_on ["pushed_authorization" ]
25+ logger .debug (f"PAR method args: { method_args } " )
26+ logger .debug (f"PAR kwargs: { kwargs } " )
27+
2428 if method_args ["apply" ] is False :
2529 return request_args
2630
2731 _http_method = method_args ["http_client" ]
32+ _httpc_params = service .upstream_get ("unit" ).httpc_params
2833
2934 # Add client authentication if needed
3035 _headers = {}
3136 authn_method = method_args ["authn_method" ]
3237 if authn_method :
33- if authn_method not in _context .client_authn_methods :
34- _context .client_authn_methods [authn_method ] = CLIENT_AUTHN_METHOD [authn_method ]()
38+ if isinstance (authn_method , str ):
39+ if authn_method not in _context .client_authn_methods :
40+ _context .client_authn_methods [authn_method ] = CLIENT_AUTHN_METHOD [authn_method ]()
41+ else :
42+ _name = ""
43+ for _name , spec in authn_method .items ():
44+ if _name not in _context .client_authn_methods :
45+ _context .client_authn_methods [_name ] = execute (spec )
46+ authn_method = _name
3547
3648 _args = {}
3749 if _context .issuer :
3850 _args ["iss" ] = _context .issuer
51+ if _name == "client_attestation" :
52+ _wia = kwargs .get ("client_attestation" )
53+ if _wia :
54+ _args ["client_attestation" ] = _wia
55+
3956 _headers = service .get_headers (
4057 request_args , http_method = _http_method , authn_method = authn_method , ** _args
4158 )
59+ _headers ["Content-Type" ] = "application/x-www-form-urlencoded"
4260
4361 # construct the message body
4462 if method_args ["body_format" ] == "urlencoded" :
@@ -56,12 +74,13 @@ def push_authorization(request_args, service, **kwargs):
5674
5775 _body = _msg .to_urlencoded ()
5876
59- # Send it to the Pushed Authorization Request Endpoint
77+ # Send it to the Pushed Authorization Request Endpoint using POST
6078 resp = _http_method (
61- method = "GET " ,
79+ method = "POST " ,
6280 url = _context .provider_info ["pushed_authorization_request_endpoint" ],
6381 data = _body ,
6482 headers = _headers ,
83+ ** _httpc_params
6584 )
6685
6786 if resp .status_code == 200 :
0 commit comments