代码优化

This commit is contained in:
shimingxy 2025-04-21 10:35:05 +08:00
parent fdd4501d13
commit 243b546a9a
7 changed files with 40 additions and 17 deletions

View File

@ -30,13 +30,6 @@ public class Session implements Serializable{
public static final int MAX_EXPIRY_DURATION = 60 * 5; //default 5 minutes. public static final int MAX_EXPIRY_DURATION = 60 * 5; //default 5 minutes.
public class CATEGORY{
public static final int SIGN = 1;
public static final int MGMT = 5;
}
public String id; public String id;
public LocalDateTime startTimestamp; public LocalDateTime startTimestamp;

View File

@ -0,0 +1,30 @@
/*
* Copyright [2025] [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.dromara.maxkey.authn.session;
public class SessionCategory {
/**
* 认证端
*/
public static final int SIGN = 1;
/**
* 管理端
*/
public static final int MGMT = 5;
}

View File

@ -22,7 +22,7 @@ import java.util.List;
import org.dromara.maxkey.authn.SignPrincipal; import org.dromara.maxkey.authn.SignPrincipal;
import org.dromara.maxkey.authn.realm.ldap.LdapAuthenticationRealmService; import org.dromara.maxkey.authn.realm.ldap.LdapAuthenticationRealmService;
import org.dromara.maxkey.authn.session.Session.CATEGORY; import org.dromara.maxkey.authn.session.SessionCategory;
import org.dromara.maxkey.entity.history.HistoryLogin; import org.dromara.maxkey.entity.history.HistoryLogin;
import org.dromara.maxkey.entity.idm.Groups; import org.dromara.maxkey.entity.idm.Groups;
import org.dromara.maxkey.entity.idm.UserInfo; import org.dromara.maxkey.entity.idm.UserInfo;
@ -149,7 +149,7 @@ public abstract class AbstractAuthenticationRealm {
historyLogin.setUsername(userInfo.getUsername()); historyLogin.setUsername(userInfo.getUsername());
historyLogin.setDisplayName(userInfo.getDisplayName()); historyLogin.setDisplayName(userInfo.getDisplayName());
historyLogin.setInstId(userInfo.getInstId()); historyLogin.setInstId(userInfo.getInstId());
historyLogin.setCategory(CATEGORY.MGMT); historyLogin.setCategory(SessionCategory.MGMT);
Region ipRegion =ipLocationParser.region(userInfo.getLastLoginIp()); Region ipRegion =ipLocationParser.region(userInfo.getLastLoginIp());
if(ipRegion != null) { if(ipRegion != null) {

View File

@ -22,7 +22,7 @@ import java.util.List;
import org.dromara.maxkey.authn.SignPrincipal; import org.dromara.maxkey.authn.SignPrincipal;
import org.dromara.maxkey.authn.realm.ldap.LdapAuthenticationRealmService; import org.dromara.maxkey.authn.realm.ldap.LdapAuthenticationRealmService;
import org.dromara.maxkey.authn.session.Session.CATEGORY; import org.dromara.maxkey.authn.session.SessionCategory;
import org.dromara.maxkey.entity.history.HistoryLogin; import org.dromara.maxkey.entity.history.HistoryLogin;
import org.dromara.maxkey.entity.idm.Groups; import org.dromara.maxkey.entity.idm.Groups;
import org.dromara.maxkey.entity.idm.UserInfo; import org.dromara.maxkey.entity.idm.UserInfo;
@ -149,7 +149,7 @@ public abstract class AbstractAuthenticationRealm {
historyLogin.setUsername(userInfo.getUsername()); historyLogin.setUsername(userInfo.getUsername());
historyLogin.setDisplayName(userInfo.getDisplayName()); historyLogin.setDisplayName(userInfo.getDisplayName());
historyLogin.setInstId(userInfo.getInstId()); historyLogin.setInstId(userInfo.getInstId());
historyLogin.setCategory(CATEGORY.SIGN); historyLogin.setCategory(SessionCategory.SIGN);
Region ipRegion =ipLocationParser.region(userInfo.getLastLoginIp()); Region ipRegion =ipLocationParser.region(userInfo.getLastLoginIp());
if(ipRegion != null) { if(ipRegion != null) {

View File

@ -27,7 +27,7 @@ export const environment = {
production: false, production: false,
useHash: true, useHash: true,
api: { api: {
baseUrl: 'http://localhost:9527/sign/', baseUrl: 'http://sso.maxkey.top/sign/',
// baseUrl: '/sign/', // baseUrl: '/sign/',
refreshTokenEnabled: true, refreshTokenEnabled: true,
refreshTokenType: 're-request' refreshTokenType: 're-request'

View File

@ -27,7 +27,7 @@ import java.util.stream.Collectors;
import org.dromara.maxkey.authn.listener.SessionListenerAdapter; import org.dromara.maxkey.authn.listener.SessionListenerAdapter;
import org.dromara.maxkey.authn.realm.jdbc.JdbcAuthenticationRealm; import org.dromara.maxkey.authn.realm.jdbc.JdbcAuthenticationRealm;
import org.dromara.maxkey.authn.realm.ldap.LdapAuthenticationRealmService; import org.dromara.maxkey.authn.realm.ldap.LdapAuthenticationRealmService;
import org.dromara.maxkey.authn.session.Session.CATEGORY; import org.dromara.maxkey.authn.session.SessionCategory;
import org.dromara.maxkey.authn.session.SessionManager; import org.dromara.maxkey.authn.session.SessionManager;
import org.dromara.maxkey.authn.support.kerberos.KerberosProxy; import org.dromara.maxkey.authn.support.kerberos.KerberosProxy;
import org.dromara.maxkey.authn.support.kerberos.RemoteKerberosService; import org.dromara.maxkey.authn.support.kerberos.RemoteKerberosService;
@ -212,7 +212,7 @@ public class MaxKeyConfig {
.setCron("0 0/10 * * * ?") .setCron("0 0/10 * * * ?")
.setJobClass(SessionListenerAdapter.class) .setJobClass(SessionListenerAdapter.class)
.setJobData("sessionManager",sessionManager) .setJobData("sessionManager",sessionManager)
.setJobData("category", CATEGORY.SIGN) .setJobData("category", SessionCategory.SIGN)
.build(); .build();
logger.debug("Session ListenerAdapter inited ."); logger.debug("Session ListenerAdapter inited .");
} }

View File

@ -18,7 +18,7 @@
package org.dromara.maxkey.autoconfigure; package org.dromara.maxkey.autoconfigure;
import org.dromara.maxkey.authn.listener.SessionListenerAdapter; import org.dromara.maxkey.authn.listener.SessionListenerAdapter;
import org.dromara.maxkey.authn.session.Session.CATEGORY; import org.dromara.maxkey.authn.session.SessionCategory;
import org.dromara.maxkey.authn.session.SessionManager; import org.dromara.maxkey.authn.session.SessionManager;
import org.dromara.maxkey.configuration.ApplicationConfig; import org.dromara.maxkey.configuration.ApplicationConfig;
import org.dromara.maxkey.listener.DynamicGroupsListenerAdapter; import org.dromara.maxkey.listener.DynamicGroupsListenerAdapter;
@ -53,7 +53,7 @@ public class MaxKeyMgtListenerConfig {
.setCron("0 0/10 * * * ?") .setCron("0 0/10 * * * ?")
.setJobClass(SessionListenerAdapter.class) .setJobClass(SessionListenerAdapter.class)
.setJobData("sessionManager",sessionManager) .setJobData("sessionManager",sessionManager)
.setJobData("category", CATEGORY.MGMT) .setJobData("category", SessionCategory.MGMT)
.build(); .build();
logger.debug("Session ListenerAdapter inited ."); logger.debug("Session ListenerAdapter inited .");
return "sessionListenerAdapter"; return "sessionListenerAdapter";