You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2016/06/13 09:49:43 UTC

[1/2] syncope git commit: [SYNCOPE-829] Moving result size protection onto external layers

Repository: syncope
Updated Branches:
  refs/heads/master 6401a9039 -> 339f9d5d3


[SYNCOPE-829] Moving result size protection onto external layers


Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/9d15e6f1
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/9d15e6f1
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/9d15e6f1

Branch: refs/heads/master
Commit: 9d15e6f19bd0db7375a024a4d313fe3f84dac70a
Parents: 6401a90
Author: Francesco Chicchiricc� <il...@apache.org>
Authored: Mon Jun 13 11:33:25 2016 +0200
Committer: Francesco Chicchiricc� <il...@apache.org>
Committed: Mon Jun 13 11:33:25 2016 +0200

----------------------------------------------------------------------
 .../common/rest/api/beans/ConnObjectTOListQuery.java      | 10 +++++++++-
 .../java/org/apache/syncope/core/logic/ResourceLogic.java |  8 +++-----
 2 files changed, 12 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/9d15e6f1/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/ConnObjectTOListQuery.java
----------------------------------------------------------------------
diff --git a/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/ConnObjectTOListQuery.java b/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/ConnObjectTOListQuery.java
index 53df9fb..16d0e66 100644
--- a/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/ConnObjectTOListQuery.java
+++ b/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/ConnObjectTOListQuery.java
@@ -19,6 +19,7 @@
 package org.apache.syncope.common.rest.api.beans;
 
 import java.io.Serializable;
+import javax.validation.constraints.Max;
 import javax.validation.constraints.Min;
 import javax.ws.rs.DefaultValue;
 import javax.ws.rs.QueryParam;
