Authentication 优化

This commit is contained in:
Crystal.Sea
2020-11-08 13:05:30 +08:00
parent c1e4b36cbe
commit 06b27d3564
41 changed files with 425 additions and 163 deletions

View File

@@ -21,7 +21,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.maxkey.authn.AbstractAuthenticationProvider;
import org.maxkey.authn.BasicAuthentication;
import org.maxkey.authn.LoginCredential;
import org.maxkey.authn.support.jwt.JwtLoginService;
import org.maxkey.authn.support.rememberme.AbstractRemeberMeService;
import org.maxkey.configuration.ApplicationConfig;
@@ -110,12 +110,12 @@ public class LoginEndpoint {
}
@RequestMapping(value={"/logon.do"})
public ModelAndView logon(@ModelAttribute("authentication") BasicAuthentication authentication) {
public ModelAndView logon(@ModelAttribute("loginCredential") LoginCredential loginCredential) {
if(WebContext.isAuthenticated()){
return WebContext.redirect("/main");
}else{
authenticationProvider.authenticate(authentication);
authenticationProvider.authenticate(loginCredential);
return WebContext.redirect("/login");
}
}

View File

@@ -23,7 +23,7 @@ import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.maxkey.authn.BasicAuthentication;
import org.maxkey.authn.SigninPrincipal;
import org.maxkey.configuration.ApplicationConfig;
import org.maxkey.web.WebContext;
import org.slf4j.Logger;
@@ -68,7 +68,7 @@ public class PermissionAdapter extends HandlerInterceptorAdapter {
}
//非管理员用户直接注销
if (!((BasicAuthentication) WebContext.getAuthentication().getPrincipal()).isRoleAdministrators()) {
if (!((SigninPrincipal) WebContext.getAuthentication().getPrincipal()).isRoleAdministrators()) {
_logger.debug("Not ADMINISTRATORS Authentication .");
RequestDispatcher dispatcher = request.getRequestDispatcher("/logout");
dispatcher.forward(request, response);