mgt sso
This commit is contained in:
shimingxy
2019-12-02 11:55:20 +08:00
parent 40bef5723d
commit c1a82ab45b
7 changed files with 50 additions and 56 deletions

View File

@@ -93,27 +93,27 @@ public class InitApplicationContext extends HttpServlet {
public void listDataBaseVariables(){ public void listDataBaseVariables(){
if(applicationContext.containsBean("dataSource")){ if(applicationContext.containsBean("dataSource")){
try { try {
_logger.info("----------------------------------------------------------------------------------------------------"); _logger.debug("----------------------------------------------------------------------------------------------------");
_logger.info("List DatabaseMetaData Variables "); _logger.debug("List DatabaseMetaData Variables ");
Connection connection = ((javax.sql.DataSource)applicationContext.getBean("dataSource")).getConnection(); Connection connection = ((javax.sql.DataSource)applicationContext.getBean("dataSource")).getConnection();
java.sql.DatabaseMetaData databaseMetaData = connection.getMetaData(); java.sql.DatabaseMetaData databaseMetaData = connection.getMetaData();
_logger.info("DatabaseProductName : " + databaseMetaData.getDatabaseProductName()); _logger.debug("DatabaseProductName : " + databaseMetaData.getDatabaseProductName());
_logger.info("DatabaseProductVersion: " + databaseMetaData.getDatabaseProductVersion()); _logger.debug("DatabaseProductVersion: " + databaseMetaData.getDatabaseProductVersion());
_logger.info("DatabaseMajorVersion : " + databaseMetaData.getDatabaseMajorVersion()); _logger.debug("DatabaseMajorVersion : " + databaseMetaData.getDatabaseMajorVersion());
_logger.info("DatabaseMinorVersion : " + databaseMetaData.getDatabaseMinorVersion()); _logger.debug("DatabaseMinorVersion : " + databaseMetaData.getDatabaseMinorVersion());
_logger.info("supportsTransactions : " + databaseMetaData.supportsTransactions()); _logger.debug("supportsTransactions : " + databaseMetaData.supportsTransactions());
_logger.info("DefaultTransaction : " + databaseMetaData.getDefaultTransactionIsolation()); _logger.debug("DefaultTransaction : " + databaseMetaData.getDefaultTransactionIsolation());
_logger.info("MaxConnections : " + databaseMetaData.getMaxConnections()); _logger.debug("MaxConnections : " + databaseMetaData.getMaxConnections());
_logger.info(""); _logger.debug("");
_logger.info("JDBCMajorVersion : " + databaseMetaData.getJDBCMajorVersion()); _logger.debug("JDBCMajorVersion : " + databaseMetaData.getJDBCMajorVersion());
_logger.info("JDBCMinorVersion : " + databaseMetaData.getJDBCMinorVersion()); _logger.debug("JDBCMinorVersion : " + databaseMetaData.getJDBCMinorVersion());
_logger.info("DriverName : " + databaseMetaData.getDriverName()); _logger.debug("DriverName : " + databaseMetaData.getDriverName());
_logger.info("DriverVersion : " + databaseMetaData.getDriverVersion()); _logger.debug("DriverVersion : " + databaseMetaData.getDriverVersion());
_logger.info(""); _logger.debug("");
_logger.info("DBMS URL : " + databaseMetaData.getURL()); _logger.debug("DBMS URL : " + databaseMetaData.getURL());
_logger.info("UserName : " + databaseMetaData.getUserName()); _logger.debug("UserName : " + databaseMetaData.getUserName());
_logger.info("----------------------------------------------------------------------------------------------------"); _logger.debug("----------------------------------------------------------------------------------------------------");
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -123,8 +123,8 @@ public class InitApplicationContext extends HttpServlet {
//propertySourcesPlaceholderConfigurer //propertySourcesPlaceholderConfigurer
public void listProperties(){ public void listProperties(){
if(applicationContext.containsBean("propertySourcesPlaceholderConfigurer")){ if(applicationContext.containsBean("propertySourcesPlaceholderConfigurer")){
_logger.info("----------------------------------------------------------------------------------------------------"); _logger.debug("----------------------------------------------------------------------------------------------------");
_logger.info("List Properties Variables "); _logger.debug("List Properties Variables ");
PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = ((PropertySourcesPlaceholderConfigurer)applicationContext.getBean("propertySourcesPlaceholderConfigurer")); PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = ((PropertySourcesPlaceholderConfigurer)applicationContext.getBean("propertySourcesPlaceholderConfigurer"));
Properties properties=(Properties)propertySourcesPlaceholderConfigurer.getAppliedPropertySources().get(PropertySourcesPlaceholderConfigurer.LOCAL_PROPERTIES_PROPERTY_SOURCE_NAME).getSource(); Properties properties=(Properties)propertySourcesPlaceholderConfigurer.getAppliedPropertySources().get(PropertySourcesPlaceholderConfigurer.LOCAL_PROPERTIES_PROPERTY_SOURCE_NAME).getSource();
Set<Object> keyValue = properties.keySet(); Set<Object> keyValue = properties.keySet();
@@ -137,15 +137,15 @@ public class InitApplicationContext extends HttpServlet {
//out //out
for (Iterator<String> it = keyValueSet.iterator(); it.hasNext();){ for (Iterator<String> it = keyValueSet.iterator(); it.hasNext();){
String key = (String) it.next(); String key = (String) it.next();
_logger.info(key + " = " + properties.get(key)); _logger.debug(key + " = " + properties.get(key));
} }
_logger.info("----------------------------------------------------------------------------------------------------"); _logger.debug("----------------------------------------------------------------------------------------------------");
} }
} }
public void listEnvVars() { public void listEnvVars() {
_logger.info("----------------------------------------------------------------------------------------------------"); _logger.debug("----------------------------------------------------------------------------------------------------");
_logger.info("List Environment Variables "); _logger.debug("List Environment Variables ");
Map<String, String> map = System.getenv(); Map<String, String> map = System.getenv();
SortedSet<String> keyValueSet = new TreeSet<String>(); SortedSet<String> keyValueSet = new TreeSet<String>();
for (Iterator<String> itr = map.keySet().iterator(); itr.hasNext();) { for (Iterator<String> itr = map.keySet().iterator(); itr.hasNext();) {
@@ -155,10 +155,10 @@ public class InitApplicationContext extends HttpServlet {
// out // out
for (Iterator<String> it = keyValueSet.iterator(); it.hasNext();) { for (Iterator<String> it = keyValueSet.iterator(); it.hasNext();) {
String key = (String) it.next(); String key = (String) it.next();
_logger.info(key + " = " + map.get(key)); _logger.debug(key + " = " + map.get(key));
} }
_logger.info("APP_HOME" + " = " + PathUtils.getInstance().getAppPath()); _logger.debug("APP_HOME" + " = " + PathUtils.getInstance().getAppPath());
_logger.info("----------------------------------------------------------------------------------------------------"); _logger.debug("----------------------------------------------------------------------------------------------------");
} }
public void showLicense(){ public void showLicense(){

View File

@@ -99,6 +99,9 @@ public class LoginEndpoint {
}else { }else {
WebContext.setAttribute(WebConstants.SPRING_PROCESS_SAVED_REQUEST, firstSavedRequest); WebContext.setAttribute(WebConstants.SPRING_PROCESS_SAVED_REQUEST, firstSavedRequest);
} }
if(WebContext.isAuthenticated()){
return WebContext.redirect("/main");
}
modelAndView.setViewName("login"); modelAndView.setViewName("login");
return modelAndView; return modelAndView;
} }
@@ -106,11 +109,10 @@ public class LoginEndpoint {
@RequestMapping(value={"/logon.do"}) @RequestMapping(value={"/logon.do"})
public ModelAndView logon(@ModelAttribute("authentication") BasicAuthentication authentication) { public ModelAndView logon(@ModelAttribute("authentication") BasicAuthentication authentication) {
authenticationProvider.authenticate(authentication);
if(WebContext.isAuthenticated()){ if(WebContext.isAuthenticated()){
return WebContext.redirect("/main"); return WebContext.redirect("/main");
}else{ }else{
authenticationProvider.authenticate(authentication);
return WebContext.redirect("/login"); return WebContext.redirect("/login");
} }
} }

View File

@@ -91,7 +91,7 @@ config.support.wsfederation.logoutUrl=https://adfs.connsec.com/adfs/ls/?wa=wsign
############################################################################# #############################################################################
############################################################################# #############################################################################
config.oidc.metadata.issuer=${config.server.maxkey.uri} config.oidc.metadata.issuer=${config.server.name}/maxkey
config.oidc.metadata.authorizationEndpoint=${config.server.maxkey.uri}/oauth/v20/authorize config.oidc.metadata.authorizationEndpoint=${config.server.maxkey.uri}/oauth/v20/authorize
config.oidc.metadata.tokenEndpoint=${config.server.maxkey.uri}/oauth/v20/token config.oidc.metadata.tokenEndpoint=${config.server.maxkey.uri}/oauth/v20/token
config.oidc.metadata.userinfoEndpoint=${config.server.maxkey.uri}/api/connect/userinfo config.oidc.metadata.userinfoEndpoint=${config.server.maxkey.uri}/api/connect/userinfo

View File

@@ -38,15 +38,15 @@
<bean id="jwtSignerValidationService" class="org.maxkey.crypto.jwt.signer.service.impl.DefaultJwtSigningAndValidationService"> <bean id="jwtSignerValidationService" class="org.maxkey.crypto.jwt.signer.service.impl.DefaultJwtSigningAndValidationService">
<constructor-arg name="keyStore" ref="jwkSetKeyStore" /> <constructor-arg name="keyStore" ref="jwkSetKeyStore" />
<property name="defaultSignerKeyId" value="connsec_rsa" /> <property name="defaultSignerKeyId" value="maxkey_rsa" />
<property name="defaultSigningAlgorithmName" value="RS256" /> <property name="defaultSigningAlgorithmName" value="RS256" />
</bean> </bean>
<bean id="jwtEncryptionService" class="org.maxkey.crypto.jwt.encryption.service.impl.DefaultJwtEncryptionAndDecryptionService"> <bean id="jwtEncryptionService" class="org.maxkey.crypto.jwt.encryption.service.impl.DefaultJwtEncryptionAndDecryptionService">
<constructor-arg name="keyStore" ref="jwkSetKeyStore" /> <constructor-arg name="keyStore" ref="jwkSetKeyStore" />
<property name="defaultAlgorithm" value="RSA1_5" /> <property name="defaultAlgorithm" value="RSA1_5" />
<property name="defaultDecryptionKeyId" value="connsec_rsa" /> <property name="defaultDecryptionKeyId" value="maxkey_rsa" />
<property name="defaultEncryptionKeyId" value="connsec_rsa" /> <property name="defaultEncryptionKeyId" value="maxkey_rsa" />
</bean> </bean>
<bean id="jwtLoginService" class="org.maxkey.authn.support.jwt.JwtLoginService"> <bean id="jwtLoginService" class="org.maxkey.authn.support.jwt.JwtLoginService">
@@ -105,8 +105,8 @@
<bean id="timeBasedKeyUriFormat" class="org.maxkey.crypto.password.opt.algorithm.KeyUriFormat"> <bean id="timeBasedKeyUriFormat" class="org.maxkey.crypto.password.opt.algorithm.KeyUriFormat">
<property name="type" value="totp" /> <property name="type" value="totp" />
<property name="digits" value="6" /> <property name="digits" value="6" />
<property name="issuer" value="ConnSec" /> <property name="issuer" value="maxkey" />
<property name="domain" value="connsec.com" /> <property name="domain" value="maxkey.org" />
<property name="period" value="30" /> <property name="period" value="30" />
</bean> </bean>

View File

@@ -36,7 +36,7 @@
</a> </a>
</td> </td>
<td id="manage" nowrap> <td id="manage" nowrap>
<a target="_blank" href="<@base/>/authz/manage"> <a target="_blank" href="<@base/>/authz/maxkey_mgt">
<div style="float:right;" >&nbsp;&nbsp;<@locale code="global.text.manage"/>&nbsp;&nbsp;</div> <div style="float:right;" >&nbsp;&nbsp;<@locale code="global.text.manage"/>&nbsp;&nbsp;</div>
</a> </a>
</td> </td>

View File

@@ -18,7 +18,7 @@
<div> <div>
<form method="post" type="label" autoclose="true" action="<@base/>/safe/changeExpiredPassword"> <form method="post" type="label" autoclose="true" action="<@base/>/safe/changeExpiredPassword">
<table class="datatable" > <table class="table table-bordered" >
<tbody> <tbody>
<tr> <tr>
<th colspan="2"><@locale code="login.password.expired.tip" /></th> <th colspan="2"><@locale code="login.password.expired.tip" /></th>
@@ -26,37 +26,33 @@
<tr> <tr>
<th><@locale code="userinfo.displayName" /> :</th> <th><@locale code="userinfo.displayName" /> :</th>
<td> <td>
<input readonly type="text" id="displayName" name="displayName" class="required" title="" value="${model.displayName}"/> <input readonly type="text" id="displayName" name="displayName" class="form-control" title="" value="${model.displayName}"/>
</td> </td>
</tr> </tr>
<tr> <tr>
<th><@locale code="userinfo.username" /> :</th> <th><@locale code="userinfo.username" /> :</th>
<td> <td>
<input readonly type="text" id="username" name="username" class="required" title="" value="${model.username}"/> <input readonly type="text" id="username" name="username" class="form-control" title="" value="${model.username}"/>
</td> </td>
</tr> </tr>
<tr> <tr>
<th><@locale code="login.password.newPassword" />:</th> <th><@locale code="login.password.newPassword" />:</th>
<td> <td>
<input type="password" id="newPassword" name="newPassword" class=" required" title="" value=""/> <input type="password" id="newPassword" name="newPassword" class="form-control" title="" value=""/>
<b class="orange">*</b>
<label for="newPassword"></label>
</td> </td>
</tr> </tr>
<tr> <tr>
<th><@locale code="login.password.confirmPassword" />:</th> <th><@locale code="login.password.confirmPassword" />:</th>
<td nowrap> <td nowrap>
<input type="password" id="confirmPassword" name="confirmPassword" class="{ required: true, equalTo: '#newPassword' }" title="" value=""/> <input type="password" id="confirmPassword" name="confirmPassword" class="form-control" title="" value=""/>
<b class="orange">*</b>
<label for="confirmPassword"></label>
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2" class="center"> <td colspan="2" class="center">
<input id="_method" type="hidden" name="_method" value="post"/> <input id="_method" type="hidden" name="_method" value="post"/>
<input class="button" style="width:100px" type="submit" id="submitBtn" value="<@locale code="button.text.save" />"/> <input class="button btn btn-lg btn-primary" style="width:100px" type="submit" id="submitBtn" value="<@locale code="button.text.save" />"/>
</td> </td>
</tr> </tr>

View File

@@ -18,7 +18,7 @@
<form method="post" type="label" autoclose="true" action="<@base/>/safe/changeInitPassword"> <form method="post" type="label" autoclose="true" action="<@base/>/safe/changeInitPassword">
<table class="datatable" > <table class="table table-bordered" >
<tbody> <tbody>
<tr> <tr>
<th colspan="2"><@locale code="login.password.initial.change.tip" /></th> <th colspan="2"><@locale code="login.password.initial.change.tip" /></th>
@@ -26,37 +26,33 @@
<tr> <tr>
<th><@locale code="userinfo.displayName" /> :</th> <th><@locale code="userinfo.displayName" /> :</th>
<td> <td>
<input readonly type="text" id="displayName" name="displayName" class="required" title="" value="${model.displayName}"/> <input readonly type="text" id="displayName" name="displayName" class="form-control" title="" value="${model.displayName}"/>
</td> </td>
</tr> </tr>
<tr> <tr>
<th><@locale code="userinfo.username" /> :</th> <th><@locale code="userinfo.username" /> :</th>
<td> <td>
<input readonly type="text" id="username" name="username" class="required" title="" value="${model.username}"/> <input readonly type="text" id="username" name="username" class="form-control" title="" value="${model.username}"/>
</td> </td>
</tr> </tr>
<tr> <tr>
<th><@locale code="login.password.newPassword" />:</th> <th><@locale code="login.password.newPassword" />:</th>
<td> <td>
<input type="password" id="newPassword" name="newPassword" class=" required" title="" value=""/> <input type="password" id="newPassword" name="newPassword" class="form-control" title="" value=""/>
<b class="orange">*</b>
<label for="newPassword"></label>
</td> </td>
</tr> </tr>
<tr> <tr>
<th><@locale code="login.password.confirmPassword" />:</th> <th><@locale code="login.password.confirmPassword" />:</th>
<td nowrap> <td nowrap>
<input type="password" id="confirmPassword" name="confirmPassword" class="{ required: true, equalTo: '#newPassword' }" title="" value=""/> <input type="password" id="confirmPassword" name="confirmPassword" class="form-control" title="" value=""/>
<b class="orange">*</b>
<label for="confirmPassword"></label>
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2" class="center"> <td colspan="2" class="center">
<input id="_method" type="hidden" name="_method" value="post"/> <input id="_method" type="hidden" name="_method" value="post"/>
<input class="button" style="width:100px" type="submit" id="submitBtn" value=" code="button.text.save" />"/> <input class="button btn btn-lg btn-primaryk" style="width:100px" type="submit" id="submitBtn" value=" code="button.text.save" />"/>
</td> </td>
</tr> </tr>