keycloak-aplcache

Merge pull request #1058 from mposolda/master Fix google

3/18/2015 8:01:41 AM

Details

diff --git a/distribution/modules/src/main/resources/modules/org/keycloak/keycloak-social-twitter/main/module.xml b/distribution/modules/src/main/resources/modules/org/keycloak/keycloak-social-twitter/main/module.xml
index 3f67efe..beef9a7 100755
--- a/distribution/modules/src/main/resources/modules/org/keycloak/keycloak-social-twitter/main/module.xml
+++ b/distribution/modules/src/main/resources/modules/org/keycloak/keycloak-social-twitter/main/module.xml
@@ -15,6 +15,7 @@
         <module name="org.twitter4j"/>
         <module name="org.jboss.logging"/>
         <module name="javax.api"/>
+        <module name="javax.ws.rs.api"/>
         <module name="org.codehaus.jackson.jackson-core-asl"/>
         <module name="org.codehaus.jackson.jackson-mapper-asl"/>
         <module name="org.codehaus.jackson.jackson-xc"/>
diff --git a/examples/broker/facebook-authentication/README.md b/examples/broker/facebook-authentication/README.md
index ed9b7fe..3fe44c4 100644
--- a/examples/broker/facebook-authentication/README.md
+++ b/examples/broker/facebook-authentication/README.md
@@ -34,6 +34,7 @@ documentation.
 Please take a look on [Facebook Developer Console](https://developers.facebook.com/apps/) for more details. Make sure to use the correct
 redirect URI to be used as URL on Facebook. The facebook will redirect to this URI after finish authentication. For this example, it's the URL
 [http://localhost:8080/auth/realms/facebook-identity-provider-realm/broker/facebook](http://localhost:8080/auth/realms/facebook-identity-provider-realm/broker/facebook) .
+You can also determine this redirect URI from Keycloak admin console (It's in Identity provider settings for Facebook provider).
 
 Once you have a Facebook Application configured, you need to obtain both **App ID** and **App Secret** and update the
 **facebook-identity-provider-realm.json** configuration file with these information. There you'll find a section as follows:
@@ -127,7 +128,7 @@ create a new admin password before you can go to the create realm page.
 
 [http://localhost:8080/auth/admin/master/console/#/create/realm](http://localhost:8080/auth/admin/master/console/#/create/realm)
 
-Import the **facebook-identity-provider-realm.json** file that is in the saml/ example directory.
+Import the **facebook-identity-provider-realm.json** file that is in the facebook-authentication/ example directory.
 
 
 Start JBoss Enterprise Application Platform 6 or WildFly with the Web Profile
diff --git a/examples/broker/google-authentication/google-identity-provider-realm.json b/examples/broker/google-authentication/google-identity-provider-realm.json
index 22df7e4..f808658 100644
--- a/examples/broker/google-authentication/google-identity-provider-realm.json
+++ b/examples/broker/google-authentication/google-identity-provider-realm.json
@@ -42,6 +42,12 @@
             ],
             "webOrigins": [
               "http://localhost:8080"
+            ],
+            "identityProviders": [
+                {
+                    "id": "google",
+                    "retrieveToken": true
+                }
             ]
         }
     ],
diff --git a/examples/broker/google-authentication/README.md b/examples/broker/google-authentication/README.md
index a03cd4e..5d60d11 100644
--- a/examples/broker/google-authentication/README.md
+++ b/examples/broker/google-authentication/README.md
@@ -31,9 +31,9 @@ Make sure you've set up a application in Google
 This example application requires you to create a Google Application. How to create it is beyond the scope of this
 documentation.
 
-Please take a look on [Google Developer Console](https://developers.google.com/apps/) for more details.
+Please take a look on [Google Developer Console](https://cloud.google.com/console/project) for more details.
 
-Once you have a Google Application configured, you need to obtain both **App ID** and **App Secret** and update the
+Once you have a Google Application configured, you need to obtain both **Client ID** and **Client Secret** and update the
 **google-identity-provider-realm.json** configuration file with these information. There you'll find a section as follows:
 
         "identityProviders": [
@@ -51,7 +51,11 @@ Once you have a Google Application configured, you need to obtain both **App ID*
                 }
             ]
 
-Please, update both *clientId* and *clientSecret* configuration options with the **App ID** and **App Secret**.
+Please, update both *clientId* and *clientSecret* configuration options with the **Client ID** and **Client Secret**.
+
+Make sure to use the correct redirect URI to be used as URL on Google. The Google will redirect to this URI after finish authentication. For this example, it's the URL
+[http://localhost:8080/auth/realms/google-identity-provider-realm/broker/google](http://localhost:8080/auth/realms/google-identity-provider-realm/broker/google) .
+You can also determine the redirect URI from Keycloak admin console (It's in Identity provider settings for Google provider).
 
 Make sure you've set up the Keycloak Server
 --------------------------------------
@@ -125,7 +129,7 @@ create a new admin password before you can go to the create realm page.
 
 [http://localhost:8080/auth/admin/master/console/#/create/realm](http://localhost:8080/auth/admin/master/console/#/create/realm)
 
-Import the **google-identity-provider-realm.json** file that is in the saml/ example directory.
+Import the **google-identity-provider-realm.json** file that is in the google-authentication/ example directory.
 
 
 Start JBoss Enterprise Application Platform 6 or WildFly with the Web Profile
diff --git a/examples/broker/google-authentication/src/main/webapp/js/app.js b/examples/broker/google-authentication/src/main/webapp/js/app.js
index a7e363c..aa508cc 100755
--- a/examples/broker/google-authentication/src/main/webapp/js/app.js
+++ b/examples/broker/google-authentication/src/main/webapp/js/app.js
@@ -83,7 +83,7 @@ module.controller('GlobalCtrl', function($scope, $http, $location, Auth) {
     $scope.identity = Auth.getIdentity();
 
     $scope.loadSocialProfile = function() {
-        $http.get('http://localhost:8081/auth/realms/google-identity-provider-realm/broker/google/token').success(function(data) {
+        $http.get('/auth/realms/google-identity-provider-realm/broker/google/token').success(function(data) {
             var accessToken = data.access_token;
 
             var req = {
diff --git a/examples/broker/twitter-authentication/README.md b/examples/broker/twitter-authentication/README.md
index 0971cb8..0a0ebc6 100644
--- a/examples/broker/twitter-authentication/README.md
+++ b/examples/broker/twitter-authentication/README.md
@@ -31,9 +31,9 @@ Make sure you've set up a application in Twitter
 This example application requires you to create a Twitter Application. How to create it is beyond the scope of this
 documentation.
 
-Please take a look on [Twitter Developer Console](https://developers.twitter.com/apps/) for more details.
+Please take a look on [Twitter Developer Console](https://dev.twitter.com/apps) for more details.
 
-Once you have a Twitter Application configured, you need to obtain both **App ID** and **App Secret** and update the
+Once you have a Twitter Application configured, you need to obtain both **Consumer Key** and **Consumer Secret** and update the
 **twitter-identity-provider-realm.json** configuration file with these information. There you'll find a section as follows:
 
         "identityProviders": [
@@ -51,7 +51,7 @@ Once you have a Twitter Application configured, you need to obtain both **App ID
                 }
             ]
 
-Please, update both *clientId* and *clientSecret* configuration options with the **App ID** and **App Secret**.
+Please, update both *clientId* and *clientSecret* configuration options with the **Consumer Key** and **Consumer Secret**.
 
 Make sure you've set up the Keycloak Server
 --------------------------------------
@@ -125,7 +125,7 @@ create a new admin password before you can go to the create realm page.
 
 [http://localhost:8080/auth/admin/master/console/#/create/realm](http://localhost:8080/auth/admin/master/console/#/create/realm)
 
-Import the **twitter-identity-provider-realm.json** file that is in the saml/ example directory.
+Import the **twitter-identity-provider-realm.json** file that is in the twitter-authentication/ example directory.
 
 
 Start JBoss Enterprise Application Platform 6 or WildFly with the Web Profile
@@ -156,7 +156,10 @@ _NOTE: The following build command assumes you have configured your Maven user s
 Access the application
 ---------------------
 
-The application will be running at the following URL: <http://localhost:8080/twitter-authentication>.
+The application will be running at the following URL: <http://localhost:8080/twitter-authentication/index.html>. This is angular based application.
+In addition, the example contains testing servlet, which will show you JSON with full info about your Twitter account. Servlet is accessible 
+on [http://localhost:8080/twitter-authentication/twitter/showUser](http://localhost:8080/twitter-authentication/twitter/showUser) . 
+
 
 
 Undeploy the Archive
diff --git a/examples/broker/twitter-authentication/src/main/java/org/keycloak/examples/broker/twitter/TwitterShowUserServlet.java b/examples/broker/twitter-authentication/src/main/java/org/keycloak/examples/broker/twitter/TwitterShowUserServlet.java
index 7fdcb4e..e00ec56 100644
--- a/examples/broker/twitter-authentication/src/main/java/org/keycloak/examples/broker/twitter/TwitterShowUserServlet.java
+++ b/examples/broker/twitter-authentication/src/main/java/org/keycloak/examples/broker/twitter/TwitterShowUserServlet.java
@@ -68,6 +68,11 @@ public class TwitterShowUserServlet extends HttpServlet {
     }
 
     @Override
+    public void destroy() {
+        this.keycloak.close();
+    }
+
+    @Override
     protected void doGet(final HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
         TwitterOAuthResponse twitterOAuthResponse = getTwitterOAuthResponse(request);
         ConfigurationBuilder cb = new ConfigurationBuilder();
@@ -132,6 +137,5 @@ public class TwitterShowUserServlet extends HttpServlet {
         this.keycloak = Keycloak.getInstance(authServer, realmName, "admin", "password", "admin-client", "password");
         IdentityProvidersResource providersResource = keycloak.realm(realmName).identityProviders();
         this.identityProvider = providersResource.get("twitter").toRepresentation();
-        this.keycloak = Keycloak.getInstance(authServer, realmName, "admin", "password", "admin-client", "password");
     }
 }
diff --git a/examples/broker/twitter-authentication/src/main/webapp/js/app.js b/examples/broker/twitter-authentication/src/main/webapp/js/app.js
index ceba93d..16683a2 100755
--- a/examples/broker/twitter-authentication/src/main/webapp/js/app.js
+++ b/examples/broker/twitter-authentication/src/main/webapp/js/app.js
@@ -87,7 +87,7 @@ module.controller('GlobalCtrl', function($scope, $http, $location, Auth) {
     $scope.identity = Auth.getIdentity();
 
     $scope.loadSocialProfile = function() {
-        $http.get('http://localhost:8080/twitter-authentication/twitter/showUser')
+        $http.get('/twitter-authentication/twitter/showUser')
             .success(function(profile) {
                 $scope.socialProfile = profile;
             })
diff --git a/examples/broker/twitter-authentication/src/main/webapp/WEB-INF/keycloak.json b/examples/broker/twitter-authentication/src/main/webapp/WEB-INF/keycloak.json
index 7243636..f5401a7 100644
--- a/examples/broker/twitter-authentication/src/main/webapp/WEB-INF/keycloak.json
+++ b/examples/broker/twitter-authentication/src/main/webapp/WEB-INF/keycloak.json
@@ -2,7 +2,7 @@
   "realm" : "twitter-identity-provider-realm",
   "resource" : "twitter-authentication",
   "realm-public-key" : "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB",
-  "auth-server-url": "/auth",
+  "auth-server-url": "http://localhost:8080/auth",
   "ssl-required" : "external",
   "public-client" : true
 }
diff --git a/examples/broker/twitter-authentication/twitter-identity-provider-realm.json b/examples/broker/twitter-authentication/twitter-identity-provider-realm.json
index 90aef3f..27850eb 100644
--- a/examples/broker/twitter-authentication/twitter-identity-provider-realm.json
+++ b/examples/broker/twitter-authentication/twitter-identity-provider-realm.json
@@ -43,6 +43,12 @@
             ],
             "webOrigins": [
               "http://localhost:8080"
+            ],
+            "identityProviders": [
+                {
+                    "id": "twitter",
+                    "retrieveToken": true
+                }
             ]
         },
         {