mirror of
https://gitee.com/dromara/MaxKey.git
synced 2026-05-18 14:28:08 +08:00
v2.0.RC1
v2.0.RC1
This commit is contained in:
@@ -10,6 +10,11 @@ import org.apache.catalina.connector.Connector;
|
||||
import org.apache.tomcat.util.descriptor.web.SecurityCollection;
|
||||
import org.apache.tomcat.util.descriptor.web.SecurityConstraint;
|
||||
import org.maxkey.authn.realm.jdbc.JdbcAuthenticationRealm;
|
||||
import org.maxkey.authn.realm.ldap.LdapAuthenticationRealm;
|
||||
import org.maxkey.authn.realm.ldap.LdapServer;
|
||||
import org.maxkey.authn.realm.IAuthenticationServer;
|
||||
import org.maxkey.authn.realm.activedirectory.ActiveDirectoryAuthenticationRealm;
|
||||
import org.maxkey.authn.realm.activedirectory.ActiveDirectoryServer;
|
||||
import org.maxkey.authn.support.kerberos.KerberosProxy;
|
||||
import org.maxkey.authn.support.kerberos.RemoteKerberosService;
|
||||
import org.maxkey.authn.support.socialsignon.service.JdbcSocialsAssociateService;
|
||||
@@ -21,6 +26,8 @@ import org.maxkey.crypto.password.opt.impl.MailOtpAuthn;
|
||||
import org.maxkey.crypto.password.opt.impl.SmsOtpAuthn;
|
||||
import org.maxkey.crypto.password.opt.impl.TimeBasedOtpAuthn;
|
||||
import org.maxkey.crypto.password.opt.impl.sms.SmsOtpAuthnYunxin;
|
||||
import org.maxkey.persistence.ldap.ActiveDirectoryUtils;
|
||||
import org.maxkey.persistence.ldap.LdapUtils;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -135,15 +142,61 @@ public class MaxKeyConfig implements InitializingBean {
|
||||
_logger.debug("KeyUri Format " + keyUriFormat);
|
||||
return keyUriFormat;
|
||||
}
|
||||
|
||||
|
||||
//可以在此实现其他的登陆认证方式,请实现AbstractAuthenticationRealm
|
||||
@Bean(name = "authenticationRealm")
|
||||
public JdbcAuthenticationRealm JdbcAuthenticationRealm(
|
||||
public JdbcAuthenticationRealm authenticationRealm(
|
||||
JdbcTemplate jdbcTemplate) {
|
||||
JdbcAuthenticationRealm authenticationRealm = jdbcAuthenticationRealm(jdbcTemplate);
|
||||
return authenticationRealm;
|
||||
}
|
||||
|
||||
//JdbcAuthenticationRealm
|
||||
public JdbcAuthenticationRealm jdbcAuthenticationRealm(
|
||||
JdbcTemplate jdbcTemplate) {
|
||||
JdbcAuthenticationRealm authenticationRealm = new JdbcAuthenticationRealm(jdbcTemplate);
|
||||
_logger.debug("JdbcAuthenticationRealm inited.");
|
||||
return authenticationRealm;
|
||||
}
|
||||
|
||||
//LdapAuthenticationRealm
|
||||
public LdapAuthenticationRealm ldapAuthenticationRealm(
|
||||
JdbcTemplate jdbcTemplate) {
|
||||
LdapAuthenticationRealm authenticationRealm = new LdapAuthenticationRealm(jdbcTemplate);
|
||||
LdapServer ldapServer=new LdapServer();
|
||||
String providerUrl = "ldap://localhost:389";
|
||||
String principal = "cn=root";
|
||||
String credentials = "maxkey";
|
||||
String baseDN = "dc=maxkey,dc=top";
|
||||
LdapUtils ldapUtils = new LdapUtils(providerUrl,principal,credentials,baseDN);
|
||||
ldapServer.setLdapUtils(ldapUtils);
|
||||
ldapServer.setFilterAttribute("uid");
|
||||
List<IAuthenticationServer> ldapServers = new ArrayList<IAuthenticationServer>();
|
||||
ldapServers.add(ldapServer);
|
||||
authenticationRealm.setLdapServers(ldapServers);
|
||||
_logger.debug("LdapAuthenticationRealm inited.");
|
||||
return authenticationRealm;
|
||||
}
|
||||
|
||||
//ActiveDirectoryAuthenticationRealm
|
||||
public ActiveDirectoryAuthenticationRealm activeDirectoryAuthenticationRealm(
|
||||
JdbcTemplate jdbcTemplate) {
|
||||
ActiveDirectoryAuthenticationRealm authenticationRealm = new ActiveDirectoryAuthenticationRealm(jdbcTemplate);
|
||||
ActiveDirectoryServer ldapServer=new ActiveDirectoryServer();
|
||||
String providerUrl = "ldap://localhost:389";
|
||||
String principal = "cn=root";
|
||||
String credentials = "maxkey";
|
||||
String domain = "maxkey";
|
||||
ActiveDirectoryUtils ldapUtils = new ActiveDirectoryUtils(providerUrl,principal,credentials,domain);
|
||||
ldapServer.setActiveDirectoryUtils(ldapUtils);
|
||||
|
||||
List<IAuthenticationServer> ldapServers = new ArrayList<IAuthenticationServer>();
|
||||
ldapServers.add(ldapServer);
|
||||
authenticationRealm.setActiveDirectoryServers(ldapServers);
|
||||
_logger.debug("LdapAuthenticationRealm inited.");
|
||||
return authenticationRealm;
|
||||
}
|
||||
|
||||
@Bean(name = "tfaOptAuthn")
|
||||
public TimeBasedOtpAuthn tfaOptAuthn() {
|
||||
TimeBasedOtpAuthn tfaOptAuthn = new TimeBasedOtpAuthn();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.maxkey;
|
||||
|
||||
import org.maxkey.authn.support.basic.BasicEntryPoint;
|
||||
import org.maxkey.authn.support.httpheader.HttpHeaderConfig;
|
||||
import org.maxkey.authn.support.httpheader.HttpHeaderEntryPoint;
|
||||
import org.maxkey.web.interceptor.HistoryLoginAppAdapter;
|
||||
import org.maxkey.web.interceptor.HistoryLogsAdapter;
|
||||
@@ -76,11 +75,17 @@ public class MaxKeyMvcConfig implements WebMvcConfigurer {
|
||||
.addPathPatterns("/authz/desktop/*")
|
||||
.addPathPatterns("/authz/formbased/*")
|
||||
.addPathPatterns("/authz/tokenbased/*")
|
||||
//SAML
|
||||
.addPathPatterns("/authz/saml20/idpinit/*")
|
||||
.addPathPatterns("/authz/saml20/assertion")
|
||||
.addPathPatterns("/authz/saml20/assertion/")
|
||||
//CAS
|
||||
.addPathPatterns("/authz/cas/*")
|
||||
.addPathPatterns("/authz/cas/*/*")
|
||||
.addPathPatterns("/authz/cas/login")
|
||||
.addPathPatterns("/authz/cas/login/")
|
||||
.addPathPatterns("/authz/cas/granting/*")
|
||||
//OAuth
|
||||
.addPathPatterns("/oauth/v20/authorize")
|
||||
.addPathPatterns("/oauth/v20/authorize/*")
|
||||
;
|
||||
@@ -122,8 +127,7 @@ public class MaxKeyMvcConfig implements WebMvcConfigurer {
|
||||
_logger.debug("add LocaleChangeInterceptor");
|
||||
|
||||
if(httpHeaderEnable) {
|
||||
HttpHeaderConfig httpHeaderConfig= new HttpHeaderConfig(this.httpHeaderName,httpHeaderEnable);
|
||||
registry.addInterceptor(new HttpHeaderEntryPoint(httpHeaderConfig))
|
||||
registry.addInterceptor(new HttpHeaderEntryPoint(httpHeaderName,httpHeaderEnable))
|
||||
.addPathPatterns("/*");
|
||||
_logger.debug("add HttpHeaderEntryPoint");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user