Open christian-hawk opened 1 year ago
Why do you think you need to register the scope
for OpenID connect? Does some OP force that?
For OpenID Dynamic Registration (https://openid.net/specs/openid-connect-registration-1_0.html#ClientMetadata ) scope isn't a supported value. So the default oic.oic.Client does not implement it.
OAuth 2.0 does allow it though, but we only implement the OAuth2 registration in the extensions, https://github.com/CZ-NIC/pyoidc/blob/444bd6845e13b06c14fbaefccbc0c47059aa2364/src/oic/extension/client.py#L390
, see the RegistrationRequest class https://github.com/CZ-NIC/pyoidc/blob/f6c590cd8d5834f7e2a2d746ded934549e1fd5f8/src/oic/extension/message.py#L97 this allows scope
as part of the registration.
Why do you think you need to register the
scope
for OpenID connect? Does some OP force that?
It does not force, but it register with no scope at all.
For OpenID Dynamic Registration (https://openid.net/specs/openid-connect-registration-1_0.html#ClientMetadata ) scope isn't a supported value. So the default oic.oic.Client does not implement it.
Actually scope
is supported, but unlisted in this spec. If you check the last line of the provided section, you will find:
Additional Client Metadata parameters MAY also be used. Some are defined by other specifications, such as OpenID Connect Session Management 1.0 [OpenID.Session].
Another interesting reading for this topic can be found at OpenID Foundation repository, entitled "Update dynamic client registration spec to reference OAuth2 dynamic client reg". Issue description:
In section 2.0 (Client Metadata) of the Dynamic Client Registration spec there is a statement at the end of the section that says "Additional Client Metadata parameters MAY also be used. ..." I recommend we update this text to also reference the OAuth2 Dynamic Client Registration spec as another place where additional client metadata parameters are defined (specifically, scope and software statements). "Additional Client Metadata parameters MAY also be used. Some are defined by other specifications, such as OpenID Connect Session Management 1.0 [OpenID.Session] and OAuth 2.0 Dynamic Client Registration Protocol [https://tools.ietf.org/html/rfc7591]".
Correct me if I'm wrong, but by specs sending scope
is allowed.
Agreed. The spec allows sending any key and value you want. The default client just does not implement arbitrary additional registration values in its message factory in order to be able to validate the parameters.
So if you want to register a scope
value, you must override the message_factory
passed into the client:
from oic.oic.message import OIDCMessageFactory, RegistrationRequest, RegistrationResponse, MessageTuple
class MyRegistrationRequest(RegistrationRequest):
# add the fields you want to send
class MyRegistrationResponse(RegistrationResponse):
# add the extra fields you expect the OP to send back
class MyMessageFactory(OIDCMessageFactory):
registration_endpoint = MessageTuple(MyRegistrationRequest, MyRegistrationResponse)
client = Client(client_authn_method=CLIENT_AUTHN_METHOD,
message_factory=MyMessageFactory)
See the https://github.com/CZ-NIC/pyoidc/blob/master/src/oic/extension/message.py#L97 for a message type that has the OAuth2 registration fields available. There are a lot of publicly registered fields, see https://www.iana.org/assignments/oauth-parameters/oauth-parameters.xhtml#client-metadata for the public list and any OP might invent their own additional ones.
thanks, do you think that updating docs / docstring about allowed fields may be helpful?
Yes, you are welcome to submit a PR with updated docs.
I would like to add the
scope
param to my dynamic registration request. But I realized thatoic
does not allow it the way I'm trying.scope
param is being ignored.As
register
docstring states:so, example:
And the scope param is not sent in request.
I checked
req.parameters()
, which gets me the following params:It looks like any other param then not any of those, is ignored.
After researching OAuth docs, in RFC7591 Section 1.3 , I found the following: