split maxkey-authentication-provider

This commit is contained in:
MaxKey 2022-08-03 21:46:22 +08:00
parent 7819373af7
commit 8954f7f891
67 changed files with 301 additions and 193 deletions

View File

@ -1,18 +0,0 @@
/*
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.maxkey.authn.annotation;

View File

@ -1,18 +0,0 @@
/*
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.maxkey.authn.jwt;

View File

@ -1,18 +0,0 @@
/*
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.maxkey.authn.provider;

View File

@ -15,7 +15,7 @@
*/ */
package org.maxkey.authn; package org.maxkey.authn.web;
import java.io.IOException; import java.io.IOException;
import javax.servlet.ServletException; import javax.servlet.ServletException;

View File

@ -1,18 +0,0 @@
/*
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.maxkey.authn.web.interceptor;

View File

@ -0,0 +1,69 @@
/*
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.maxkey.autoconfigure;
import org.maxkey.authn.session.SessionManager;
import org.maxkey.authn.session.SessionManagerFactory;
import org.maxkey.authn.web.HttpSessionListenerAdapter;
import org.maxkey.authn.web.SavedRequestAwareAuthenticationSuccessHandler;
import org.maxkey.persistence.redis.RedisConnectionFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;
@Configuration
public class SessionAutoConfiguration implements InitializingBean {
private static final Logger _logger =
LoggerFactory.getLogger(SessionAutoConfiguration.class);
@Bean(name = "savedRequestSuccessHandler")
public SavedRequestAwareAuthenticationSuccessHandler
savedRequestAwareAuthenticationSuccessHandler() {
return new SavedRequestAwareAuthenticationSuccessHandler();
}
@Bean
public SessionManager sessionManager(
@Value("${maxkey.server.persistence}") int persistence,
JdbcTemplate jdbcTemplate,
RedisConnectionFactory redisConnFactory,
@Value("${maxkey.session.timeout:1800}") int timeout
) {
_logger.debug("session timeout " + timeout);
SessionManager sessionManager =
new SessionManagerFactory(
persistence, jdbcTemplate, redisConnFactory,timeout);
return sessionManager;
}
@Bean
public HttpSessionListenerAdapter httpSessionListenerAdapter() {
return new HttpSessionListenerAdapter();
}
@Override
public void afterPropertiesSet() throws Exception {
}
}

View File

@ -0,0 +1,77 @@
/*
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.maxkey.autoconfigure;
import org.maxkey.authn.jwt.AuthRefreshTokenService;
import org.maxkey.authn.jwt.AuthTokenService;
import org.maxkey.authn.jwt.CongressService;
import org.maxkey.authn.jwt.InMemoryCongressService;
import org.maxkey.authn.jwt.RedisCongressService;
import org.maxkey.configuration.AuthJwkConfig;
import org.maxkey.constants.ConstsPersistence;
import org.maxkey.persistence.cache.MomentaryService;
import org.maxkey.persistence.redis.RedisConnectionFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.nimbusds.jose.JOSEException;
@Configuration
public class TokenAutoConfiguration implements InitializingBean {
private static final Logger _logger =
LoggerFactory.getLogger(TokenAutoConfiguration.class);
@Bean
public AuthTokenService authTokenService(
AuthJwkConfig authJwkConfig,
RedisConnectionFactory redisConnFactory,
MomentaryService momentaryService,
AuthRefreshTokenService refreshTokenService,
@Value("${maxkey.server.persistence}") int persistence) throws JOSEException {
CongressService congressService;
if (persistence == ConstsPersistence.REDIS) {
congressService = new RedisCongressService(redisConnFactory);
}else {
congressService = new InMemoryCongressService();
}
AuthTokenService authTokenService =
new AuthTokenService(
authJwkConfig,
congressService,
momentaryService,
refreshTokenService
);
return authTokenService;
}
@Bean
public AuthRefreshTokenService refreshTokenService(AuthJwkConfig authJwkConfig) throws JOSEException {
return new AuthRefreshTokenService(authJwkConfig);
}
@Override
public void afterPropertiesSet() throws Exception {
}
}

View File

@ -0,0 +1,63 @@
/*
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.maxkey.autoconfigure;
import org.maxkey.constants.ConstsPersistence;
import org.maxkey.password.onetimepwd.OtpAuthnService;
import org.maxkey.password.onetimepwd.token.RedisOtpTokenStore;
import org.maxkey.persistence.redis.RedisConnectionFactory;
import org.maxkey.persistence.service.EmailSendersService;
import org.maxkey.persistence.service.SmsProviderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class OneTimePasswordAutoConfiguration implements InitializingBean {
private static final Logger _logger =
LoggerFactory.getLogger(OneTimePasswordAutoConfiguration.class);
@Bean(name = "otpAuthnService")
public OtpAuthnService otpAuthnService(
@Value("${maxkey.server.persistence}") int persistence,
SmsProviderService smsProviderService,
EmailSendersService emailSendersService,
RedisConnectionFactory redisConnFactory) {
OtpAuthnService otpAuthnService =
new OtpAuthnService(smsProviderService,emailSendersService);
if (persistence == ConstsPersistence.REDIS) {
RedisOtpTokenStore redisOptTokenStore = new RedisOtpTokenStore(redisConnFactory);
otpAuthnService.setRedisOptTokenStore(redisOptTokenStore);
}
_logger.debug("OneTimePasswordService {} inited." ,
persistence == ConstsPersistence.REDIS ? "Redis" : "InMemory");
return otpAuthnService;
}
@Override
public void afterPropertiesSet() throws Exception {
}
}

View File

@ -0,0 +1,15 @@
description = "maxkey-authentication-provider"
dependencies {
//local jars
implementation fileTree(dir: '../maxkey-lib/', include: '*/*.jar')
implementation project(":maxkey-common")
implementation project(":maxkey-core")
implementation project(":maxkey-persistence")
implementation project(":maxkey-authentications:maxkey-authentication-core")
implementation project(":maxkey-authentications:maxkey-authentication-otp")
}

