Amoratinos commented on code in PR #3286:
URL: https://github.com/apache/jackrabbit-oak/pull/3286#discussion_r4539663326


##########
oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserConfigurationImpl.java:
##########
@@ -273,7 +273,7 @@ public WorkspaceInitializer getWorkspaceInitializer() {
     @NotNull
     @Override
     public List<? extends ValidatorProvider> getValidators(@NotNull String 
workspaceName, @NotNull Set<Principal> principals, @NotNull MoveTracker 
moveTracker) {
-        return List.of(new UserValidatorProvider(getParameters(), 
getRootProvider(), getTreeProvider()), new CacheValidatorProvider(principals, 
getTreeProvider()));
+        return List.of(new UserValidatorProvider(getParameters(), 
getRootProvider(), getTreeProvider(), getMonitor()), new 
CacheValidatorProvider(principals, getTreeProvider()));

Review Comment:
   In `getUserManager` the instance variable `monitor` is used without calling 
the get method, couldn't we use it here as well? Creating a new `getMonitor` 
method when we already have a `getMonitors` method feels a bit off to me



##########
oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserAuthentication.java:
##########
@@ -113,16 +116,22 @@ public boolean authenticate(@Nullable Credentials 
credentials) throws LoginExcep
                 if (loginId.equals(creds.getUserID()) && userCreds instanceof 
CredentialsImpl) {
                     success = PasswordUtil.isSame(((CredentialsImpl) 
userCreds).getPasswordHash(), creds.getPassword());
                 }
-                checkSuccess(success, "UserId/Password mismatch.");
-
                 // change the password if the credentials object has the 
UserConstants.CREDENTIALS_ATTRIBUTE_NEWPASSWORD attribute set
-                if (isPasswordExpired(user) && !changePassword(user, creds)) {
+                boolean expired = success && isPasswordExpired(user) && 
!changePassword(user, creds);
+                if (user.isAdmin()) {
+                    monitor.adminLogin(success && !expired);

Review Comment:
   Wdyt if instead monitoring only admin login we change the monitoring method 
to 
   
   ```java
   
   monitor.login(success && !expired, user.isAdmin())
   
   ```
   
   Then in the UserMonitorImpl we only count those that are only admin ones. 



##########
oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserValidatorProvider.java:
##########
@@ -61,4 +65,9 @@ ConfigurationParameters getConfig() {
     MembershipProvider getMembershipProvider() {
         return membershipProvider;
     }
+
+    @NotNull
+    UserMonitor getMonitor() {
+        return monitor;
+    }

Review Comment:
   If I'm not mistaken the only scope for this `getMonitor` method is to be 
used in the `UserValidator` class so instead of creating a getter here I'd 
suggest to inject it in the `UserValidator` constructor. 
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to