Currently confidential OAuth2 clients do not use PKCE by default. PKCE can be enabled through code. However, it would be a lot more convenient be have an option to control this using configuration instead. Otherwise everyone has to implement it by theirselves.

PKCE can be used with confidential clients and the the latest drafts suggests to use it even with confidential clients:

I think it would make sense to have this enabled by default in the medium term (apparently, there is fear that this might break some authorization servers) so maybe an option whose default value could be changed in the future would be nice.

Related:

Comment From: wilkinsona

Thanks for the suggestion.

We don't have a great deal of auto-configuration for this and it currently uses Spring Security's defaults for OAuth2 login:

https://github.com/spring-projects/spring-boot/blob/7c2413f0e38a29d0a812d35ff54184d6d678a22e/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/servlet/OAuth2WebSecurityConfiguration.java#L56-L68

This configuration backs off once any custom security configuration is provided.

I'm not sure that we should start offering properties that are intended to take the place of a Customizer<OAuth2LoginConfigurer<HttpSecurity>> passed to oauth2Login. We would be in danger of trying to recreate Spring Security's DSL in properties and of encouraging people to program through properties.

What's your take on this please, @jgrandja? You said in https://github.com/spring-projects/spring-security/issues/12219#issuecomment-1352147037 that "this type of configuration/setting would make more sense in the Spring Boot auto-configuration classes and properties. However, I don't feel it's necessary as the configuration is pretty straight forward". This was 18 months ago so I wonder if your opinion has changed since then.

I think it would make sense to have this enabled by default in the medium term (apparently, there is fear that this might break some authorization servers) so maybe an option whose default value could be changed in the future would be nice.

I don't think this is something that we'd do in Spring Boot as we prefer to keep our defaults aligned with Spring Security's. If you would like to see PKCE enabled by default, please raise a Spring Security issue.

Comment From: jgrandja

@wilkinsona

"this type of configuration/setting would make more sense in the Spring Boot auto-configuration classes and properties..."

My comment was meant to be more of a general statement but I see that I was a conflicting statement instead. To be clear, a "use-pkce" configuration option per client registration would not make sense to add as a Spring Boot property.

We do not want to promote:

We would be in danger of trying to recreate Spring Security's DSL in properties and of encouraging people to program through properties.

@wilkinsona Please close this issue and we'll take it over in spring-security#12219.

@randomstuff Let's take this conversation to spring-security#12219 and see what we can do to simplify things further.

@sjohnr has an idea that he will propose.

Comment From: wilkinsona

Thanks very much, @jgrandja.