RemeberMe fix

This commit is contained in:
shimingxy
2020-03-29 19:24:27 +08:00
parent 70e25496e3
commit 6e62782bc7
3 changed files with 15 additions and 0 deletions

View File

@@ -2,6 +2,7 @@ package org.maxkey.authn;
import org.maxkey.authn.realm.AbstractAuthenticationRealm;
import org.maxkey.authn.support.jwt.JwtLoginService;
import org.maxkey.authn.support.rememberme.AbstractRemeberMeService;
import org.maxkey.config.ApplicationConfig;
import org.maxkey.constants.LOGINTYPE;
import org.maxkey.crypto.password.PasswordReciprocal;
@@ -41,6 +42,10 @@ public abstract class AbstractAuthenticationProvider{
@Autowired
@Qualifier("tfaOTPAuthn")
protected AbstractOTPAuthn tfaOTPAuthn;
@Autowired
@Qualifier("remeberMeService")
protected AbstractRemeberMeService remeberMeService;
/* @Autowired
@Qualifier("jwtLoginService")

View File

@@ -8,6 +8,8 @@ import org.slf4j.LoggerFactory;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.WebAuthenticationDetails;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
/**
@@ -62,6 +64,10 @@ public class RealmAuthenticationProvider extends AbstractAuthenticationProvider
if(auth.getJ_remeberme()!=null&&auth.getJ_remeberme().equals("remeberMe")){
WebContext.getSession().setAttribute(WebConstants.REMEBER_ME_SESSION,auth.getJ_username());
_logger.debug("do Remeber Me");
remeberMeService.createRemeberMe(
userInfo.getUsername(),
WebContext.getRequest(),
((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getResponse());
}
}