diff --git a/audit/api/pom.xml b/audit/api/pom.xml index facd5866a3..5eeb3494fb 100755 --- a/audit/api/pom.xml +++ b/audit/api/pom.xml @@ -16,6 +16,7 @@ org.jboss.logging jboss-logging + provided org.keycloak diff --git a/audit/jboss-logging/pom.xml b/audit/jboss-logging/pom.xml index f3f11bad14..3de5cec950 100755 --- a/audit/jboss-logging/pom.xml +++ b/audit/jboss-logging/pom.xml @@ -16,6 +16,7 @@ org.jboss.logging jboss-logging + provided org.keycloak diff --git a/audit/jpa/pom.xml b/audit/jpa/pom.xml index e8fa5501d9..504136a68f 100755 --- a/audit/jpa/pom.xml +++ b/audit/jpa/pom.xml @@ -55,6 +55,7 @@ org.json json + provided diff --git a/audit/mongo/pom.xml b/audit/mongo/pom.xml index 53f6f734b9..4f5098ee44 100755 --- a/audit/mongo/pom.xml +++ b/audit/mongo/pom.xml @@ -44,6 +44,7 @@ org.json json + provided diff --git a/forms/account-api/pom.xml b/forms/account-api/pom.xml index 1ad638a8f8..33658a58ff 100755 --- a/forms/account-api/pom.xml +++ b/forms/account-api/pom.xml @@ -18,24 +18,29 @@ org.keycloak keycloak-core ${project.version} + provided org.keycloak keycloak-model-api ${project.version} + provided org.keycloak keycloak-audit-api ${project.version} + provided org.jboss.resteasy jaxrs-api + provided org.jboss.resteasy resteasy-jaxrs + provided diff --git a/forms/account-freemarker/pom.xml b/forms/account-freemarker/pom.xml index c438fedd09..1c5c02afdd 100755 --- a/forms/account-freemarker/pom.xml +++ b/forms/account-freemarker/pom.xml @@ -18,32 +18,49 @@ org.keycloak keycloak-core ${project.version} + provided org.keycloak keycloak-account-api ${project.version} + provided org.keycloak keycloak-model-api ${project.version} + provided org.keycloak keycloak-forms-common-freemarker ${project.version} + provided org.keycloak keycloak-services ${project.version} + provided - - org.keycloak - keycloak-social-core - ${project.version} - + + org.keycloak + keycloak-social-core + ${project.version} + provided + + + org.keycloak + keycloak-audit-api + ${project.version} + provided + + + org.jboss.logging + jboss-logging + provided + org.jboss.resteasy resteasy-jaxrs @@ -52,6 +69,7 @@ org.freemarker freemarker + provided diff --git a/forms/common-freemarker/pom.xml b/forms/common-freemarker/pom.xml index f7511d4397..f89c87bf98 100755 --- a/forms/common-freemarker/pom.xml +++ b/forms/common-freemarker/pom.xml @@ -18,23 +18,28 @@ org.keycloak keycloak-core ${project.version} + provided org.keycloak keycloak-model-api ${project.version} + provided org.jboss.resteasy resteasy-jaxrs + provided org.freemarker freemarker + provided org.jboss.logging jboss-logging + provided junit diff --git a/forms/common-themes/pom.xml b/forms/common-themes/pom.xml index cb1d6f9673..411e96ae86 100755 --- a/forms/common-themes/pom.xml +++ b/forms/common-themes/pom.xml @@ -18,24 +18,29 @@ org.keycloak keycloak-core ${project.version} + provided org.keycloak keycloak-model-api ${project.version} + provided org.keycloak keycloak-forms-common-freemarker ${project.version} + provided org.jboss.resteasy jaxrs-api + provided org.jboss.resteasy resteasy-jaxrs + provided diff --git a/forms/login-api/pom.xml b/forms/login-api/pom.xml index 9b44836f0b..bb2a702832 100755 --- a/forms/login-api/pom.xml +++ b/forms/login-api/pom.xml @@ -18,19 +18,23 @@ org.keycloak keycloak-core ${project.version} + provided org.keycloak keycloak-model-api ${project.version} + provided org.jboss.resteasy jaxrs-api + provided org.jboss.resteasy resteasy-jaxrs + provided diff --git a/forms/login-freemarker/pom.xml b/forms/login-freemarker/pom.xml index d1cc8294f7..c9e85bfa6e 100755 --- a/forms/login-freemarker/pom.xml +++ b/forms/login-freemarker/pom.xml @@ -18,31 +18,37 @@ org.keycloak keycloak-core ${project.version} + provided org.keycloak keycloak-forms-common-freemarker ${project.version} + provided org.keycloak keycloak-login-api ${project.version} + provided org.keycloak keycloak-model-api ${project.version} + provided org.keycloak keycloak-services ${project.version} + provided org.keycloak keycloak-social-core ${project.version} + provided org.jboss.resteasy @@ -52,11 +58,13 @@ org.freemarker freemarker + provided org.jboss jboss-vfs 3.2.2.Final + provided diff --git a/integration/jaxrs-oauth-client/src/main/java/org/keycloak/jaxrs/JaxrsOAuthClient.java b/integration/jaxrs-oauth-client/src/main/java/org/keycloak/jaxrs/JaxrsOAuthClient.java index 4207a027b8..2a825571c6 100755 --- a/integration/jaxrs-oauth-client/src/main/java/org/keycloak/jaxrs/JaxrsOAuthClient.java +++ b/integration/jaxrs-oauth-client/src/main/java/org/keycloak/jaxrs/JaxrsOAuthClient.java @@ -1,12 +1,9 @@ package org.keycloak.jaxrs; -import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; import org.jboss.resteasy.logging.Logger; -import org.jboss.resteasy.util.BasicAuthHelper; import org.keycloak.AbstractOAuthClient; import org.keycloak.OAuth2Constants; import org.keycloak.representations.AccessTokenResponse; -import org.keycloak.representations.idm.CredentialRepresentation; import javax.ws.rs.BadRequestException; import javax.ws.rs.InternalServerErrorException; @@ -20,7 +17,6 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.UriBuilder; import javax.ws.rs.core.UriInfo; import java.net.URI; -import java.net.URL; import java.util.Map; /** diff --git a/model/api/pom.xml b/model/api/pom.xml index fbcfd5336e..ae6b5a3dcb 100755 --- a/model/api/pom.xml +++ b/model/api/pom.xml @@ -17,6 +17,7 @@ net.iharder base64 + provided org.bouncycastle diff --git a/model/jpa/pom.xml b/model/jpa/pom.xml index 0fec0afa0b..3e4340a452 100755 --- a/model/jpa/pom.xml +++ b/model/jpa/pom.xml @@ -19,12 +19,35 @@ bcprov-jdk16 provided + + net.iharder + base64 + provided + org.keycloak keycloak-core ${project.version} provided + + org.keycloak + keycloak-audit-api + ${project.version} + provided + + + org.keycloak + keycloak-audit-jpa + ${project.version} + provided + + + org.keycloak + keycloak-audit-jboss-logging + ${project.version} + provided + org.keycloak keycloak-model-api diff --git a/model/mongo/pom.xml b/model/mongo/pom.xml index 6b07eea88c..6f8110d426 100755 --- a/model/mongo/pom.xml +++ b/model/mongo/pom.xml @@ -15,11 +15,23 @@ + + commons-io + commons-io + 2.4 + provided + + org.bouncycastle bcprov-jdk16 provided + + net.iharder + base64 + provided + org.keycloak keycloak-core @@ -30,6 +42,19 @@ org.keycloak keycloak-model-api ${project.version} + provided + + + org.keycloak + keycloak-audit-api + ${project.version} + provided + + + org.keycloak + keycloak-audit-jboss-logging + ${project.version} + provided org.jboss.logging @@ -46,13 +71,6 @@ mongo-java-driver provided - - org.apache.httpcomponents - httpclient - ${keycloak.apache.httpcomponents.version} - provided - - org.keycloak @@ -60,6 +78,26 @@ ${project.version} test + + org.jboss.resteasy + resteasy-jaxrs + test + + + log4j + log4j + + + org.slf4j + slf4j-api + + + org.slf4j + slf4j-simple + + + + org.keycloak keycloak-model-tests diff --git a/model/picketlink/pom.xml b/model/picketlink/pom.xml index d2250f8913..98deeb4449 100755 --- a/model/picketlink/pom.xml +++ b/model/picketlink/pom.xml @@ -38,22 +38,27 @@ org.picketlink picketlink-idm-api + provided org.picketlink picketlink-common + provided org.picketlink picketlink-idm-impl + provided org.picketlink picketlink-idm-simple-schema + provided org.picketlink picketlink-config + provided org.hibernate.javax.persistence diff --git a/model/tests/pom.xml b/model/tests/pom.xml index 99f567e430..87817fed9a 100755 --- a/model/tests/pom.xml +++ b/model/tests/pom.xml @@ -15,12 +15,24 @@ + + org.keycloak + keycloak-core + ${project.version} + compile + org.keycloak keycloak-services ${project.version} compile + + org.keycloak + keycloak-model-api + ${project.version} + compile + org.keycloak keycloak-authentication-api @@ -68,6 +80,30 @@ junit compile + + org.jboss.resteasy + resteasy-jaxrs + provided + + + log4j + log4j + + + org.slf4j + slf4j-api + + + org.slf4j + slf4j-simple + + + + + org.jboss.resteasy + jaxrs-api + provided + org.codehaus.jackson jackson-core-asl diff --git a/model/tests/src/test/java/org/keycloak/model/test/AbstractModelTest.java b/model/tests/src/test/java/org/keycloak/model/test/AbstractModelTest.java old mode 100644 new mode 100755 index cdd802484d..c83863f6f9 --- a/model/tests/src/test/java/org/keycloak/model/test/AbstractModelTest.java +++ b/model/tests/src/test/java/org/keycloak/model/test/AbstractModelTest.java @@ -5,7 +5,6 @@ import java.io.IOException; import java.io.InputStream; import java.util.Set; -import org.jboss.resteasy.logging.Logger; import org.junit.After; import org.junit.Assert; import org.junit.Before; diff --git a/server/pom.xml b/server/pom.xml index da9cbbfe55..a4313c2ad3 100755 --- a/server/pom.xml +++ b/server/pom.xml @@ -15,18 +15,14 @@ - org.bouncycastle - bcprov-jdk16 + org.keycloak + keycloak-core + ${project.version} net.iharder base64 - - org.keycloak - keycloak-core - ${project.version} - org.keycloak keycloak-core-jaxrs @@ -37,6 +33,10 @@ keycloak-services ${project.version} + + com.google.zxing + javase + org.keycloak keycloak-model-api @@ -62,11 +62,16 @@ keycloak-audit-jboss-logging ${project.version} + org.keycloak keycloak-social-core ${project.version} + + org.json + json + org.keycloak keycloak-social-github @@ -82,16 +87,25 @@ keycloak-social-twitter ${project.version} + + org.twitter4j + twitter4j-core + org.keycloak keycloak-social-facebook ${project.version} + org.keycloak keycloak-forms-common-freemarker ${project.version} + + org.freemarker + freemarker + org.keycloak keycloak-forms-common-themes @@ -127,6 +141,7 @@ keycloak-js-adapter ${project.version} + org.keycloak keycloak-authentication-api @@ -142,84 +157,10 @@ keycloak-authentication-picketlink ${project.version} - - org.keycloak - keycloak-timer-api - ${project.version} - - - org.keycloak - keycloak-timer-basic - ${project.version} - - - org.keycloak - keycloak-picketlink-api - ${project.version} - - - org.keycloak - keycloak-picketlink-realm - ${project.version} - - - junit - junit - 4.1 - test - - - org.jboss.spec.javax.servlet - jboss-servlet-api_3.0_spec - provided - - - - org.jboss.resteasy - resteasy-jaxrs - ${resteasy.version} - - - org.jboss.resteasy - resteasy-multipart-provider - ${resteasy.version} - - - org.jboss.resteasy - async-http-servlet-3.0 - ${resteasy.version} - - - org.jboss.resteasy - jaxrs-api - ${resteasy.version} - - - org.jboss.resteasy - resteasy-jackson-provider - ${resteasy.version} - - - - - org.keycloak - keycloak-model-mongo - ${project.version} - - - org.keycloak - keycloak-audit-mongo - ${project.version} - - - org.mongodb - mongo-java-driver - org.picketlink picketlink-common - org.picketlink picketlink-idm-api @@ -233,6 +174,67 @@ picketlink-idm-simple-schema + + + org.keycloak + keycloak-timer-api + ${project.version} + + + org.keycloak + keycloak-timer-basic + ${project.version} + + + + + org.keycloak + keycloak-picketlink-api + ${project.version} + + + org.keycloak + keycloak-picketlink-realm + ${project.version} + + + org.jboss.spec.javax.servlet + jboss-servlet-api_3.0_spec + provided + + + + org.jboss.resteasy + resteasy-jaxrs + ${resteasy.version} + provided + + + org.jboss.resteasy + resteasy-multipart-provider + ${resteasy.version} + provided + + + org.jboss.resteasy + async-http-servlet-3.0 + ${resteasy.version} + provided + + + org.jboss.resteasy + jaxrs-api + ${resteasy.version} + provided + + + org.jboss.resteasy + resteasy-jackson-provider + ${resteasy.version} + provided + + + diff --git a/server/src/main/webapp/WEB-INF/jboss-deployment-structure.xml b/server/src/main/webapp/WEB-INF/jboss-deployment-structure.xml index f37138daeb..3caa9f922a 100755 --- a/server/src/main/webapp/WEB-INF/jboss-deployment-structure.xml +++ b/server/src/main/webapp/WEB-INF/jboss-deployment-structure.xml @@ -1,5 +1,8 @@ + + + @@ -8,11 +11,9 @@ - + - @@ -27,6 +28,7 @@ + -> \ No newline at end of file diff --git a/services/pom.xml b/services/pom.xml index a0cad7b0ff..bec5d06d9e 100755 --- a/services/pom.xml +++ b/services/pom.xml @@ -47,21 +47,19 @@ org.keycloak keycloak-account-api ${project.version} + provided org.keycloak keycloak-login-api ${project.version} + provided org.keycloak keycloak-model-api ${project.version} - - - org.keycloak - keycloak-jaxrs-oauth-client - ${project.version} + provided org.keycloak @@ -155,6 +153,7 @@ com.google.zxing javase + provided junit diff --git a/services/src/main/java/org/keycloak/services/resources/AccountService.java b/services/src/main/java/org/keycloak/services/resources/AccountService.java index 5bf2a38bd5..4d44d8587d 100755 --- a/services/src/main/java/org/keycloak/services/resources/AccountService.java +++ b/services/src/main/java/org/keycloak/services/resources/AccountService.java @@ -33,7 +33,6 @@ import org.keycloak.audit.AuditProvider; import org.keycloak.audit.Details; import org.keycloak.audit.Event; import org.keycloak.audit.Events; -import org.keycloak.jaxrs.JaxrsOAuthClient; import org.keycloak.models.AccountRoles; import org.keycloak.models.ApplicationModel; import org.keycloak.models.AuthenticationLinkModel; @@ -55,6 +54,7 @@ import org.keycloak.services.managers.SocialRequestManager; import org.keycloak.services.managers.TokenManager; import org.keycloak.services.messages.Messages; import org.keycloak.services.resources.flows.Flows; +import org.keycloak.services.resources.flows.OAuthRedirect; import org.keycloak.services.resources.flows.Urls; import org.keycloak.services.validation.Validation; import org.keycloak.social.SocialLoader; @@ -473,7 +473,7 @@ public class AccountService { } private Response login(String path) { - JaxrsOAuthClient oauth = new JaxrsOAuthClient(); + OAuthRedirect oauth = new OAuthRedirect(); String authUrl = Urls.realmLoginPage(uriInfo.getBaseUri(), realm.getName()).toString(); oauth.setAuthUrl(authUrl); diff --git a/services/src/main/java/org/keycloak/services/resources/admin/AdminService.java b/services/src/main/java/org/keycloak/services/resources/admin/AdminService.java index bc8e4d494d..54c4da09d2 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/AdminService.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/AdminService.java @@ -9,7 +9,6 @@ import org.jboss.resteasy.spi.NotFoundException; import org.jboss.resteasy.spi.ResteasyProviderFactory; import org.jboss.resteasy.spi.UnauthorizedException; import org.keycloak.OAuth2Constants; -import org.keycloak.jaxrs.JaxrsOAuthClient; import org.keycloak.models.AdminRoles; import org.keycloak.models.ApplicationModel; import org.keycloak.models.Config; @@ -25,6 +24,7 @@ import org.keycloak.services.managers.RealmManager; import org.keycloak.services.managers.TokenManager; import org.keycloak.services.resources.TokenService; import org.keycloak.services.resources.flows.Flows; +import org.keycloak.services.resources.flows.OAuthRedirect; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -301,7 +301,7 @@ public class AdminService { logger.debug("loginPage ********************** <---"); expireCookie(); - JaxrsOAuthClient oauth = new JaxrsOAuthClient(); + OAuthRedirect oauth = new OAuthRedirect(); String authUrl = TokenService.loginPageUrl(uriInfo).build(Config.getAdminRealm()).toString(); logger.debug("authUrl: {0}", authUrl); oauth.setAuthUrl(authUrl); @@ -368,7 +368,7 @@ public class AdminService { logger.debug("state not specified"); return redirectOnLoginError("invalid login data"); } - new JaxrsOAuthClient().checkStateCookie(uriInfo, headers); + new OAuthRedirect().checkStateCookie(uriInfo, headers); logger.debug("loginRedirect SUCCESS"); NewCookie cookie = authManager.createCookie(adminRealm, adminConsole, code, AdminService.saasCookiePath(uriInfo).build()); diff --git a/services/src/main/java/org/keycloak/services/resources/flows/OAuthRedirect.java b/services/src/main/java/org/keycloak/services/resources/flows/OAuthRedirect.java new file mode 100755 index 0000000000..cda6a7c19c --- /dev/null +++ b/services/src/main/java/org/keycloak/services/resources/flows/OAuthRedirect.java @@ -0,0 +1,77 @@ +package org.keycloak.services.resources.flows; + +import org.jboss.resteasy.logging.Logger; +import org.jboss.resteasy.spi.BadRequestException; +import org.keycloak.AbstractOAuthClient; +import org.keycloak.OAuth2Constants; +import org.keycloak.representations.AccessTokenResponse; + +import javax.ws.rs.core.Cookie; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.NewCookie; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriBuilder; +import javax.ws.rs.core.UriInfo; +import java.net.URI; +import java.util.Map; + +/** + * Helper code to obtain oauth access tokens via browser redirects + * + * @author Bill Burke + * @version $Revision: 1 $ + */ +public class OAuthRedirect extends AbstractOAuthClient { + protected static final Logger logger = Logger.getLogger(OAuthRedirect.class); + + /** + * closes client + */ + public void stop() { + } + + public Response redirect(UriInfo uriInfo, String redirectUri) { + String state = getStateCode(); + + UriBuilder uriBuilder = UriBuilder.fromUri(authUrl) + .queryParam(OAuth2Constants.CLIENT_ID, clientId) + .queryParam(OAuth2Constants.REDIRECT_URI, redirectUri) + .queryParam(OAuth2Constants.STATE, state); + if (scope != null) { + uriBuilder.queryParam(OAuth2Constants.SCOPE, scope); + } + + URI url = uriBuilder.build(); + + // todo httpOnly! + NewCookie cookie = new NewCookie(getStateCookieName(), state, getStateCookiePath(uriInfo), null, null, -1, isSecure); + logger.debug("NewCookie: " + cookie.toString()); + logger.debug("Oauth Redirect to: " + url); + return Response.status(302) + .location(url) + .cookie(cookie).build(); + } + + public String getStateCookiePath(UriInfo uriInfo) { + if (stateCookiePath != null) return stateCookiePath; + return uriInfo.getBaseUri().getRawPath(); + } + + public String getError(UriInfo uriInfo) { + return uriInfo.getQueryParameters().getFirst(OAuth2Constants.ERROR); + } + + public String getAccessCode(UriInfo uriInfo) { + return uriInfo.getQueryParameters().getFirst(OAuth2Constants.CODE); + } + + public void checkStateCookie(UriInfo uriInfo, HttpHeaders headers) { + Cookie stateCookie = headers.getCookies().get(stateCookieName); + if (stateCookie == null) throw new BadRequestException("state cookie not set"); + String state = uriInfo.getQueryParameters().getFirst(OAuth2Constants.STATE); + if (state == null) throw new BadRequestException("state parameter was null"); + if (!state.equals(stateCookie.getValue())) { + throw new BadRequestException("state parameter invalid"); + } + } +} diff --git a/social/core/pom.xml b/social/core/pom.xml index 09a459263e..457854326a 100755 --- a/social/core/pom.xml +++ b/social/core/pom.xml @@ -18,10 +18,12 @@ org.keycloak keycloak-core ${project.version} + provided org.json json + provided junit diff --git a/social/facebook/pom.xml b/social/facebook/pom.xml index 775909be53..be3679c958 100755 --- a/social/facebook/pom.xml +++ b/social/facebook/pom.xml @@ -14,10 +14,16 @@ + + org.json + json + provided + org.keycloak keycloak-social-core ${project.version} + provided diff --git a/social/github/pom.xml b/social/github/pom.xml index c34de7bf5b..e8dc767d31 100755 --- a/social/github/pom.xml +++ b/social/github/pom.xml @@ -14,10 +14,16 @@ + + org.json + json + provided + org.keycloak keycloak-social-core ${project.version} + provided diff --git a/social/google/pom.xml b/social/google/pom.xml index 925965b5f7..c575a86985 100755 --- a/social/google/pom.xml +++ b/social/google/pom.xml @@ -14,10 +14,16 @@ + + org.json + json + provided + org.keycloak keycloak-social-core ${project.version} + provided diff --git a/social/twitter/pom.xml b/social/twitter/pom.xml index eb907c6b87..0511193976 100755 --- a/social/twitter/pom.xml +++ b/social/twitter/pom.xml @@ -21,9 +21,15 @@ provided + + org.json + json + provided + org.twitter4j twitter4j-core + provided diff --git a/testsuite/integration/pom.xml b/testsuite/integration/pom.xml index 72b8768bdc..86d40dcaf4 100755 --- a/testsuite/integration/pom.xml +++ b/testsuite/integration/pom.xml @@ -77,6 +77,11 @@ resteasy-undertow ${resteasy.version.latest} + + com.google.zxing + javase + provided + org.bouncycastle bcprov-jdk16 @@ -184,6 +189,11 @@ keycloak-forms-common-freemarker ${project.version} + + org.freemarker + freemarker + provided + org.keycloak keycloak-forms-common-themes diff --git a/testsuite/performance/pom.xml b/testsuite/performance/pom.xml index 0b14c76ab3..e4bd352c3d 100755 --- a/testsuite/performance/pom.xml +++ b/testsuite/performance/pom.xml @@ -30,6 +30,11 @@ keycloak-services ${project.version} + + org.keycloak + keycloak-model-api + ${project.version} + org.jboss.resteasy resteasy-jaxrs diff --git a/timer/api/pom.xml b/timer/api/pom.xml index 030f08905c..7d9cb9c433 100755 --- a/timer/api/pom.xml +++ b/timer/api/pom.xml @@ -16,6 +16,7 @@ org.keycloak keycloak-core ${project.version} + provided diff --git a/timer/basic/pom.xml b/timer/basic/pom.xml index 8d5c5bff9a..57e56f30db 100755 --- a/timer/basic/pom.xml +++ b/timer/basic/pom.xml @@ -13,10 +13,17 @@ + + org.keycloak + keycloak-core + ${project.version} + provided + org.keycloak keycloak-timer-api ${project.version} + provided