KEYCLOAK-18551 Fixed the adapter to use dynamic openid-configuration instead of building the tokenUrl by itself.

This commit is contained in:
Adamczyk Błażej 2021-06-25 13:55:10 +02:00 committed by Pedro Igor
parent 4e6e125ede
commit e5b05d05f0
2 changed files with 2 additions and 6 deletions

View file

@ -89,9 +89,7 @@ public class BasicAuthRequestAuthenticator extends BearerTokenRequestAuthenticat
AccessTokenResponse tokenResponse=null; AccessTokenResponse tokenResponse=null;
HttpClient client = deployment.getClient(); HttpClient client = deployment.getClient();
HttpPost post = new HttpPost( HttpPost post = new HttpPost(deployment.getTokenUrl());
KeycloakUriBuilder.fromUri(deployment.getAuthServerBaseUrl())
.path(ServiceUrlConstants.TOKEN_PATH).build(deployment.getRealm()));
java.util.List <NameValuePair> formparams = new java.util.ArrayList <NameValuePair>(); java.util.List <NameValuePair> formparams = new java.util.ArrayList <NameValuePair>();
formparams.add(new BasicNameValuePair(OAuth2Constants.GRANT_TYPE, OAuth2Constants.PASSWORD)); formparams.add(new BasicNameValuePair(OAuth2Constants.GRANT_TYPE, OAuth2Constants.PASSWORD));
formparams.add(new BasicNameValuePair("username", username)); formparams.add(new BasicNameValuePair("username", username));

View file

@ -86,9 +86,7 @@ public class DirectAccessGrantsLoginModule extends AbstractKeycloakLoginModule {
protected Auth directGrantAuth(String username, String password) throws IOException, VerificationException { protected Auth directGrantAuth(String username, String password) throws IOException, VerificationException {
String authServerBaseUrl = deployment.getAuthServerBaseUrl(); String authServerBaseUrl = deployment.getAuthServerBaseUrl();
URI directGrantUri = KeycloakUriBuilder.fromUri(authServerBaseUrl).path(ServiceUrlConstants.TOKEN_PATH).build(deployment.getRealm()); HttpPost post = new HttpPost(deployment.getTokenUrl());
HttpPost post = new HttpPost(directGrantUri);
List<NameValuePair> formparams = new ArrayList<NameValuePair>(); List<NameValuePair> formparams = new ArrayList<NameValuePair>();
formparams.add(new BasicNameValuePair(OAuth2Constants.GRANT_TYPE, OAuth2Constants.PASSWORD)); formparams.add(new BasicNameValuePair(OAuth2Constants.GRANT_TYPE, OAuth2Constants.PASSWORD));
formparams.add(new BasicNameValuePair("username", username)); formparams.add(new BasicNameValuePair("username", username));