keycloak-aplcache
Changes
examples/as7-eap-demo/server/pom.xml 15(+15 -0)
pom.xml 1(+1 -0)
services/pom.xml 6(+6 -0)
social/core/pom.xml 23(+23 -0)
social/google/pom.xml 37(+37 -0)
social/pom.xml 64(+8 -56)
social/twitter/pom.xml 29(+29 -0)
Details
examples/as7-eap-demo/server/pom.xml 15(+15 -0)
diff --git a/examples/as7-eap-demo/server/pom.xml b/examples/as7-eap-demo/server/pom.xml
index c5487e8..03db66c 100755
--- a/examples/as7-eap-demo/server/pom.xml
+++ b/examples/as7-eap-demo/server/pom.xml
@@ -31,6 +31,21 @@
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>org.keycloak</groupId>
+ <artifactId>keycloak-social-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.keycloak</groupId>
+ <artifactId>keycloak-social-google</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.keycloak</groupId>
+ <artifactId>keycloak-social-twitter</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.picketlink</groupId>
<artifactId>picketlink-idm-api</artifactId>
</dependency>
diff --git a/examples/as7-eap-demo/server/src/main/webapp/loginForm.jsp b/examples/as7-eap-demo/server/src/main/webapp/loginForm.jsp
index 0e1b963..f0f42ba 100755
--- a/examples/as7-eap-demo/server/src/main/webapp/loginForm.jsp
+++ b/examples/as7-eap-demo/server/src/main/webapp/loginForm.jsp
@@ -22,13 +22,41 @@
<body>
<div class="modal-body">
- <div id="facebook-login-box" onclick="loginFacebook()">
- <img id="facebook-sign" src="<%=application.getContextPath()%>/img/facebook.png" border="0"/>
- </div>
+ <%
+ String googleLogin = request.getAttribute("KEYCLOAK_SOCIAL_LOGIN").toString();
+ googleLogin += "?provider_id=google";
+ googleLogin += "&client_id=" + request.getAttribute("client_id");
+ if (request.getAttribute("scope") != null) {
+ googleLogin += "&scope=" + request.getAttribute("scope");
+ }
+ if (request.getAttribute("state") != null) {
+ googleLogin += "&state=" + request.getAttribute("state");
+ }
+ googleLogin += "&redirect_uri=" + request.getAttribute("redirect_uri");
+ %>
+
+ <a href="<%=googleLogin%>">
+ Login with Google
+ </a>
- <div id="twitter-login-box" onclick="loginTwitter()">
- <img id="twitter-sign" src="<%=application.getContextPath()%>/img/twitter.png" border="0"/>
- </div>
+ <%
+ String twitterLogin = request.getAttribute("KEYCLOAK_SOCIAL_LOGIN").toString();
+ twitterLogin = twitterLogin.replace("://localhost", "://127.0.0.1");
+
+ twitterLogin += "?provider_id=twitter";
+ twitterLogin += "&client_id=" + request.getAttribute("client_id");
+ if (request.getAttribute("scope") != null) {
+ twitterLogin += "&scope=" + request.getAttribute("scope");
+ }
+ if (request.getAttribute("state") != null) {
+ twitterLogin += "&state=" + request.getAttribute("state");
+ }
+ twitterLogin += "&redirect_uri=" + request.getAttribute("redirect_uri");
+ %>
+
+ <a href="<%=twitterLogin%>">
+ Login with Twitter
+ </a>
<hr/>
<% String errorMessage = (String)request.getAttribute("KEYCLOAK_LOGIN_ERROR_MESSAGE");
pom.xml 1(+1 -0)
diff --git a/pom.xml b/pom.xml
index 3cbe76b..9883d69 100755
--- a/pom.xml
+++ b/pom.xml
@@ -57,6 +57,7 @@
<module>services</module>
<module>integration</module>
<module>examples</module>
+ <module>social</module>
<!--
<module>sdk-html</module>
<module>social</module>
services/pom.xml 6(+6 -0)
diff --git a/services/pom.xml b/services/pom.xml
index 9d32874..74452e2 100755
--- a/services/pom.xml
+++ b/services/pom.xml
@@ -25,6 +25,12 @@
<scope>provided</scope>
</dependency>
<dependency>
+ <groupId>org.keycloak</groupId>
+ <artifactId>keycloak-social-core</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
<scope>provided</scope>
diff --git a/services/src/main/java/org/keycloak/services/resources/AbstractLoginService.java b/services/src/main/java/org/keycloak/services/resources/AbstractLoginService.java
new file mode 100644
index 0000000..b2103c6
--- /dev/null
+++ b/services/src/main/java/org/keycloak/services/resources/AbstractLoginService.java
@@ -0,0 +1,107 @@
+package org.keycloak.services.resources;
+
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriBuilder;
+import javax.ws.rs.core.UriInfo;
+
+import org.jboss.resteasy.logging.Logger;
+import org.jboss.resteasy.spi.HttpRequest;
+import org.jboss.resteasy.spi.HttpResponse;
+import org.keycloak.services.JspRequestParameters;
+import org.keycloak.services.managers.AccessCodeEntry;
+import org.keycloak.services.managers.RealmManager;
+import org.keycloak.services.managers.TokenManager;
+import org.keycloak.services.models.RealmModel;
+import org.keycloak.services.models.RoleModel;
+import org.keycloak.services.models.UserModel;
+
+public abstract class AbstractLoginService {
+
+ @Context
+ protected UriInfo uriInfo;
+ @Context
+ protected HttpHeaders headers;
+ @Context
+ HttpRequest request;
+ @Context
+ HttpResponse response;
+
+ protected String securityFailurePath = "/securityFailure.jsp";
+ protected String loginFormPath = "/loginForm.jsp";
+ protected String oauthFormPath = "/oauthGrantForm.jsp";
+
+ protected RealmModel realm;
+ protected TokenManager tokenManager;
+
+ public AbstractLoginService(RealmModel realm, TokenManager tokenManager) {
+ this.realm = realm;
+ this.tokenManager = tokenManager;
+ }
+
+ protected Response processAccessCode(String scopeParam, String state, String redirect, UserModel client, UserModel user) {
+ RoleModel resourceRole = realm.getRole(RealmManager.RESOURCE_ROLE);
+ RoleModel identityRequestRole = realm.getRole(RealmManager.IDENTITY_REQUESTER_ROLE);
+ boolean isResource = realm.hasRole(client, resourceRole);
+ if (!isResource && !realm.hasRole(client, identityRequestRole)) {
+ securityFailureForward("Login requester not allowed to request login.");
+ return null;
+ }
+ AccessCodeEntry accessCode = tokenManager.createAccessCode(scopeParam, state, redirect, realm, client, user);
+ getLogger().info("processAccessCode: isResource: " + isResource);
+ getLogger().info("processAccessCode: go to oauth page?: "
+ + (!isResource && (accessCode.getRealmRolesRequested().size() > 0 || accessCode.getResourceRolesRequested()
+ .size() > 0)));
+ if (!isResource
+ && (accessCode.getRealmRolesRequested().size() > 0 || accessCode.getResourceRolesRequested().size() > 0)) {
+ oauthGrantPage(accessCode, client);
+ return null;
+ }
+ return redirectAccessCode(accessCode, state, redirect);
+ }
+
+ protected Response redirectAccessCode(AccessCodeEntry accessCode, String state, String redirect) {
+ String code = accessCode.getCode();
+ UriBuilder redirectUri = UriBuilder.fromUri(redirect).queryParam("code", code);
+ getLogger().info("redirectAccessCode: state: " + state);
+ if (state != null)
+ redirectUri.queryParam("state", state);
+ Response.ResponseBuilder location = Response.status(302).location(redirectUri.build());
+ if (realm.isCookieLoginAllowed()) {
+ location.cookie(tokenManager.createLoginCookie(realm, accessCode.getUser(), uriInfo));
+ }
+ return location.build();
+ }
+
+ protected void securityFailureForward(String message) {
+ getLogger().error(message);
+ request.setAttribute(JspRequestParameters.KEYCLOAK_SECURITY_FAILURE_MESSAGE, message);
+ request.forward(securityFailurePath);
+ }
+
+ protected void forwardToLoginForm(String redirect, String clientId, String scopeParam, String state) {
+ request.setAttribute(RealmModel.class.getName(), realm);
+ request.setAttribute("KEYCLOAK_LOGIN_ACTION", TokenService.processLoginUrl(uriInfo).build(realm.getId()));
+ request.setAttribute("KEYCLOAK_SOCIAL_LOGIN", SocialService.redirectToProviderAuthUrl(uriInfo).build(realm.getId()));
+
+ // RESTEASY eats the form data, so we send via an attribute
+ request.setAttribute("redirect_uri", redirect);
+ request.setAttribute("client_id", clientId);
+ request.setAttribute("scope", scopeParam);
+ request.setAttribute("state", state);
+ request.forward(loginFormPath);
+ }
+
+ protected void oauthGrantPage(AccessCodeEntry accessCode, UserModel client) {
+ request.setAttribute("realmRolesRequested", accessCode.getRealmRolesRequested());
+ request.setAttribute("resourceRolesRequested", accessCode.getResourceRolesRequested());
+ request.setAttribute("client", client);
+ request.setAttribute("action", TokenService.processOAuthUrl(uriInfo).build(realm.getId()).toString());
+ request.setAttribute("code", accessCode.getCode());
+
+ request.forward(oauthFormPath);
+ }
+
+ protected abstract Logger getLogger();
+}
diff --git a/services/src/main/java/org/keycloak/services/resources/KeycloakApplication.java b/services/src/main/java/org/keycloak/services/resources/KeycloakApplication.java
index 7467161..5408c92 100755
--- a/services/src/main/java/org/keycloak/services/resources/KeycloakApplication.java
+++ b/services/src/main/java/org/keycloak/services/resources/KeycloakApplication.java
@@ -9,6 +9,7 @@ import org.keycloak.services.models.picketlink.PicketlinkKeycloakSession;
import org.keycloak.services.models.picketlink.PicketlinkKeycloakSessionFactory;
import org.keycloak.services.models.picketlink.mappings.RealmEntity;
import org.keycloak.services.models.picketlink.mappings.ResourceEntity;
+import org.keycloak.social.SocialRequestManager;
import org.picketlink.idm.PartitionManager;
import org.picketlink.idm.config.IdentityConfigurationBuilder;
import org.picketlink.idm.internal.DefaultPartitionManager;
@@ -49,7 +50,7 @@ public class KeycloakApplication extends Application {
KeycloakSessionFactory f = createSessionFactory();
this.factory = f;
KeycloakSessionRequestFilter filter = new KeycloakSessionRequestFilter(factory);
- singletons.add(new RealmsResource(new TokenManager()));
+ singletons.add(new RealmsResource(new TokenManager(), new SocialRequestManager()));
singletons.add(filter);
classes.add(KeycloakSessionResponseFilter.class);
classes.add(SkeletonKeyContextResolver.class);
diff --git a/services/src/main/java/org/keycloak/services/resources/RealmsResource.java b/services/src/main/java/org/keycloak/services/resources/RealmsResource.java
index 753b261..b2db4f4 100755
--- a/services/src/main/java/org/keycloak/services/resources/RealmsResource.java
+++ b/services/src/main/java/org/keycloak/services/resources/RealmsResource.java
@@ -10,6 +10,7 @@ import org.keycloak.services.models.KeycloakSessionFactory;
import org.keycloak.services.models.RealmModel;
import org.keycloak.services.models.RoleModel;
import org.keycloak.services.models.UserModel;
+import org.keycloak.social.SocialRequestManager;
import javax.ws.rs.Consumes;
import javax.ws.rs.NotAuthorizedException;
@@ -44,8 +45,11 @@ public class RealmsResource {
protected TokenManager tokenManager;
- public RealmsResource(TokenManager tokenManager) {
+ protected SocialRequestManager socialRequestManager;
+
+ public RealmsResource(TokenManager tokenManager, SocialRequestManager socialRequestManager) {
this.tokenManager = tokenManager;
+ this.socialRequestManager = socialRequestManager;
}
public static UriBuilder realmBaseUrl(UriInfo uriInfo) {
@@ -71,6 +75,23 @@ public class RealmsResource {
}
+ @Path("{realm}/social")
+ public SocialService getSocialService(final @PathParam("realm") String id) {
+ return new Transaction(false) {
+ @Override
+ protected SocialService callImpl() {
+ RealmManager realmManager = new RealmManager(session);
+ RealmModel realm = realmManager.getRealm(id);
+ if (realm == null) {
+ logger.debug("realm not found");
+ throw new NotFoundException();
+ }
+ SocialService socialService = new SocialService(realm, tokenManager, socialRequestManager);
+ resourceContext.initResource(socialService);
+ return socialService;
+ }
+ }.call();
+ }
@Path("{realm}")
public RealmSubResource getRealmResource(final @PathParam("realm") String id) {
diff --git a/services/src/main/java/org/keycloak/services/resources/SocialService.java b/services/src/main/java/org/keycloak/services/resources/SocialService.java
new file mode 100644
index 0000000..d497f8e
--- /dev/null
+++ b/services/src/main/java/org/keycloak/services/resources/SocialService.java
@@ -0,0 +1,259 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.keycloak.services.resources;
+
+import java.net.URISyntaxException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import javax.imageio.spi.ServiceRegistry;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+import javax.ws.rs.core.UriBuilder;
+import javax.ws.rs.core.UriInfo;
+
+import org.jboss.resteasy.logging.Logger;
+import org.keycloak.services.managers.TokenManager;
+import org.keycloak.services.models.RealmModel;
+import org.keycloak.services.models.UserModel;
+import org.keycloak.social.AuthCallback;
+import org.keycloak.social.AuthRequest;
+import org.keycloak.social.RequestDetails;
+import org.keycloak.social.RequestDetailsBuilder;
+import org.keycloak.social.SocialProvider;
+import org.keycloak.social.SocialProviderConfig;
+import org.keycloak.social.SocialProviderException;
+import org.keycloak.social.SocialRequestManager;
+import org.keycloak.social.SocialUser;
+
+/**
+ * @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
+ */
+public class SocialService extends AbstractLoginService {
+
+ private static final Logger logger = Logger.getLogger(SocialService.class);
+
+ @Context
+ private HttpHeaders headers;
+
+ @Context
+ private UriInfo uriInfo;
+
+ public static UriBuilder socialServiceBaseUrl(UriInfo uriInfo) {
+ UriBuilder base = uriInfo.getBaseUriBuilder().path(RealmsResource.class).path(RealmsResource.class, "getSocialService");
+ return base;
+ }
+
+ public static UriBuilder redirectToProviderAuthUrl(UriInfo uriInfo) {
+ return socialServiceBaseUrl(uriInfo).path(SocialService.class, "redirectToProviderAuth");
+
+ }
+
+ public static UriBuilder callbackUrl(UriInfo uriInfo) {
+ return socialServiceBaseUrl(uriInfo).path(SocialService.class, "callback");
+
+ }
+
+ private SocialRequestManager socialRequestManager;
+
+ public SocialService(RealmModel realm, TokenManager tokenManager, SocialRequestManager socialRequestManager) {
+ super(realm, tokenManager);
+ this.socialRequestManager = socialRequestManager;
+ }
+
+ @GET
+ @Path("callback")
+ public Response callback() throws URISyntaxException {
+ return new Transaction() {
+ protected Response callImpl() {
+ Map<String, String[]> queryParams = getQueryParams();
+
+ RequestDetails requestData = getRequestDetails(queryParams);
+ SocialProvider provider = getProvider(requestData.getProviderId());
+
+ String key = System.getProperty("keycloak.social." + requestData.getProviderId() + ".key");
+ String secret = System.getProperty("keycloak.social." + requestData.getProviderId() + ".secret");
+ String callbackUri = callbackUrl(uriInfo).build(realm.getId()).toString();
+
+ SocialProviderConfig config = new SocialProviderConfig(key, secret, callbackUri);
+
+ AuthCallback callback = new AuthCallback(requestData.getSocialAttributes(), queryParams);
+
+ SocialUser socialUser = null;
+ try {
+ socialUser = provider.processCallback(config, callback);
+ } catch (SocialProviderException e) {
+ logger.warn("Failed to process social callback", e);
+ securityFailureForward("Failed to process social callback");
+ return null;
+ }
+
+ if (!realm.isEnabled()) {
+ securityFailureForward("Realm not enabled.");
+ return null;
+ }
+
+ String clientId = requestData.getClientAttributes().get("clientId");
+
+ UserModel client = realm.getUser(clientId);
+ if (client == null) {
+ securityFailureForward("Unknown login requester.");
+ return null;
+ }
+ if (!client.isEnabled()) {
+ securityFailureForward("Login requester not enabled.");
+ return null;
+ }
+
+ // TODO Lookup user based on attribute for provider id - this is so a user can have a friendly username + link a
+ // user to
+ // multiple social logins
+ UserModel user = realm.getUser(provider.getId() + "." + socialUser.getId());
+
+ if (user == null) {
+ user = realm.addUser(provider.getId() + "." + socialUser.getId());
+ user.setAttribute(provider.getId() + ".id", socialUser.getId());
+
+ // TODO Grant default roles for realm when available
+ realm.grantRole(user, realm.getRole("user"));
+ }
+
+ if (!user.isEnabled()) {
+ securityFailureForward("Your account is not enabled.");
+ return null;
+ }
+
+ String scope = requestData.getClientAttributes().get("scope");
+ String state = requestData.getClientAttributes().get("state");
+ String redirectUri = requestData.getClientAttributes().get("redirectUri");
+
+ return processAccessCode(scope, state, redirectUri, client, user);
+ }
+ }.call();
+ }
+
+ @GET
+ @Path("providers")
+ @Produces(MediaType.APPLICATION_JSON)
+ public List<SocialProvider> getProviders() {
+ List<SocialProvider> providers = new LinkedList<SocialProvider>();
+ Iterator<SocialProvider> itr = ServiceRegistry.lookupProviders(SocialProvider.class);
+ while (itr.hasNext()) {
+ providers.add(itr.next());
+ }
+ return providers;
+ }
+
+ @GET
+ @Path("login")
+ public Response redirectToProviderAuth(@QueryParam("provider_id") final String providerId,
+ @QueryParam("client_id") final String clientId, @QueryParam("scope") final String scope,
+ @QueryParam("state") final String state, @QueryParam("redirect_uri") final String redirectUri) {
+ return new Transaction() {
+ protected Response callImpl() {
+ SocialProvider provider = getProvider(providerId);
+ if (provider == null) {
+ securityFailureForward("Social provider not found");
+ return null;
+ }
+
+ String key = System.getProperty("keycloak.social." + providerId + ".key");
+ String secret = System.getProperty("keycloak.social." + providerId + ".secret");
+ String callbackUri = callbackUrl(uriInfo).build(realm.getId()).toString();
+
+ SocialProviderConfig config = new SocialProviderConfig(key, secret, callbackUri);
+
+ try {
+ AuthRequest authRequest = provider.getAuthUrl(config);
+
+ RequestDetails socialRequest = RequestDetailsBuilder.create(providerId)
+ .putSocialAttributes(authRequest.getAttributes()).putClientAttribute("clientId", clientId)
+ .putClientAttribute("scope", scope).putClientAttribute("state", state)
+ .putClientAttribute("redirectUri", redirectUri).build();
+
+ socialRequestManager.addRequest(authRequest.getId(), socialRequest);
+
+ return Response.status(Status.FOUND).location(authRequest.getAuthUri()).build();
+ } catch (Throwable t) {
+ logger.error("Failed to redirect to social auth", t);
+ securityFailureForward("Failed to redirect to social auth");
+ return null;
+ }
+ }
+ }.call();
+ }
+
+ private RequestDetails getRequestDetails(Map<String, String[]> queryParams) {
+ Iterator<SocialProvider> itr = ServiceRegistry.lookupProviders(SocialProvider.class);
+
+ while (itr.hasNext()) {
+ SocialProvider provider = itr.next();
+
+ if (queryParams.containsKey(provider.getRequestIdParamName())) {
+ String requestId = queryParams.get(provider.getRequestIdParamName())[0];
+ if (socialRequestManager.isRequestId(requestId)) {
+ return socialRequestManager.retrieveData(requestId);
+ }
+ }
+ }
+
+ return null;
+ }
+
+ private SocialProvider getProvider(String providerId) {
+ Iterator<SocialProvider> itr = ServiceRegistry.lookupProviders(SocialProvider.class);
+
+ while (itr.hasNext()) {
+ SocialProvider provider = itr.next();
+ if (provider.getId().equals(providerId)) {
+ return provider;
+ }
+ }
+
+ return null;
+ }
+
+ private Map<String, String[]> getQueryParams() {
+ Map<String, String[]> queryParams = new HashMap<String, String[]>();
+ for (Entry<String, List<String>> e : uriInfo.getQueryParameters().entrySet()) {
+ queryParams.put(e.getKey(), e.getValue().toArray(new String[e.getValue().size()]));
+ }
+ return queryParams;
+ }
+
+ @Override
+ protected Logger getLogger() {
+ return logger;
+ }
+
+}
diff --git a/services/src/main/java/org/keycloak/services/resources/TokenService.java b/services/src/main/java/org/keycloak/services/resources/TokenService.java
index 5cabe41..b16c1ef 100755
--- a/services/src/main/java/org/keycloak/services/resources/TokenService.java
+++ b/services/src/main/java/org/keycloak/services/resources/TokenService.java
@@ -5,17 +5,13 @@ import org.jboss.resteasy.jose.jws.JWSInput;
import org.jboss.resteasy.jose.jws.crypto.RSAProvider;
import org.jboss.resteasy.jwt.JsonSerialization;
import org.jboss.resteasy.logging.Logger;
-import org.jboss.resteasy.spi.HttpRequest;
-import org.jboss.resteasy.spi.HttpResponse;
import org.keycloak.representations.AccessTokenResponse;
import org.keycloak.representations.SkeletonKeyToken;
-import org.keycloak.services.JspRequestParameters;
import org.keycloak.services.managers.AccessCodeEntry;
import org.keycloak.services.managers.AuthenticationManager;
import org.keycloak.services.managers.RealmManager;
import org.keycloak.services.managers.ResourceAdminManager;
import org.keycloak.services.managers.TokenManager;
-import org.keycloak.services.models.KeycloakSession;
import org.keycloak.services.models.RealmModel;
import org.keycloak.services.models.RoleModel;
import org.keycloak.services.models.UserModel;
@@ -28,7 +24,6 @@ import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
-import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
@@ -44,37 +39,21 @@ import java.util.Map;
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
* @version $Revision: 1 $
*/
-public class TokenService {
+public class TokenService extends AbstractLoginService {
protected static final Logger logger = Logger.getLogger(TokenService.class);
@Context
- protected UriInfo uriInfo;
- @Context
protected Providers providers;
@Context
protected SecurityContext securityContext;
- @Context
- protected HttpHeaders headers;
- @Context
- HttpRequest request;
- @Context
- HttpResponse response;
-
- protected String securityFailurePath = "/securityFailure.jsp";
- protected String loginFormPath = "/loginForm.jsp";
- protected String oauthFormPath = "/oauthGrantForm.jsp";
-
- protected RealmModel realm;
- protected TokenManager tokenManager;
protected AuthenticationManager authManager = new AuthenticationManager();
private ResourceAdminManager resourceAdminManager = new ResourceAdminManager();
public TokenService(RealmModel realm, TokenManager tokenManager) {
- this.realm = realm;
- this.tokenManager = tokenManager;
+ super(realm, tokenManager);
}
public static UriBuilder tokenServiceBaseUrl(UriInfo uriInfo) {
@@ -227,36 +206,6 @@ public class TokenService {
}.call();
}
- protected Response processAccessCode(String scopeParam, String state, String redirect, UserModel client, UserModel user) {
- RoleModel resourceRole = realm.getRole(RealmManager.RESOURCE_ROLE);
- RoleModel identityRequestRole = realm.getRole(RealmManager.IDENTITY_REQUESTER_ROLE);
- boolean isResource = realm.hasRole(client, resourceRole);
- if (!isResource && !realm.hasRole(client, identityRequestRole)) {
- securityFailureForward("Login requester not allowed to request login.");
- return null;
- }
- AccessCodeEntry accessCode = tokenManager.createAccessCode(scopeParam, state, redirect, realm, client, user);
- logger.info("processAccessCode: isResource: " + isResource);
- logger.info("processAccessCode: go to oauth page?: " + (!isResource && (accessCode.getRealmRolesRequested().size() > 0 || accessCode.getResourceRolesRequested().size() > 0)));
- if (!isResource && (accessCode.getRealmRolesRequested().size() > 0 || accessCode.getResourceRolesRequested().size() > 0)) {
- oauthGrantPage(accessCode, client);
- return null;
- }
- return redirectAccessCode(accessCode, state, redirect);
- }
-
- protected Response redirectAccessCode(AccessCodeEntry accessCode, String state, String redirect) {
- String code = accessCode.getCode();
- UriBuilder redirectUri = UriBuilder.fromUri(redirect).queryParam("code", code);
- logger.info("redirectAccessCode: state: " + state);
- if (state != null) redirectUri.queryParam("state", state);
- Response.ResponseBuilder location = Response.status(302).location(redirectUri.build());
- if (realm.isCookieLoginAllowed()) {
- location.cookie(tokenManager.createLoginCookie(realm, accessCode.getUser(), uriInfo));
- }
- return location.build();
- }
-
@Path("access/codes")
@POST
@Produces("application/json")
@@ -382,27 +331,6 @@ public class TokenService {
return res;
}
- protected void securityFailureForward(String message) {
- logger.error(message);
- request.setAttribute(JspRequestParameters.KEYCLOAK_SECURITY_FAILURE_MESSAGE, message);
- request.forward(securityFailurePath);
- }
-
- protected void forwardToLoginForm(String redirect,
- String clientId,
- String scopeParam,
- String state) {
- request.setAttribute(RealmModel.class.getName(), realm);
- request.setAttribute("KEYCLOAK_LOGIN_ACTION", processLoginUrl(uriInfo).build(realm.getId()));
-
- // RESTEASY eats the form data, so we send via an attribute
- request.setAttribute("redirect_uri", redirect);
- request.setAttribute("client_id", clientId);
- request.setAttribute("scope", scopeParam);
- request.setAttribute("state", state);
- request.forward(loginFormPath);
- }
-
@Path("login")
@GET
public Response loginPage(final @QueryParam("response_type") String responseType,
@@ -517,14 +445,9 @@ public class TokenService {
return location.build();
}
- protected void oauthGrantPage(AccessCodeEntry accessCode, UserModel client) {
- request.setAttribute("realmRolesRequested", accessCode.getRealmRolesRequested());
- request.setAttribute("resourceRolesRequested", accessCode.getResourceRolesRequested());
- request.setAttribute("client", client);
- request.setAttribute("action", processOAuthUrl(uriInfo).build(realm.getId()).toString());
- request.setAttribute("code", accessCode.getCode());
-
- request.forward(oauthFormPath);
+ @Override
+ protected Logger getLogger() {
+ return logger;
}
}
social/core/pom.xml 23(+23 -0)
diff --git a/social/core/pom.xml b/social/core/pom.xml
new file mode 100755
index 0000000..7b6c22a
--- /dev/null
+++ b/social/core/pom.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+<project>
+ <parent>
+ <artifactId>keycloak-social-parent</artifactId>
+ <groupId>org.keycloak</groupId>
+ <version>1.0-alpha-1</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>keycloak-social-core</artifactId>
+ <name>Keycloak Social Core</name>
+ <description/>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>jaxrs-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/social/core/src/main/java/org/keycloak/social/AuthCallback.java b/social/core/src/main/java/org/keycloak/social/AuthCallback.java
new file mode 100644
index 0000000..16fc089
--- /dev/null
+++ b/social/core/src/main/java/org/keycloak/social/AuthCallback.java
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.keycloak.social;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
+ */
+public class AuthCallback {
+
+ private Map<String, String> attributes;
+
+ private Map<String, String[]> queryParams;
+
+ public AuthCallback(Map<String, String> attributes, Map<String, String[]> queryParams) {
+ this.attributes = attributes;
+ this.queryParams = queryParams;
+ }
+
+ public String getAttribute(String name) {
+ return attributes.get(name);
+ }
+
+ public String getQueryParam(String name) {
+ String[] value = queryParams.get(name);
+ if (value.length > 0) {
+ return value[0];
+ }
+ return null;
+ }
+
+}
diff --git a/social/core/src/main/java/org/keycloak/social/AuthRequestBuilder.java b/social/core/src/main/java/org/keycloak/social/AuthRequestBuilder.java
new file mode 100644
index 0000000..600783d
--- /dev/null
+++ b/social/core/src/main/java/org/keycloak/social/AuthRequestBuilder.java
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.keycloak.social;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.ws.rs.core.UriBuilder;
+
+/**
+ * @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
+ */
+public class AuthRequestBuilder {
+
+ private UriBuilder b;
+
+ private Map<String, String> attributes;
+
+ private String id;
+
+ private AuthRequestBuilder() {
+ }
+
+ public static AuthRequestBuilder create(String id, String path) {
+ AuthRequestBuilder req = new AuthRequestBuilder();
+ req.id = id;
+ req.b = UriBuilder.fromUri(path);
+ req.attributes = new HashMap<String, String>();
+ return req;
+ }
+
+ public AuthRequestBuilder setQueryParam(String name, String value) {
+ b.queryParam(name, value);
+ return this;
+ }
+
+ public AuthRequestBuilder setAttribute(String name, String value) {
+ attributes.put(name, value);
+ return this;
+ }
+
+ public AuthRequest build() {
+ return new AuthRequest(id, b.build(), attributes);
+ }
+
+}
diff --git a/social/core/src/main/java/org/keycloak/social/RequestDetails.java b/social/core/src/main/java/org/keycloak/social/RequestDetails.java
new file mode 100644
index 0000000..0476a64
--- /dev/null
+++ b/social/core/src/main/java/org/keycloak/social/RequestDetails.java
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.keycloak.social;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
+ */
+public class RequestDetails {
+
+ private String providerId;
+
+ private Map<String, String> clientAttributes;
+
+ private Map<String, String> socialAttributes;
+
+ RequestDetails(String providerId, Map<String, String> clientAttributes, Map<String, String> socialAttributes) {
+ this.providerId = providerId;
+ this.clientAttributes = clientAttributes;
+ this.socialAttributes = socialAttributes;
+ }
+
+ public String getProviderId() {
+ return providerId;
+ }
+
+ public String getClientAttribute(String name) {
+ return clientAttributes.get(name);
+ }
+
+ public Map<String, String> getClientAttributes() {
+ return clientAttributes;
+ }
+
+ public String getSocialAttribute(String name) {
+ return socialAttributes.get(name);
+ }
+
+ public Map<String, String> getSocialAttributes() {
+ return socialAttributes;
+ }
+
+}
diff --git a/social/core/src/main/java/org/keycloak/social/RequestDetailsBuilder.java b/social/core/src/main/java/org/keycloak/social/RequestDetailsBuilder.java
new file mode 100644
index 0000000..a8d8286
--- /dev/null
+++ b/social/core/src/main/java/org/keycloak/social/RequestDetailsBuilder.java
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.keycloak.social;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
+ */
+public class RequestDetailsBuilder {
+
+ private String providerId;
+
+ private Map<String, String> clientAttributes;
+
+ private Map<String, String> socialAttributes;
+
+ private RequestDetailsBuilder() {
+ }
+
+ public static RequestDetailsBuilder create(String providerId) {
+ RequestDetailsBuilder req = new RequestDetailsBuilder();
+ req.providerId = providerId;
+ req.clientAttributes = new HashMap<String, String>();
+ req.socialAttributes = new HashMap<String, String>();
+ return req;
+ }
+
+ public RequestDetailsBuilder putClientAttribute(String name, String value) {
+ clientAttributes.put(name, value);
+ return this;
+ }
+
+ public RequestDetailsBuilder putClientAttributes(Map<String, String> attributes) {
+ clientAttributes.putAll(attributes);
+ return this;
+ }
+
+ public RequestDetailsBuilder putSocialAttribute(String name, String value) {
+ socialAttributes.put(name, value);
+ return this;
+ }
+
+ public RequestDetailsBuilder putSocialAttributes(Map<String, String> attributes) {
+ socialAttributes.putAll(attributes);
+ return this;
+ }
+
+ public RequestDetails build() {
+ return new RequestDetails(providerId, clientAttributes, socialAttributes);
+ }
+
+}
diff --git a/social/core/src/main/java/org/keycloak/social/SocialProviderConfig.java b/social/core/src/main/java/org/keycloak/social/SocialProviderConfig.java
new file mode 100644
index 0000000..d6d1276
--- /dev/null
+++ b/social/core/src/main/java/org/keycloak/social/SocialProviderConfig.java
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.keycloak.social;
+
+/**
+ * @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
+ */
+public class SocialProviderConfig {
+
+ private String callbackUrl;
+
+ private String key;
+
+ private String secret;
+
+ public SocialProviderConfig(String key, String secret, String callbackUrl) {
+ this.key = key;
+ this.secret = secret;
+ this.callbackUrl = callbackUrl;
+ }
+
+ public String getCallbackUrl() {
+ return callbackUrl;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public String getSecret() {
+ return secret;
+ }
+
+ public void setSecret(String secret) {
+ this.secret = secret;
+ }
+
+}
diff --git a/social/core/src/main/java/org/keycloak/social/SocialRequestManager.java b/social/core/src/main/java/org/keycloak/social/SocialRequestManager.java
new file mode 100644
index 0000000..684254a
--- /dev/null
+++ b/social/core/src/main/java/org/keycloak/social/SocialRequestManager.java
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.keycloak.social;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+/**
+ * @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
+ */
+public class SocialRequestManager {
+
+ public static final long TIMEOUT = 10 * 60 * 1000;
+
+ private Map<String, RequestDetails> map = new HashMap<String, RequestDetails>();
+
+ private LinkedHashMap<String, Long> expires = new LinkedHashMap<String, Long>();
+
+ public synchronized void addRequest(String requestId, RequestDetails request) {
+ pruneExpired();
+
+ map.put(requestId, request);
+ expires.put(requestId, System.currentTimeMillis() + TIMEOUT);
+ }
+
+ public synchronized boolean isRequestId(String requestId) {
+ return map.containsKey(requestId);
+ }
+
+ public synchronized RequestDetails retrieveData(String requestId) {
+ expires.remove(requestId);
+ RequestDetails details = map.remove(requestId);
+
+ pruneExpired();
+
+ return details;
+ }
+
+ private void pruneExpired() {
+ Iterator<Entry<String, Long>> itr = expires.entrySet().iterator();
+ while (itr.hasNext()) {
+ Entry<String, Long> e = itr.next();
+ if (e.getValue() < System.currentTimeMillis()) {
+ itr.remove();
+ map.remove(e.getKey());
+ } else {
+ return;
+ }
+ }
+ }
+
+}
diff --git a/social/core/src/main/java/org/keycloak/social/SocialUser.java b/social/core/src/main/java/org/keycloak/social/SocialUser.java
new file mode 100644
index 0000000..fc0b7f2
--- /dev/null
+++ b/social/core/src/main/java/org/keycloak/social/SocialUser.java
@@ -0,0 +1,46 @@
+package org.keycloak.social;
+
+public class SocialUser {
+
+ private String id;
+ private String firstName;
+ private String lastName;
+ private String email;
+
+ public SocialUser(String id) {
+ this.id = id;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+}
social/google/pom.xml 37(+37 -0)
diff --git a/social/google/pom.xml b/social/google/pom.xml
new file mode 100755
index 0000000..7553e6b
--- /dev/null
+++ b/social/google/pom.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0"?>
+<project>
+ <parent>
+ <artifactId>keycloak-social-parent</artifactId>
+ <groupId>org.keycloak</groupId>
+ <version>1.0-alpha-1</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>keycloak-social-google</artifactId>
+ <name>Keycloak Social Google</name>
+ <description/>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.keycloak</groupId>
+ <artifactId>keycloak-social-core</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.google.api-client</groupId>
+ <artifactId>google-api-client</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.google.http-client</groupId>
+ <artifactId>google-http-client-jackson</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.google.apis</groupId>
+ <artifactId>google-api-services-oauth2</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
social/pom.xml 64(+8 -56)
diff --git a/social/pom.xml b/social/pom.xml
index f91a7c7..9efd60c 100755
--- a/social/pom.xml
+++ b/social/pom.xml
@@ -8,63 +8,15 @@
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>keycloak-social</artifactId>
- <name>Keycloak Social</name>
+ <artifactId>keycloak-social-parent</artifactId>
+ <name>Keycloak Social Parent</name>
<description/>
+ <packaging>pom</packaging>
- <dependencies>
- <dependency>
- <groupId>org.jboss.resteasy</groupId>
- <artifactId>resteasy-jaxrs</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.resteasy</groupId>
- <artifactId>jaxrs-api</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.picketlink</groupId>
- <artifactId>picketlink-idm-api</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.spec.javax.ejb</groupId>
- <artifactId>jboss-ejb-api_3.2_spec</artifactId>
- <version>1.0.0.Alpha2</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>com.google.api-client</groupId>
- <artifactId>google-api-client</artifactId>
- </dependency>
- <dependency>
- <groupId>com.google.http-client</groupId>
- <artifactId>google-http-client-jackson</artifactId>
- </dependency>
- <dependency>
- <groupId>com.google.apis</groupId>
- <artifactId>google-api-services-oauth2</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.twitter4j</groupId>
- <artifactId>twitter4j-core</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.6</source>
- <target>1.6</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
+ <modules>
+ <module>core</module>
+ <module>google</module>
+ <module>twitter</module>
+ </modules>
</project>
social/twitter/pom.xml 29(+29 -0)
diff --git a/social/twitter/pom.xml b/social/twitter/pom.xml
new file mode 100755
index 0000000..8f11323
--- /dev/null
+++ b/social/twitter/pom.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0"?>
+<project>
+ <parent>
+ <artifactId>keycloak-social-parent</artifactId>
+ <groupId>org.keycloak</groupId>
+ <version>1.0-alpha-1</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>keycloak-social-twitter</artifactId>
+ <name>Keycloak Social Twitter</name>
+ <description/>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.keycloak</groupId>
+ <artifactId>keycloak-social-core</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.twitter4j</groupId>
+ <artifactId>twitter4j-core</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/social/twitter/src/main/resources/META-INF/services/org.keycloak.social.SocialProvider b/social/twitter/src/main/resources/META-INF/services/org.keycloak.social.SocialProvider
new file mode 100644
index 0000000..a033621
--- /dev/null
+++ b/social/twitter/src/main/resources/META-INF/services/org.keycloak.social.SocialProvider
@@ -0,0 +1 @@
+org.keycloak.social.twitter.TwitterProvider