View File

@ -0,0 +1,3 @@
Manifest-Version: 1.0
Class-Path:

View File

@ -15,10 +15,12 @@
*/ */
package org.maxkey.authn; package org.maxkey.authn.provider;
import java.util.ArrayList; import java.util.ArrayList;
import org.maxkey.authn.LoginCredential;
import org.maxkey.authn.SignPrincipal;
import org.maxkey.authn.jwt.AuthTokenService; import org.maxkey.authn.jwt.AuthTokenService;
import org.maxkey.authn.realm.AbstractAuthenticationRealm; import org.maxkey.authn.realm.AbstractAuthenticationRealm;
import org.maxkey.authn.session.Session; import org.maxkey.authn.session.Session;

View File

@ -17,7 +17,6 @@ package org.maxkey.authn.provider;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import org.maxkey.authn.AbstractAuthenticationProvider;
import org.maxkey.authn.LoginCredential; import org.maxkey.authn.LoginCredential;
import org.springframework.security.core.Authentication; import org.springframework.security.core.Authentication;

View File

@ -15,11 +15,11 @@
*/ */
package org.maxkey.authn.provider; package org.maxkey.authn.provider.impl;
import org.maxkey.authn.AbstractAuthenticationProvider;
import org.maxkey.authn.LoginCredential; import org.maxkey.authn.LoginCredential;
import org.maxkey.authn.jwt.AuthTokenService; import org.maxkey.authn.jwt.AuthTokenService;
import org.maxkey.authn.provider.AbstractAuthenticationProvider;
import org.maxkey.authn.realm.AbstractAuthenticationRealm; import org.maxkey.authn.realm.AbstractAuthenticationRealm;
import org.maxkey.authn.session.SessionManager; import org.maxkey.authn.session.SessionManager;
import org.maxkey.configuration.ApplicationConfig; import org.maxkey.configuration.ApplicationConfig;

View File

@ -15,10 +15,10 @@
*/ */
package org.maxkey.authn.provider; package org.maxkey.authn.provider.impl;
import org.maxkey.authn.AbstractAuthenticationProvider;
import org.maxkey.authn.LoginCredential; import org.maxkey.authn.LoginCredential;
import org.maxkey.authn.provider.AbstractAuthenticationProvider;
import org.maxkey.authn.realm.AbstractAuthenticationRealm; import org.maxkey.authn.realm.AbstractAuthenticationRealm;
import org.maxkey.authn.session.SessionManager; import org.maxkey.authn.session.SessionManager;
import org.maxkey.configuration.ApplicationConfig; import org.maxkey.configuration.ApplicationConfig;

View File