@@ -32,6 +33,8 @@ public class ConnObjectTOListQuery implements Serializable {
 
     private static final long serialVersionUID = -371488230250055359L;
 
+    private static final int MAX_SIZE = 100;
+
     public static class Builder {
 
         private final ConnObjectTOListQuery instance = new ConnObjectTOListQuery();
@@ -64,10 +67,15 @@ public class ConnObjectTOListQuery implements Serializable {
     private String orderBy;
 
     public Integer getSize() {
-        return size;
+        return size == null
+                ? 25
+                : size > MAX_SIZE
+                        ? MAX_SIZE
+                        : size;
     }
 
     @Min(1)
+    @Max(MAX_SIZE)
     @QueryParam(JAXRSService.PARAM_SIZE)
     @DefaultValue("25")
     public void setSize(final Integer size) {

http://git-wip-us.apache.org/repos/asf/syncope/blob/9d15e6f1/core/logic/src/main/java/org/apache/syncope/core/logic/ResourceLogic.java
----------------------------------------------------------------------
diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/ResourceLogic.java b/core/logic/src/main/java/org/apache/syncope/core/logic/ResourceLogic.java
index 34d9544..915d8ff 100644
--- a/core/logic/src/main/java/org/apache/syncope/core/logic/ResourceLogic.java
+++ b/core/logic/src/main/java/org/apache/syncope/core/logic/ResourceLogic.java
@@ -77,8 +77,6 @@ import org.springframework.transaction.annotation.Transactional;
 @Component
 public class ResourceLogic extends AbstractTransactionalLogic<ResourceTO> {
 
-    private static final transient int MAX_CONNOBJ_SEARCH_SIZE = 1000;
-
     @Autowired
     private ExternalResourceDAO resourceDAO;
 
@@ -320,7 +318,7 @@ public class ResourceLogic extends AbstractTransactionalLogic<ResourceTO> {
     @PreAuthorize("hasRole('" + StandardEntitlement.RESOURCE_LIST_CONNOBJECT + "')")
     @Transactional(readOnly = true)
     public Pair<SearchResult, List<ConnObjectTO>> listConnObjects(final String key, final String anyTypeKey,
-            final Integer size, final String pagedResultsCookie, final List<OrderByClause> orderBy) {
+            final int size, final String pagedResultsCookie, final List<OrderByClause> orderBy) {
 
         Triple<ExternalResource, AnyType, Provision> init = connObjectInit(key, anyTypeKey);
 
@@ -349,9 +347,9 @@ public class ResourceLogic extends AbstractTransactionalLogic<ResourceTO> {
             @Override
             public boolean handle(final ConnectorObject connectorObject) {
                 connObjects.add(connObjectUtils.getConnObjectTO(connectorObject));
-                // provide safety approach in case of pagination not supported or not required (SYNCOPE-829 reworking)
+                // safety protection against uncontrolled result size
                 count++;
-                return count < MAX_CONNOBJ_SEARCH_SIZE;
+                return count < size;
             }
         }, size, pagedResultsCookie, orderBy, mapItems);
 


[2/2] syncope git commit: More fixes to enduser

Posted by il...@apache.org.
More fixes to enduser


Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/339f9d5d
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/339f9d5d
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/339f9d5d

Branch: refs/heads/master
Commit: 339f9d5d3f996d38c08df57c5ec28135f75dda9f
Parents: 9d15e6f
Author: Francesco Chicchiricc� <il...@apache.org>
Authored: Mon Jun 13 11:49:35 2016 +0200
Committer: Francesco Chicchiricc� <il...@apache.org>
Committed: Mon Jun 13 11:49:35 2016 +0200

----------------------------------------------------------------------
 .../main/resources/META-INF/resources/app/index.html   |  1 -
 .../main/resources/META-INF/resources/app/js/app.js    | 11 +++++------
 .../resources/app/js/controllers/UserController.js     | 13 +++++--------
 .../META-INF/resources/app/js/directives/captcha.js    | 12 +++++++-----
 4 files changed, 17 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/339f9d5d/client/enduser/src/main/resources/META-INF/resources/app/index.html
----------------------------------------------------------------------
diff --git a/client/enduser/src/main/resources/META-INF/resources/app/index.html b/client/enduser/src/main/resources/META-INF/resources/app/index.html
index d191570..ebba78a 100644
--- a/client/enduser/src/main/resources/META-INF/resources/app/index.html
+++ b/client/enduser/src/main/resources/META-INF/resources/app/index.html
@@ -89,7 +89,6 @@ under the License.
     <script src="js/services/resourceService.js"></script>
     <script src="js/services/groupService.js"></script>
     <script src="js/services/anyService.js"></script>
-    <script src="js/services/captchaService.js"></script>
     <!--controllers-->
     <script src="js/controllers/HomeController.js"></script>
     <script src="js/controllers/LoginController.js"></script>

http://git-wip-us.apache.org/repos/asf/syncope/blob/339f9d5d/client/enduser/src/main/resources/META-INF/resources/app/js/app.js
----------------------------------------------------------------------
diff --git a/client/enduser/src/main/resources/META-INF/resources/app/js/app.js b/client/enduser/src/main/resources/META-INF/resources/app/js/app.js
index 780d738..3f356c9 100644
--- a/client/enduser/src/main/resources/META-INF/resources/app/js/app.js
+++ b/client/enduser/src/main/resources/META-INF/resources/app/js/app.js
@@ -211,11 +211,10 @@ app.config(['$stateProvider', '$urlRouterProvider', '$httpProvider',
     $httpProvider.defaults.headers.common["If-Modified-Since"] = "0";
 
     $httpProvider.interceptors.push(function ($q, $rootScope, $location) {
-      var numLoadings = 0;
       return {
         'request': function (config, a, b) {
           //if the url is an html, we're changing page
-          if (config.url.indexOf('.html', config.url.length - 5) == -1) {
+          if (config.url.indexOf('.html', config.url.length - 5) === -1) {
             $rootScope.$broadcast("xhrStarted");
             var separator = config.url.indexOf('?') === -1 ? '?' : '&';
             config.url = config.url + separator + 'noCache=' + new Date().getTime();
@@ -231,15 +230,15 @@ app.config(['$stateProvider', '$urlRouterProvider', '$httpProvider',
         },
         'responseError': function (response) {
           $rootScope.spinner.off();
-          if (response.config.url.indexOf("acceptError=true") == -1) {
+          if (response.config.url.indexOf("acceptError=true") === -1) {
             var status = response.status;
-            if (status == 401) {
+            if (status === 401) {
               console.error("ERROR ", status);
             }
-            if (status == 403) {
+            if (status === 403) {
               console.error("UNAUTHORIZED ", status);
             }
-            if (status == 400 || status == 404 || status == 412 || status == 500) {
+            if (status === 400 || status === 404 || status === 412 || status === 500) {
               console.error("GENERIC ERROR ", status);
             }
           }

http://git-wip-us.apache.org/repos/asf/syncope/blob/339f9d5d/client/enduser/src/main/resources/META-INF/resources/app/js/controllers/UserController.js
----------------------------------------------------------------------
diff --git a/client/enduser/src/main/resources/META-INF/resources/app/js/controllers/UserController.js b/client/enduser/src/main/resources/META-INF/resources/app/js/controllers/UserController.js
index ad6ea3c..3aa009a 100644
--- a/client/enduser/src/main/resources/META-INF/resources/app/js/controllers/UserController.js
+++ b/client/enduser/src/main/resources/META-INF/resources/app/js/controllers/UserController.js
@@ -20,11 +20,10 @@
 'use strict';
 
 angular.module("self").controller("UserController", ['$scope', '$rootScope', '$location', '$compile', 'AuthService',
-  'UserSelfService', 'SchemaService', 'RealmService', 'ResourceService', 'SecurityQuestionService', 'CaptchaService',
-  'GroupService', 'AnyService', 'UserUtil', 'GenericUtil', "ValidationExecutor",
+  'UserSelfService', 'SchemaService', 'RealmService', 'ResourceService', 'SecurityQuestionService', 'GroupService',
+  'AnyService', 'UserUtil', 'GenericUtil', "ValidationExecutor",
   function ($scope, $rootScope, $location, $compile, AuthService, UserSelfService, SchemaService, RealmService,
-          ResourceService, SecurityQuestionService, CaptchaService, GroupService, AnyService, UserUtil, GenericUtil,
-          ValidationExecutor) {
+          ResourceService, SecurityQuestionService, GroupService, AnyService, UserUtil, GenericUtil, ValidationExecutor) {
 
     $scope.user = {};
     $scope.confirmPassword = {
@@ -255,8 +254,7 @@ angular.module("self").controller("UserController", ['$scope', '$rootScope', '$l
           }
           if ($scope.user.mustChangePassword) {
             $location.path('/mustchangepassword')
-          }
-          else {
+          } else {
             initProperties();
           }
         }, function (e) {
@@ -395,8 +393,7 @@ angular.module("self").controller("UserController", ['$scope', '$rootScope', '$l
             }
             $scope.showError("Error retrieving user security question: " + errorMessage, $scope.notification);
           });
-        }
-        else {
+        } else {
           $scope.userSecurityQuestion = "";
         }
       }

http://git-wip-us.apache.org/repos/asf/syncope/blob/339f9d5d/client/enduser/src/main/resources/META-INF/resources/app/js/directives/captcha.js
----------------------------------------------------------------------
diff --git a/client/enduser/src/main/resources/META-INF/resources/app/js/directives/captcha.js b/client/enduser/src/main/resources/META-INF/resources/app/js/directives/captcha.js
index dc52bd8..a2d5938 100644
--- a/client/enduser/src/main/resources/META-INF/resources/app/js/directives/captcha.js
+++ b/client/enduser/src/main/resources/META-INF/resources/app/js/directives/captcha.js
@@ -19,17 +19,17 @@
 'use strict';
 
 angular.module('self')
-        .directive('captcha', function (CaptchaService) {
+        .directive('captcha', function () {
           return {
             restrict: 'E',
             templateUrl: 'views/captcha.html',
             scope: {
               input: "=",
-              captchaEnabled : '=enabled'
+              captchaEnabled: '=enabled'
             },
             controller: function ($scope) {
               $scope.captchaUrl = '';
-                            
+
               //initialize captcha
               $scope.refreshCaptcha = function () {
                 console.debug("REFRESH CAPTCHA")
@@ -38,8 +38,10 @@ angular.module('self')
 
               // initialize captcha
               $scope.refreshCaptcha();
-              
-              $scope.$on("refreshCaptcha", function(){$scope.refreshCaptcha()});
+
+              $scope.$on("refreshCaptcha", function () {
+                $scope.refreshCaptcha()
+              });
             }
           };
         });