KEYCLOAK-6849 - LinkedIn social login provider updated to new LinkedIn OAuth2 endpoint (#5125)
* KEYCLOAK-6849 - LinkedIn social login provider updated to new LinkedIn OAuth2 endpoint * KEYCLOAK-6849 - LinkedIn social login provider test updated * KEYCLOAK-6849 - LinkedIn social login provider test updated to conditionally handle consent page when shown only * Simplify the LinkedIn app authorization This reverts commit c12359e7a13d9ff231fe2e25cddba66ad679a9cd.
This commit is contained in:
1 parent
9a94004fc9
commit
c1311e4619
4 files changed
+27
-11
No files matched your search
@@ -37,12 +37,12 @@ import java.net.URLDecoder;
|
||||
*
|
||||
* @author Vlastimil Elias (velias at redhat dot com)
|
||||
*/
|
||||
public class LinkedInIdentityProvider extends AbstractOAuth2IdentityProvider implements SocialIdentityProvider {
|
||||
public class LinkedInIdentityProvider extends AbstractOAuth2IdentityProvider<OAuth2IdentityProviderConfig> implements SocialIdentityProvider<OAuth2IdentityProviderConfig> {
|
||||
|
||||
private static final Logger log = Logger.getLogger(LinkedInIdentityProvider.class);
|
||||
|
||||
public static final String AUTH_URL = "https://www.linkedin.com/uas/oauth2/authorization";
|
||||
public static final String TOKEN_URL = "https://www.linkedin.com/uas/oauth2/accessToken";
|
||||
public static final String AUTH_URL = "https://www.linkedin.com/oauth/v2/authorization";
|
||||
public static final String TOKEN_URL = "https://www.linkedin.com/oauth/v2/accessToken";
|
||||
public static final String PROFILE_URL = "https://api.linkedin.com/v1/people/~:(id,formatted-name,email-address,public-profile-url)?format=json";
|
||||
public static final String DEFAULT_SCOPE = "r_basicprofile r_emailaddress";
|
||||
|
||||
|
||||
@@ -292,8 +292,10 @@ The social login tests require setup of all social networks including an example
|
||||
shared as it would result in the clients and users eventually being blocked. By default these tests are skipped.
|
||||
|
||||
To run the full test you need to configure clients in Google, Facebook, GitHub, Twitter, LinkedIn, Microsoft, PayPal and
|
||||
StackOverflow. See the server administration guide for details on how to do that. Further, you also need to create a
|
||||
sample user that can login to the social network.
|
||||
StackOverflow. See the server administration guide for details on how to do that. You have to use URLs like
|
||||
`http://localhost:8180/auth/realms/social/broker/google/endpoint` (with `google` replaced by the name
|
||||
of given provider) as an authorized redirect URL when configuring the client. Further, you also need to create a sample user
|
||||
that can login to the social network.
|
||||
|
||||
The details should be added to a standard properties file. For some properties you can use shared common properties and
|
||||
override when needed. Or you can specify these for all providers. All providers require at least clientId and
|
||||
@@ -315,7 +317,8 @@ An example social.properties file looks like:
|
||||
facebook.profile.lastName=Test
|
||||
|
||||
In the example above the common username, password and profile are shared for all providers, but Facebook has a
|
||||
different last name.
|
||||
different last name. Profile informations are used for assertion after login, so you have to set them to be same as
|
||||
user profile information returned by given social login provider for used sample user.
|
||||
|
||||
Some providers actively block bots so you need to use a proper browser to test. Either Firefox or Chrome should work.
|
||||
|
||||
@@ -328,6 +331,7 @@ To run the tests run:
|
||||
-Dbrowser=chrome \
|
||||
-Dsocial.config=/path/to/social.properties
|
||||
|
||||
To run individual social provider test only you can use option like `-Dtest=SocialLoginTest#linkedinLogin`
|
||||
|
||||
## Different Browsers
|
||||
|
||||
|
||||
+15
-3
@@ -17,6 +17,7 @@
|
||||
|
||||
package org.keycloak.testsuite.pages.social;
|
||||
|
||||
import org.openqa.selenium.NoSuchElementException;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
|
||||
@@ -24,20 +25,31 @@ import org.openqa.selenium.support.FindBy;
|
||||
* @author Vaclav Muzikar <vmuzikar@redhat.com>
|
||||
*/
|
||||
public class LinkedInLoginPage extends AbstractSocialLoginPage {
|
||||
@FindBy(id = "session_key-oauth2SAuthorizeForm")
|
||||
@FindBy(id = "session_key-login")
|
||||
private WebElement usernameInput;
|
||||
|
||||
@FindBy(id = "session_password-oauth2SAuthorizeForm")
|
||||
@FindBy(id = "session_password-login")
|
||||
private WebElement passwordInput;
|
||||
|
||||
@FindBy(name = "authorize")
|
||||
@FindBy(name = "signin")
|
||||
private WebElement loginButton;
|
||||
|
||||
@FindBy(name = "action")
|
||||
private WebElement authorizeButton;
|
||||
|
||||
@Override
|
||||
public void login(String user, String password) {
|
||||
usernameInput.clear();
|
||||
usernameInput.sendKeys(user);
|
||||
passwordInput.sendKeys(password);
|
||||
loginButton.click();
|
||||
|
||||
try {
|
||||
authorizeButton.click();
|
||||
log.info("LinkedIn test app authorized");
|
||||
}
|
||||
catch (NoSuchElementException e) {
|
||||
log.info("Skipping LinkedIn app authorization");
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -269,6 +269,7 @@ public class SocialLoginTest extends AbstractKeycloakTest {
|
||||
assertAccount();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void githubLogin() throws InterruptedException {
|
||||
setTestProvider(GITHUB);
|
||||
@@ -362,8 +363,7 @@ public class SocialLoginTest extends AbstractKeycloakTest {
|
||||
log.infof("current URL: %s", driver.getCurrentUrl());
|
||||
log.infof("performing log in to '%s' ...", currentTestProvider.id());
|
||||
currentSocialLoginPage.login(getConfig("username"), getConfig("password"));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
log.infof("already logged in to '%s'; skipping the login process", currentTestProvider.id());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user