@ -15,12 +15,13 @@
*/ */
package org.maxkey.authn.provider; package org.maxkey.authn.provider.impl;
import java.text.ParseException; import java.text.ParseException;
import org.maxkey.authn.AbstractAuthenticationProvider;
import org.maxkey.authn.LoginCredential; import org.maxkey.authn.LoginCredential;
import org.maxkey.authn.jwt.AuthTokenService; import org.maxkey.authn.jwt.AuthTokenService;
import org.maxkey.authn.provider.AbstractAuthenticationProvider;
import org.maxkey.authn.realm.AbstractAuthenticationRealm; import org.maxkey.authn.realm.AbstractAuthenticationRealm;
import org.maxkey.authn.session.SessionManager; import org.maxkey.authn.session.SessionManager;
import org.maxkey.configuration.ApplicationConfig; import org.maxkey.configuration.ApplicationConfig;

View File

@ -15,10 +15,10 @@
*/ */
package org.maxkey.authn.provider; package org.maxkey.authn.provider.impl;
import org.maxkey.authn.AbstractAuthenticationProvider;
import org.maxkey.authn.LoginCredential; import org.maxkey.authn.LoginCredential;
import org.maxkey.authn.provider.AbstractAuthenticationProvider;
import org.maxkey.authn.realm.AbstractAuthenticationRealm; import org.maxkey.authn.realm.AbstractAuthenticationRealm;
import org.maxkey.authn.session.SessionManager; import org.maxkey.authn.session.SessionManager;
import org.maxkey.configuration.ApplicationConfig; import org.maxkey.configuration.ApplicationConfig;

View File

@ -20,8 +20,8 @@ package org.maxkey.authn.support.basic;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.maxkey.authn.AbstractAuthenticationProvider;
import org.maxkey.authn.LoginCredential; import org.maxkey.authn.LoginCredential;
import org.maxkey.authn.provider.AbstractAuthenticationProvider;
import org.maxkey.constants.ConstsLoginType; import org.maxkey.constants.ConstsLoginType;
import org.maxkey.util.AuthorizationHeaderCredential; import org.maxkey.util.AuthorizationHeaderCredential;
import org.maxkey.util.AuthorizationHeaderUtils; import org.maxkey.util.AuthorizationHeaderUtils;

View File

@ -22,7 +22,7 @@ import java.security.cert.X509Certificate;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.maxkey.authn.AbstractAuthenticationProvider; import org.maxkey.authn.provider.AbstractAuthenticationProvider;
import org.maxkey.authn.support.httpheader.HttpHeaderEntryPoint; import org.maxkey.authn.support.httpheader.HttpHeaderEntryPoint;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;

View File

@ -20,8 +20,8 @@ package org.maxkey.authn.support.httpheader;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.maxkey.authn.AbstractAuthenticationProvider;
import org.maxkey.authn.LoginCredential; import org.maxkey.authn.LoginCredential;
import org.maxkey.authn.provider.AbstractAuthenticationProvider;
import org.maxkey.constants.ConstsLoginType; import org.maxkey.constants.ConstsLoginType;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;

View File

@ -16,10 +16,10 @@
package org.maxkey.authn.support.jwt; package org.maxkey.authn.support.jwt;
import org.maxkey.authn.AbstractAuthenticationProvider;
import org.maxkey.authn.LoginCredential; import org.maxkey.authn.LoginCredential;
import org.maxkey.authn.jwt.AuthJwt; import org.maxkey.authn.jwt.AuthJwt;
import org.maxkey.authn.jwt.AuthTokenService; import org.maxkey.authn.jwt.AuthTokenService;
import org.maxkey.authn.provider.AbstractAuthenticationProvider;
import org.maxkey.configuration.ApplicationConfig; import org.maxkey.configuration.ApplicationConfig;
import org.maxkey.constants.ConstsLoginType; import org.maxkey.constants.ConstsLoginType;
import org.maxkey.entity.Message; import org.maxkey.entity.Message;

View File

@ -20,8 +20,8 @@ package org.maxkey.authn.support.kerberos;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.maxkey.authn.AbstractAuthenticationProvider;
import org.maxkey.authn.LoginCredential; import org.maxkey.authn.LoginCredential;
import org.maxkey.authn.provider.AbstractAuthenticationProvider;
import org.maxkey.authn.web.AuthorizationUtils; import org.maxkey.authn.web.AuthorizationUtils;
import org.maxkey.configuration.ApplicationConfig; import org.maxkey.configuration.ApplicationConfig;
import org.maxkey.constants.ConstsLoginType; import org.maxkey.constants.ConstsLoginType;

