mirror of
https://gitee.com/dromara/MaxKey.git
synced 2025-12-08 09:58:56 +08:00
ldap Context accountMapping
This commit is contained in:
parent
ee8b7536e1
commit
2fe1f9f612
@ -25,5 +25,6 @@ package org.maxkey.authn.realm;
|
|||||||
public interface IAuthenticationServer {
|
public interface IAuthenticationServer {
|
||||||
|
|
||||||
public boolean authenticate(String username, String password);
|
public boolean authenticate(String username, String password);
|
||||||
|
|
||||||
|
public boolean isMapping();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,6 +36,8 @@ public final class ActiveDirectoryServer implements IAuthenticationServer {
|
|||||||
|
|
||||||
String filter;
|
String filter;
|
||||||
|
|
||||||
|
boolean mapping;
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see com.connsec.web.authentication.realm.IAuthenticationServer#authenticate(java.lang.String, java.lang.String)
|
* @see com.connsec.web.authentication.realm.IAuthenticationServer#authenticate(java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
@ -75,4 +77,11 @@ public final class ActiveDirectoryServer implements IAuthenticationServer {
|
|||||||
this.filter = filter;
|
this.filter = filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isMapping() {
|
||||||
|
return mapping;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMapping(boolean mapping) {
|
||||||
|
this.mapping = mapping;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,8 +61,12 @@ public class LdapAuthenticationRealm extends AbstractAuthenticationRealm{
|
|||||||
public boolean passwordMatches(UserInfo userInfo, String password) {
|
public boolean passwordMatches(UserInfo userInfo, String password) {
|
||||||
boolean isAuthenticated=false;
|
boolean isAuthenticated=false;
|
||||||
for (final IAuthenticationServer ldapServer : this.ldapServers) {
|
for (final IAuthenticationServer ldapServer : this.ldapServers) {
|
||||||
_logger.debug("Attempting to authenticate {} at {}", userInfo.getUsername(), ldapServer);
|
String username = userInfo.getUsername();
|
||||||
isAuthenticated= ldapServer.authenticate(userInfo.getUsername(), password);
|
if(ldapServer.isMapping()) {//if ldap Context accountMapping equals YES
|
||||||
|
username = userInfo.getWindowsAccount();
|
||||||
|
}
|
||||||
|
_logger.debug("Attempting to authenticate {} at {}", username, ldapServer);
|
||||||
|
isAuthenticated= ldapServer.authenticate(username, password);
|
||||||
if (isAuthenticated ) {
|
if (isAuthenticated ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -60,6 +60,9 @@ public class LdapAuthenticationRealmService {
|
|||||||
ldapContext.getCredentials(),
|
ldapContext.getCredentials(),
|
||||||
ldapContext.getMsadDomain());
|
ldapContext.getMsadDomain());
|
||||||
ldapServer.setActiveDirectoryUtils(ldapUtils);
|
ldapServer.setActiveDirectoryUtils(ldapUtils);
|
||||||
|
if(ldapContext.getAccountMapping().equalsIgnoreCase("YES")) {
|
||||||
|
ldapServer.setMapping(true);
|
||||||
|
}
|
||||||
ldapAuthenticationServers.add(ldapServer);
|
ldapAuthenticationServers.add(ldapServer);
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
@ -71,6 +74,9 @@ public class LdapAuthenticationRealmService {
|
|||||||
ldapContext.getBasedn());
|
ldapContext.getBasedn());
|
||||||
standardLdapServer.setLdapUtils(ldapUtils);
|
standardLdapServer.setLdapUtils(ldapUtils);
|
||||||
standardLdapServer.setFilterAttribute(ldapContext.getFilters());
|
standardLdapServer.setFilterAttribute(ldapContext.getFilters());
|
||||||
|
if(ldapContext.getAccountMapping().equalsIgnoreCase("YES")) {
|
||||||
|
standardLdapServer.setMapping(true);
|
||||||
|
}
|
||||||
ldapAuthenticationServers.add(standardLdapServer);
|
ldapAuthenticationServers.add(standardLdapServer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,6 +41,8 @@ public final class StandardLdapServer implements IAuthenticationServer {
|
|||||||
|
|
||||||
String filterAttribute;
|
String filterAttribute;
|
||||||
|
|
||||||
|
boolean mapping;
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see com.connsec.web.authentication.realm.IAuthenticationServer#authenticate(java.lang.String, java.lang.String)
|
* @see com.connsec.web.authentication.realm.IAuthenticationServer#authenticate(java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
@ -95,4 +97,12 @@ public final class StandardLdapServer implements IAuthenticationServer {
|
|||||||
this.filterAttribute = filterAttribute;
|
this.filterAttribute = filterAttribute;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isMapping() {
|
||||||
|
return mapping;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMapping(boolean mapping) {
|
||||||
|
this.mapping = mapping;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -54,6 +54,8 @@ public class LdapContext extends JpaBaseEntity implements Serializable {
|
|||||||
@Column
|
@Column
|
||||||
String msadDomain;
|
String msadDomain;
|
||||||
@Column
|
@Column
|
||||||
|
String accountMapping;
|
||||||
|
@Column
|
||||||
String sslSwitch;
|
String sslSwitch;
|
||||||
@Column
|
@Column
|
||||||
String trustStore;
|
String trustStore;
|
||||||
@ -152,6 +154,14 @@ public class LdapContext extends JpaBaseEntity implements Serializable {
|
|||||||
this.sslSwitch = sslSwitch;
|
this.sslSwitch = sslSwitch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getAccountMapping() {
|
||||||
|
return accountMapping;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccountMapping(String accountMapping) {
|
||||||
|
this.accountMapping = accountMapping;
|
||||||
|
}
|
||||||
|
|
||||||
public String getTrustStore() {
|
public String getTrustStore() {
|
||||||
return trustStore;
|
return trustStore;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,12 +32,12 @@ public class MetadataEndpoint {
|
|||||||
|
|
||||||
version.append("---------------------------------------------------------------------------------\n");
|
version.append("---------------------------------------------------------------------------------\n");
|
||||||
version.append("+ JAVA \n");
|
version.append("+ JAVA \n");
|
||||||
version.append(String.format("+ %s java version %s, class %s\n",
|
version.append(String.format("+ %s java version %s, class %s\n",
|
||||||
SystemUtils.JAVA_VENDOR,
|
SystemUtils.JAVA_VENDOR,
|
||||||
SystemUtils.JAVA_VERSION,
|
SystemUtils.JAVA_VERSION,
|
||||||
SystemUtils.JAVA_CLASS_VERSION
|
SystemUtils.JAVA_CLASS_VERSION
|
||||||
));
|
));
|
||||||
version.append(String.format("+ %s (build %s, %s)\n",
|
version.append(String.format("+ %s (build %s, %s)\n",
|
||||||
SystemUtils.JAVA_VM_NAME,
|
SystemUtils.JAVA_VM_NAME,
|
||||||
SystemUtils.JAVA_VM_VERSION,
|
SystemUtils.JAVA_VM_VERSION,
|
||||||
SystemUtils.JAVA_VM_INFO
|
SystemUtils.JAVA_VM_INFO
|
||||||
|
|||||||
@ -531,6 +531,7 @@ ldapcontext.credentials=\u51ED\u8BC1
|
|||||||
ldapcontext.filters=\u8FC7\u6EE4\u5668
|
ldapcontext.filters=\u8FC7\u6EE4\u5668
|
||||||
ldapcontext.basedn=\u57FA\u672CDN
|
ldapcontext.basedn=\u57FA\u672CDN
|
||||||
ldapcontext.msadDomain=Active Directory\u57DF
|
ldapcontext.msadDomain=Active Directory\u57DF
|
||||||
|
ldapcontext.accountMapping=\u8D26\u53F7\u6620\u5C04
|
||||||
ldapcontext.sslSwitch=SSL
|
ldapcontext.sslSwitch=SSL
|
||||||
ldapcontext.trustStore=\u8BC1\u4E66
|
ldapcontext.trustStore=\u8BC1\u4E66
|
||||||
ldapcontext.trustStorePassword=\u8BC1\u4E66\u5BC6\u94A5
|
ldapcontext.trustStorePassword=\u8BC1\u4E66\u5BC6\u94A5
|
||||||
|
|||||||
@ -539,6 +539,7 @@ ldapcontext.credentials=Credentials
|
|||||||
ldapcontext.filters=Filters
|
ldapcontext.filters=Filters
|
||||||
ldapcontext.basedn=Base DN
|
ldapcontext.basedn=Base DN
|
||||||
ldapcontext.msadDomain=Active Directory Domain
|
ldapcontext.msadDomain=Active Directory Domain
|
||||||
|
ldapcontext.accountMapping=Account Mapping
|
||||||
ldapcontext.sslSwitch=SSL
|
ldapcontext.sslSwitch=SSL
|
||||||
ldapcontext.trustStore=TrustStore
|
ldapcontext.trustStore=TrustStore
|
||||||
ldapcontext.trustStorePassword=TrustStorePassword
|
ldapcontext.trustStorePassword=TrustStorePassword
|
||||||
|
|||||||
@ -530,6 +530,7 @@ ldapcontext.credentials=\u51ED\u8BC1
|
|||||||
ldapcontext.filters=\u8FC7\u6EE4\u5668
|
ldapcontext.filters=\u8FC7\u6EE4\u5668
|
||||||
ldapcontext.basedn=\u57FA\u672CDN
|
ldapcontext.basedn=\u57FA\u672CDN
|
||||||
ldapcontext.msadDomain=Active Directory\u57DF
|
ldapcontext.msadDomain=Active Directory\u57DF
|
||||||
|
ldapcontext.accountMapping=\u8D26\u53F7\u6620\u5C04
|
||||||
ldapcontext.sslSwitch=SSL
|
ldapcontext.sslSwitch=SSL
|
||||||
ldapcontext.trustStore=\u8BC1\u4E66
|
ldapcontext.trustStore=\u8BC1\u4E66
|
||||||
ldapcontext.trustStorePassword=\u8BC1\u4E66\u5BC6\u94A5
|
ldapcontext.trustStorePassword=\u8BC1\u4E66\u5BC6\u94A5
|
||||||
|
|||||||
@ -67,9 +67,26 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
<label class="col-md-2 col-form-label"><@locale code="ldapcontext.providerUrl" /></label>
|
<div class="col-md-6">
|
||||||
<div class="col-md-10">
|
<div class="form-group row">
|
||||||
<input required="" class="form-control" type="text" id="providerUrl" name="providerUrl" value="${model.providerUrl!}" />
|
<label class="col-sm-3 col-form-label"><@locale code="ldapcontext.providerUrl" /></label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input required="" class="form-control" type="text" id="providerUrl" name="providerUrl" value="${model.providerUrl!}" />
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="form-group row">
|
||||||
|
<label class="col-sm-3 col-form-label"><@locale code="ldapcontext.accountMapping" /></label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<select id="accountMapping" name="accountMapping" class="form-control form-select">
|
||||||
|
<option value="YES" <#if 'YES'==model.accountMapping>selected</#if> ><@locale code="common.text.yes" /></option>
|
||||||
|
<option value="NO" <#if 'NO'==model.accountMapping>selected</#if> ><@locale code="common.text.no" /></option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user