fix #1516 add login failure log
This commit is contained in:
parent
3215666607
commit
f2da89d555
3 changed files with 36 additions and 1 deletions
|
@ -17,6 +17,7 @@ package org.codelibs.fess.app.web.login;
|
|||
|
||||
import org.codelibs.fess.app.web.base.FessLoginAction;
|
||||
import org.codelibs.fess.util.RenderDataUtil;
|
||||
import org.dbflute.optional.OptionalThing;
|
||||
import org.lastaflute.web.Execute;
|
||||
import org.lastaflute.web.login.credential.UserPasswordCredential;
|
||||
import org.lastaflute.web.login.exception.LoginFailureException;
|
||||
|
@ -57,6 +58,7 @@ public class LoginAction extends FessLoginAction {
|
|||
return getHtmlResponse();
|
||||
});
|
||||
} catch (final LoginFailureException lfe) {
|
||||
activityHelper.loginFailure(OptionalThing.of(new UserPasswordCredential(username, password)));
|
||||
throwValidationError(messages -> messages.addErrorsLoginError(GLOBAL), () -> asIndexPage(form));
|
||||
}
|
||||
return redirect(getClass());
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.codelibs.fess.app.web.base.login.ActionResponseCredential;
|
|||
import org.codelibs.fess.app.web.login.LoginAction;
|
||||
import org.codelibs.fess.sso.SsoManager;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.dbflute.optional.OptionalThing;
|
||||
import org.lastaflute.web.Execute;
|
||||
import org.lastaflute.web.login.credential.LoginCredential;
|
||||
import org.lastaflute.web.login.exception.LoginFailureException;
|
||||
|
@ -65,6 +66,7 @@ public class SsoAction extends FessLoginAction {
|
|||
if (ssoManager.available()) {
|
||||
saveError(messages -> messages.addErrorsSsoLoginError(GLOBAL));
|
||||
}
|
||||
activityHelper.loginFailure(OptionalThing.of(loginCredential));
|
||||
return redirect(LoginAction.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,9 +24,13 @@ import java.util.stream.Collectors;
|
|||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.codelibs.core.lang.StringUtil;
|
||||
import org.codelibs.fess.app.web.base.login.OpenIdConnectCredential;
|
||||
import org.codelibs.fess.app.web.base.login.SpnegoCredential;
|
||||
import org.codelibs.fess.mylasta.action.FessUserBean;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.dbflute.optional.OptionalThing;
|
||||
import org.lastaflute.web.login.credential.LoginCredential;
|
||||
import org.lastaflute.web.login.credential.UserPasswordCredential;
|
||||
import org.lastaflute.web.util.LaRequestUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -61,6 +65,33 @@ public class ActivityHelper {
|
|||
log(buf);
|
||||
}
|
||||
|
||||
public void loginFailure(final OptionalThing<LoginCredential> credential) {
|
||||
final StringBuilder buf = new StringBuilder(100);
|
||||
buf.append("action:");
|
||||
buf.append(Action.LOGIN_FAILURE);
|
||||
credential.map(c -> {
|
||||
final StringBuilder buffer = new StringBuilder(100);
|
||||
buffer.append('\t');
|
||||
buffer.append("class:");
|
||||
buffer.append(c.getClass().getSimpleName());
|
||||
if (c instanceof OpenIdConnectCredential) {
|
||||
buffer.append('\t');
|
||||
buffer.append("user:");
|
||||
buffer.append(((OpenIdConnectCredential) c).getEmail());
|
||||
} else if (c instanceof SpnegoCredential) {
|
||||
buffer.append('\t');
|
||||
buffer.append("user:");
|
||||
buffer.append(((SpnegoCredential) c).getUsername());
|
||||
} else if (c instanceof UserPasswordCredential) {
|
||||
buffer.append('\t');
|
||||
buffer.append("user:");
|
||||
buffer.append(((UserPasswordCredential) c).getUser());
|
||||
}
|
||||
return buffer.toString();
|
||||
}).ifPresent(buf::append);
|
||||
log(buf);
|
||||
}
|
||||
|
||||
public void logout(final OptionalThing<FessUserBean> user) {
|
||||
final StringBuilder buf = new StringBuilder(100);
|
||||
buf.append("action:");
|
||||
|
@ -106,7 +137,7 @@ public class ActivityHelper {
|
|||
}
|
||||
|
||||
protected enum Action {
|
||||
LOGIN, LOGOUT, ACCESS;
|
||||
LOGIN, LOGOUT, ACCESS, LOGIN_FAILURE;
|
||||
}
|
||||
|
||||
public void setLoggerName(final String loggerName) {
|
||||
|
|
Loading…
Add table
Reference in a new issue