View File

@ -19,8 +19,9 @@ package org.maxkey.authn.support.wsfederation;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.maxkey.authn.AbstractAuthenticationProvider;
import org.maxkey.authn.LoginCredential; import org.maxkey.authn.LoginCredential;
import org.maxkey.authn.provider.AbstractAuthenticationProvider;
import org.maxkey.authn.web.AuthorizationUtils; import org.maxkey.authn.web.AuthorizationUtils;
import org.maxkey.configuration.ApplicationConfig; import org.maxkey.configuration.ApplicationConfig;
import org.maxkey.constants.ConstsLoginType; import org.maxkey.constants.ConstsLoginType;

View File

@ -17,30 +17,20 @@
package org.maxkey.autoconfigure; package org.maxkey.autoconfigure;
import org.maxkey.authn.AbstractAuthenticationProvider;
import org.maxkey.authn.SavedRequestAwareAuthenticationSuccessHandler;
import org.maxkey.authn.jwt.AuthRefreshTokenService;
import org.maxkey.authn.jwt.AuthTokenService; import org.maxkey.authn.jwt.AuthTokenService;
import org.maxkey.authn.jwt.CongressService; import org.maxkey.authn.provider.AbstractAuthenticationProvider;
import org.maxkey.authn.jwt.InMemoryCongressService;
import org.maxkey.authn.jwt.RedisCongressService;
import org.maxkey.authn.provider.AuthenticationProviderFactory; import org.maxkey.authn.provider.AuthenticationProviderFactory;
import org.maxkey.authn.provider.MobileAuthenticationProvider; import org.maxkey.authn.provider.impl.MobileAuthenticationProvider;
import org.maxkey.authn.provider.NormalAuthenticationProvider; import org.maxkey.authn.provider.impl.NormalAuthenticationProvider;
import org.maxkey.authn.provider.TrustedAuthenticationProvider; import org.maxkey.authn.provider.impl.TrustedAuthenticationProvider;
import org.maxkey.authn.realm.AbstractAuthenticationRealm; import org.maxkey.authn.realm.AbstractAuthenticationRealm;
import org.maxkey.authn.session.SessionManager; import org.maxkey.authn.session.SessionManager;
import org.maxkey.authn.session.SessionManagerFactory;
import org.maxkey.authn.support.rememberme.AbstractRemeberMeManager; import org.maxkey.authn.support.rememberme.AbstractRemeberMeManager;
import org.maxkey.authn.support.rememberme.JdbcRemeberMeManager; import org.maxkey.authn.support.rememberme.JdbcRemeberMeManager;
import org.maxkey.authn.web.HttpSessionListenerAdapter;
import org.maxkey.configuration.ApplicationConfig; import org.maxkey.configuration.ApplicationConfig;
import org.maxkey.configuration.AuthJwkConfig;
import org.maxkey.constants.ConstsPersistence; import org.maxkey.constants.ConstsPersistence;
import org.maxkey.password.onetimepwd.AbstractOtpAuthn;
import org.maxkey.password.onetimepwd.OtpAuthnService; import org.maxkey.password.onetimepwd.OtpAuthnService;
import org.maxkey.password.onetimepwd.token.RedisOtpTokenStore; import org.maxkey.password.onetimepwd.token.RedisOtpTokenStore;
import org.maxkey.persistence.cache.MomentaryService;
import org.maxkey.persistence.redis.RedisConnectionFactory; import org.maxkey.persistence.redis.RedisConnectionFactory;
import org.maxkey.persistence.repository.LoginHistoryRepository; import org.maxkey.persistence.repository.LoginHistoryRepository;
import org.maxkey.persistence.repository.LoginRepository; import org.maxkey.persistence.repository.LoginRepository;
@ -56,20 +46,11 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import com.nimbusds.jose.JOSEException;
@Configuration @Configuration
public class AuthenticationAutoConfiguration implements InitializingBean { public class AuthnProviderAutoConfiguration implements InitializingBean {
private static final Logger _logger = private static final Logger _logger =
LoggerFactory.getLogger(AuthenticationAutoConfiguration.class); LoggerFactory.getLogger(AuthnProviderAutoConfiguration.class);
@Bean(name = "savedRequestSuccessHandler")
public SavedRequestAwareAuthenticationSuccessHandler
savedRequestAwareAuthenticationSuccessHandler() {
return new SavedRequestAwareAuthenticationSuccessHandler();
}
@Bean @Bean
public AbstractAuthenticationProvider authenticationProvider( public AbstractAuthenticationProvider authenticationProvider(
@ -131,55 +112,6 @@ public class AuthenticationAutoConfiguration implements InitializingBean {
); );
} }
@Bean
public AuthTokenService authTokenService(
AuthJwkConfig authJwkConfig,
RedisConnectionFactory redisConnFactory,
MomentaryService momentaryService,
AuthRefreshTokenService refreshTokenService,
@Value("${maxkey.server.persistence}") int persistence) throws JOSEException {
CongressService congressService;
if (persistence == ConstsPersistence.REDIS) {
congressService = new RedisCongressService(redisConnFactory);
}else {
congressService = new InMemoryCongressService();
}
AuthTokenService authTokenService =
new AuthTokenService(
authJwkConfig,
congressService,
momentaryService,
refreshTokenService
);
return authTokenService;
}
@Bean
public AuthRefreshTokenService refreshTokenService(AuthJwkConfig authJwkConfig) throws JOSEException {
return new AuthRefreshTokenService(authJwkConfig);
}
@Bean(name = "otpAuthnService")
public OtpAuthnService otpAuthnService(
@Value("${maxkey.server.persistence}") int persistence,
SmsProviderService smsProviderService,
EmailSendersService emailSendersService,
RedisConnectionFactory redisConnFactory) {
OtpAuthnService otpAuthnService =
new OtpAuthnService(smsProviderService,emailSendersService);
if (persistence == ConstsPersistence.REDIS) {
RedisOtpTokenStore redisOptTokenStore = new RedisOtpTokenStore(redisConnFactory);
otpAuthnService.setRedisOptTokenStore(redisOptTokenStore);
}
_logger.debug("OneTimePasswordService {} inited." ,
persistence == ConstsPersistence.REDIS ? "Redis" : "InMemory");
return otpAuthnService;
}
@Bean @Bean
public PasswordPolicyValidator passwordPolicyValidator(JdbcTemplate jdbcTemplate,MessageSource messageSource) { public PasswordPolicyValidator passwordPolicyValidator(JdbcTemplate jdbcTemplate,MessageSource messageSource) {
return new PasswordPolicyValidator(jdbcTemplate,messageSource); return new PasswordPolicyValidator(jdbcTemplate,messageSource);
@ -195,20 +127,6 @@ public class AuthenticationAutoConfiguration implements InitializingBean {
return new LoginHistoryRepository(jdbcTemplate); return new LoginHistoryRepository(jdbcTemplate);
} }
@Bean
public SessionManager sessionManager(
@Value("${maxkey.server.persistence}") int persistence,
JdbcTemplate jdbcTemplate,
RedisConnectionFactory redisConnFactory,
@Value("${maxkey.session.timeout:1800}") int timeout
) {
_logger.debug("session timeout " + timeout);
SessionManager sessionManager =
new SessionManagerFactory(
persistence, jdbcTemplate, redisConnFactory,timeout);
return sessionManager;
}
/** /**
* remeberMeService . * remeberMeService .
* @return * @return
@ -225,11 +143,6 @@ public class AuthenticationAutoConfiguration implements InitializingBean {
jdbcTemplate,applicationConfig,authTokenService,validity); jdbcTemplate,applicationConfig,authTokenService,validity);
} }
@Bean
public HttpSessionListenerAdapter httpSessionListenerAdapter() {
return new HttpSessionListenerAdapter();
}
@Override @Override
public void afterPropertiesSet() throws Exception { public void afterPropertiesSet() throws Exception {

View File

@ -10,5 +10,6 @@ dependencies {
implementation project(":maxkey-core") implementation project(":maxkey-core")
implementation project(":maxkey-persistence") implementation project(":maxkey-persistence")
implementation project(":maxkey-authentications:maxkey-authentication-core") implementation project(":maxkey-authentications:maxkey-authentication-core")
implementation project(":maxkey-authentications:maxkey-authentication-provider")
} }

View File

@ -20,8 +20,8 @@
*/ */
package org.maxkey.authn.support.socialsignon; package org.maxkey.authn.support.socialsignon;
import org.maxkey.authn.AbstractAuthenticationProvider;
import org.maxkey.authn.jwt.AuthTokenService; import org.maxkey.authn.jwt.AuthTokenService;
import org.maxkey.authn.provider.AbstractAuthenticationProvider;
import org.maxkey.authn.support.socialsignon.service.SocialSignOnProviderService; import org.maxkey.authn.support.socialsignon.service.SocialSignOnProviderService;
import org.maxkey.authn.support.socialsignon.service.SocialsAssociateService; import org.maxkey.authn.support.socialsignon.service.SocialsAssociateService;
import org.maxkey.configuration.ApplicationConfig; import org.maxkey.configuration.ApplicationConfig;

View File

@ -1 +1,25 @@
/*
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
*
*/
/**
* @author Administrator
*
*/
package org.maxkey.persistence.cache; package org.maxkey.persistence.cache;

View File

@ -18,5 +18,6 @@ dependencies {
implementation project(":maxkey-persistence") implementation project(":maxkey-persistence")
implementation project(":maxkey-protocols:maxkey-protocol-authorize") implementation project(":maxkey-protocols:maxkey-protocol-authorize")
implementation project(":maxkey-authentications:maxkey-authentication-core") implementation project(":maxkey-authentications:maxkey-authentication-core")
implementation project(":maxkey-authentications:maxkey-authentication-provider")
} }

View File

@ -23,8 +23,8 @@ package org.maxkey.authz.cas.endpoint;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.maxkey.authn.AbstractAuthenticationProvider;
import org.maxkey.authn.LoginCredential; import org.maxkey.authn.LoginCredential;
import org.maxkey.authn.provider.AbstractAuthenticationProvider;
import org.maxkey.authn.web.AuthorizationUtils; import org.maxkey.authn.web.AuthorizationUtils;
import org.maxkey.authz.cas.endpoint.response.ServiceResponseBuilder; import org.maxkey.authz.cas.endpoint.response.ServiceResponseBuilder;
import org.maxkey.authz.cas.endpoint.ticket.CasConstants; import org.maxkey.authz.cas.endpoint.ticket.CasConstants;

View File

@ -9,4 +9,5 @@ dependencies {
implementation project(":maxkey-persistence") implementation project(":maxkey-persistence")
implementation project(":maxkey-protocols:maxkey-protocol-authorize") implementation project(":maxkey-protocols:maxkey-protocol-authorize")
implementation project(":maxkey-authentications:maxkey-authentication-core") implementation project(":maxkey-authentications:maxkey-authentication-core")
implementation project(":maxkey-authentications:maxkey-authentication-provider")
} }

