You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Locally this works all fine, because it runs on http. However, when we deploy our applications on Cloud Foundry, we connect via https. This then creates/adds a x509 certificate to the request coming in on the authorization server, which then triggers X509ClientCertificateAuthenticationConverter. This converter looks for the client_id, but that was never added by OAuth2AuthorizationCodeGrantRequestEntityConverter and thus throws an exception:
if (!ClientAuthenticationMethod.CLIENT_SECRET_BASIC
.equals(clientRegistration.getClientAuthenticationMethod())) {
parameters.add(OAuth2ParameterNames.CLIENT_ID, clientRegistration.getClientId());
}
Maybe our set-up is wrong and we should not use client_secret_basic. Hoever, we also tried using client_secret_post, which gave a different error message, because X509ClientCertificateAuthenticationConverter changes the authentication method to tls_client_auth:
It seems like you cannot use another authentication method once you have a certificate and X509ClientCertificateAuthenticationConverter triggers.
We also found a somewhat nasty workaround where we remove the request attribute jakarta.servlet.request.X509Certificate via a filter, this just blocks the inner workings of X509ClientCertificateAuthenticationConverter and won't change the client authentication method.
But of course, we rather don't do that.
I would expect that if I set a client authentication method this would be used, not overwritten by the converter just because there is a (unrelated) certificate passed along.
(Side note, I asked on StackOverflow too, but got no interaction going there.)
The text was updated successfully, but these errors were encountered:
jgrandja
changed the title
Spring Auth Server: x509 client certificate authentication enforces client_id without checking on client authentication method
X509 client certificate authentication enforces client_id without checking on client authentication method
Jun 5, 2024
We recently upgraded to Spring Boot 3.3 and Spring Authorization Server 1.3.0. We do an OAuth2 flow with the following configuration:
We have not set any client authentication method on this side, but the default is
client_secret_basic
, which we also use in our authorization server:Locally this works all fine, because it runs on http. However, when we deploy our applications on Cloud Foundry, we connect via https. This then creates/adds a x509 certificate to the request coming in on the authorization server, which then triggers
X509ClientCertificateAuthenticationConverter
. This converter looks for theclient_id
, but that was never added byOAuth2AuthorizationCodeGrantRequestEntityConverter
and thus throws an exception:Maybe our set-up is wrong and we should not use
client_secret_basic
. Hoever, we also tried usingclient_secret_post
, which gave a different error message, becauseX509ClientCertificateAuthenticationConverter
changes the authentication method totls_client_auth
:It seems like you cannot use another authentication method once you have a certificate and
X509ClientCertificateAuthenticationConverter
triggers.We also found a somewhat nasty workaround where we remove the request attribute
jakarta.servlet.request.X509Certificate
via a filter, this just blocks the inner workings ofX509ClientCertificateAuthenticationConverter
and won't change the client authentication method.But of course, we rather don't do that.
I would expect that if I set a client authentication method this would be used, not overwritten by the converter just because there is a (unrelated) certificate passed along.
(Side note, I asked on StackOverflow too, but got no interaction going there.)
The text was updated successfully, but these errors were encountered: