spring-projects / spring-projects/spring-security
ClientRegistrations should only accept application/json MediaType
@sjohnr is already working on this.
Since Jan 11, 2023.
- Dominant language
- Java
- Stars
- 9.6k
- Forks
- 6.3k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 52
Description
Expected Behavior
As mentionned in OpenID documentation, Open ID Provider Configuration should only provide application/json.
As a result, ClientRegistrations shouldn't call these endpoints with anything else that application/json in Accept header.
Current Behavior
org.springframework.security.oauth2.client.registration.ClientRegistrations use default RestTemplate.
Default dehaviour is to add any supported media type as a request header... then it adds application/json... as well as application/xml with XML prior to JSON.
It works perfectly with most OpenID implementations and deserializers.
But if OpenID Provider can also answer with XML, deserialization can be tricky, and don't work out of the box.
Context
Talking with a third-party OpenID Provider, which configuration may be wrong on the matter : the .well-known/openid-configuration path can answer in XML as well as JSON, depending on the Accept header.
Deserializing some XML lists is tricky, with different converters implementations.
Typical lists are "scopes_supported" :
"scopes_supported": [
"openid",
"tenants",
"roles"
]
which result in XML :
<scopes_supported>openid</scopes_supported>
<scopes_supported>tenants</scopes_supported>
<scopes_supported>roles</scopes_supported>
... converters tends to fail deserializing this list out of the box.
But it should be useless considering specification don't allow XML.
I'm currently using spring-security-oauth2-client version 5.7.5.
Seems to work like a charm adding .accept(MediaType.APPLICATION_JSON) on requests, in org.springframework.security.oauth2.client.registration.ClientRegistrations
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.