View File

@ -14,8 +14,8 @@ package org.maxkey.authz.oauth2.provider;
import java.util.ArrayList; import java.util.ArrayList;
import org.maxkey.authn.AbstractAuthenticationProvider;
import org.maxkey.authn.SignPrincipal; import org.maxkey.authn.SignPrincipal;
import org.maxkey.authn.provider.AbstractAuthenticationProvider;
import org.maxkey.authn.session.Session; import org.maxkey.authn.session.Session;
import org.maxkey.entity.UserInfo; import org.maxkey.entity.UserInfo;
import org.maxkey.persistence.repository.LoginRepository; import org.maxkey.persistence.repository.LoginRepository;

View File

@ -8,4 +8,5 @@ dependencies {
implementation project(":maxkey-core") implementation project(":maxkey-core")
implementation project(":maxkey-persistence") implementation project(":maxkey-persistence")
implementation project(":maxkey-authentications:maxkey-authentication-core") implementation project(":maxkey-authentications:maxkey-authentication-core")
implementation project(":maxkey-authentications:maxkey-authentication-provider")
} }

View File

@ -30,10 +30,10 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.maxkey.authn.AbstractAuthenticationProvider;
import org.maxkey.authn.LoginCredential; import org.maxkey.authn.LoginCredential;
import org.maxkey.authn.jwt.AuthJwt; import org.maxkey.authn.jwt.AuthJwt;
import org.maxkey.authn.jwt.AuthTokenService; import org.maxkey.authn.jwt.AuthTokenService;
import org.maxkey.authn.provider.AbstractAuthenticationProvider;
import org.maxkey.authz.saml.common.EndpointGenerator; import org.maxkey.authz.saml.common.EndpointGenerator;
import org.maxkey.authz.saml.common.TrustResolver; import org.maxkey.authz.saml.common.TrustResolver;
import org.maxkey.authz.saml.service.IDService; import org.maxkey.authz.saml.service.IDService;

View File

@ -12,6 +12,7 @@ dependencies {
implementation project(":maxkey-authentications:maxkey-authentication-social") implementation project(":maxkey-authentications:maxkey-authentication-social")
implementation project(":maxkey-authentications:maxkey-authentication-captcha") implementation project(":maxkey-authentications:maxkey-authentication-captcha")
implementation project(":maxkey-authentications:maxkey-authentication-otp") implementation project(":maxkey-authentications:maxkey-authentication-otp")
implementation project(":maxkey-authentications:maxkey-authentication-provider")
implementation project(":maxkey-protocols:maxkey-protocol-authorize") implementation project(":maxkey-protocols:maxkey-protocol-authorize")
implementation project(":maxkey-protocols:maxkey-protocol-cas") implementation project(":maxkey-protocols:maxkey-protocol-cas")

View File

@ -19,7 +19,7 @@ package org.maxkey;
import java.util.List; import java.util.List;
import org.maxkey.authn.AbstractAuthenticationProvider; import org.maxkey.authn.provider.AbstractAuthenticationProvider;
import org.maxkey.authn.support.basic.BasicEntryPoint; import org.maxkey.authn.support.basic.BasicEntryPoint;
import org.maxkey.authn.support.httpheader.HttpHeaderEntryPoint; import org.maxkey.authn.support.httpheader.HttpHeaderEntryPoint;
import org.maxkey.authn.support.kerberos.HttpKerberosEntryPoint; import org.maxkey.authn.support.kerberos.HttpKerberosEntryPoint;

View File

@ -25,10 +25,10 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.maxkey.authn.AbstractAuthenticationProvider;
import org.maxkey.authn.LoginCredential; import org.maxkey.authn.LoginCredential;
import org.maxkey.authn.jwt.AuthJwt; import org.maxkey.authn.jwt.AuthJwt;
import org.maxkey.authn.jwt.AuthTokenService; import org.maxkey.authn.jwt.AuthTokenService;
import org.maxkey.authn.provider.AbstractAuthenticationProvider;
import org.maxkey.authn.support.kerberos.KerberosService; import org.maxkey.authn.support.kerberos.KerberosService;
import org.maxkey.authn.support.rememberme.AbstractRemeberMeManager; import org.maxkey.authn.support.rememberme.AbstractRemeberMeManager;
import org.maxkey.authn.support.rememberme.RemeberMe; import org.maxkey.authn.support.rememberme.RemeberMe;

View File

@ -4,7 +4,10 @@ org.maxkey.autoconfigure.ApplicationAutoConfiguration,\
org.maxkey.autoconfigure.MvcAutoConfiguration,\ org.maxkey.autoconfigure.MvcAutoConfiguration,\
org.maxkey.autoconfigure.KaptchaAutoConfiguration,\ org.maxkey.autoconfigure.KaptchaAutoConfiguration,\
org.maxkey.autoconfigure.RedisAutoConfiguration,\ org.maxkey.autoconfigure.RedisAutoConfiguration,\
org.maxkey.autoconfigure.AuthenticationAutoConfiguration,\ org.maxkey.autoconfigure.AuthnProviderAutoConfiguration,\
org.maxkey.autoconfigure.OneTimePasswordAutoConfiguration,\
org.maxkey.autoconfigure.SessionAutoConfiguration,\
org.maxkey.autoconfigure.TokenAutoConfiguration,\
org.maxkey.autoconfigure.CasAutoConfiguration,\ org.maxkey.autoconfigure.CasAutoConfiguration,\
org.maxkey.autoconfigure.Oauth20AutoConfiguration,\ org.maxkey.autoconfigure.Oauth20AutoConfiguration,\
org.maxkey.autoconfigure.Saml20AutoConfiguration,\ org.maxkey.autoconfigure.Saml20AutoConfiguration,\

View File

@ -11,6 +11,7 @@ dependencies {
implementation project(":maxkey-authentications:maxkey-authentication-core") implementation project(":maxkey-authentications:maxkey-authentication-core")
implementation project(":maxkey-authentications:maxkey-authentication-captcha") implementation project(":maxkey-authentications:maxkey-authentication-captcha")
implementation project(":maxkey-authentications:maxkey-authentication-otp") implementation project(":maxkey-authentications:maxkey-authentication-otp")
implementation project(":maxkey-authentications:maxkey-authentication-provider")
implementation project(":maxkey-protocols:maxkey-protocol-oauth-2.0") implementation project(":maxkey-protocols:maxkey-protocol-oauth-2.0")
implementation project(":maxkey-protocols:maxkey-protocol-saml-2.0") implementation project(":maxkey-protocols:maxkey-protocol-saml-2.0")

View File

@ -19,7 +19,7 @@ package org.maxkey;
import java.util.List; import java.util.List;
import org.maxkey.authn.AbstractAuthenticationProvider; import org.maxkey.authn.provider.AbstractAuthenticationProvider;
import org.maxkey.authn.web.CurrentUserMethodArgumentResolver; import org.maxkey.authn.web.CurrentUserMethodArgumentResolver;
import org.maxkey.authn.web.interceptor.PermissionInterceptor; import org.maxkey.authn.web.interceptor.PermissionInterceptor;
import org.maxkey.configuration.ApplicationConfig; import org.maxkey.configuration.ApplicationConfig;

View File

@ -19,10 +19,10 @@ package org.maxkey.web.contorller;
import java.util.HashMap; import java.util.HashMap;
import org.maxkey.authn.AbstractAuthenticationProvider;
import org.maxkey.authn.LoginCredential; import org.maxkey.authn.LoginCredential;
import org.maxkey.authn.jwt.AuthJwt; import org.maxkey.authn.jwt.AuthJwt;
import org.maxkey.authn.jwt.AuthTokenService; import org.maxkey.authn.jwt.AuthTokenService;
import org.maxkey.authn.provider.AbstractAuthenticationProvider;
import org.maxkey.configuration.ApplicationConfig; import org.maxkey.configuration.ApplicationConfig;
import org.maxkey.entity.Institutions; import org.maxkey.entity.Institutions;
import org.maxkey.entity.Message; import org.maxkey.entity.Message;

View File

@ -5,7 +5,10 @@ org.maxkey.autoconfigure.KaptchaAutoConfiguration,\
org.maxkey.autoconfigure.MvcAutoConfiguration,\ org.maxkey.autoconfigure.MvcAutoConfiguration,\
org.maxkey.autoconfigure.JwtAuthnAutoConfiguration,\ org.maxkey.autoconfigure.JwtAuthnAutoConfiguration,\
org.maxkey.autoconfigure.RedisAutoConfiguration,\ org.maxkey.autoconfigure.RedisAutoConfiguration,\
org.maxkey.autoconfigure.AuthenticationAutoConfiguration,\ org.maxkey.autoconfigure.AuthnProviderAutoConfiguration,\
org.maxkey.autoconfigure.OneTimePasswordAutoConfiguration,\
org.maxkey.autoconfigure.SessionAutoConfiguration,\
org.maxkey.autoconfigure.TokenAutoConfiguration,\
org.maxkey.synchronizer.autoconfigure.SynchronizerAutoConfiguration,\ org.maxkey.synchronizer.autoconfigure.SynchronizerAutoConfiguration,\
org.maxkey.autoconfigure.SwaggerConfig,\ org.maxkey.autoconfigure.SwaggerConfig,\
org.maxkey.Oauth20ClientAutoConfiguration,\ org.maxkey.Oauth20ClientAutoConfiguration,\

View File

@ -30,6 +30,7 @@ include (
'maxkey-authentications:maxkey-authentication-captcha', 'maxkey-authentications:maxkey-authentication-captcha',
'maxkey-authentications:maxkey-authentication-social', 'maxkey-authentications:maxkey-authentication-social',
'maxkey-authentications:maxkey-authentication-otp', 'maxkey-authentications:maxkey-authentication-otp',
'maxkey-authentications:maxkey-authentication-provider',
//identity //identity
'maxkey-identitys:maxkey-identity-scim', 'maxkey-identitys:maxkey-identity-scim',
'maxkey-identitys:maxkey-identity-rest', 'maxkey-identitys:maxkey-identity-rest',