Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
superrain51
apollo
提交
1a5db6c5
apollo
项目概览
superrain51
/
apollo
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
apollo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1a5db6c5
编写于
6月 20, 2019
作者:
idefav
提交者:
Jason Song
6月 20, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix ldap userId with case problem (#2326)
fix ldap userId with case problem
上级
3bfed3c8
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
213 addition
and
111 deletion
+213
-111
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/AuthConfiguration.java
...rk/apollo/portal/spi/configuration/AuthConfiguration.java
+5
-3
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/LdapExtendProperties.java
...apollo/portal/spi/configuration/LdapExtendProperties.java
+0
-108
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/LdapGroupProperties.java
.../apollo/portal/spi/configuration/LdapGroupProperties.java
+50
-0
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/LdapMappingProperties.java
...pollo/portal/spi/configuration/LdapMappingProperties.java
+76
-0
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/ldap/ApolloLdapAuthenticationProvider.java
...llo/portal/spi/ldap/ApolloLdapAuthenticationProvider.java
+82
-0
未找到文件。
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/AuthConfiguration.java
浏览文件 @
1a5db6c5
...
...
@@ -15,6 +15,7 @@ import com.ctrip.framework.apollo.portal.spi.defaultimpl.DefaultLogoutHandler;
import
com.ctrip.framework.apollo.portal.spi.defaultimpl.DefaultSsoHeartbeatHandler
;
import
com.ctrip.framework.apollo.portal.spi.defaultimpl.DefaultUserInfoHolder
;
import
com.ctrip.framework.apollo.portal.spi.defaultimpl.DefaultUserService
;
import
com.ctrip.framework.apollo.portal.spi.ldap.ApolloLdapAuthenticationProvider
;
import
com.ctrip.framework.apollo.portal.spi.ldap.FilterLdapByGroupUserSearch
;
import
com.ctrip.framework.apollo.portal.spi.ldap.LdapUserService
;
import
com.ctrip.framework.apollo.portal.spi.springsecurity.SpringSecurityUserInfoHolder
;
...
...
@@ -392,9 +393,10 @@ public class AuthConfiguration {
ldapContextSource
,
null
);
defaultAuthAutoConfiguration
.
setIgnorePartialResultException
(
true
);
defaultAuthAutoConfiguration
.
setSearchSubtree
(
true
);
LdapAuthenticationProvider
ldapAuthenticationProvider
=
new
LdapAuthenticationProvider
(
bindAuthenticator
,
defaultAuthAutoConfiguration
);
return
ldapAuthenticationProvider
;
// Rewrite the logic of LdapAuthenticationProvider with ApolloLdapAuthenticationProvider,
// use userId in LDAP system instead of userId input by user.
return
new
ApolloLdapAuthenticationProvider
(
bindAuthenticator
,
defaultAuthAutoConfiguration
,
ldapExtendProperties
);
}
@Override
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/LdapExtendProperties.java
浏览文件 @
1a5db6c5
...
...
@@ -33,111 +33,3 @@ public class LdapExtendProperties {
this
.
group
=
group
;
}
}
class
LdapMappingProperties
{
/**
* user ldap objectClass
*/
private
String
objectClass
;
/**
* user login Id
*/
private
String
loginId
;
/**
* user rdn key
*/
private
String
rdnKey
;
/**
* user display name
*/
private
String
userDisplayName
;
/**
* email
*/
private
String
email
;
public
String
getObjectClass
()
{
return
objectClass
;
}
public
void
setObjectClass
(
String
objectClass
)
{
this
.
objectClass
=
objectClass
;
}
public
String
getLoginId
()
{
return
loginId
;
}
public
void
setLoginId
(
String
loginId
)
{
this
.
loginId
=
loginId
;
}
public
String
getRdnKey
()
{
return
rdnKey
;
}
public
void
setRdnKey
(
String
rdnKey
)
{
this
.
rdnKey
=
rdnKey
;
}
public
String
getUserDisplayName
()
{
return
userDisplayName
;
}
public
void
setUserDisplayName
(
String
userDisplayName
)
{
this
.
userDisplayName
=
userDisplayName
;
}
public
String
getEmail
()
{
return
email
;
}
public
void
setEmail
(
String
email
)
{
this
.
email
=
email
;
}
}
class
LdapGroupProperties
{
/**
* group search base
*/
private
String
groupBase
;
/**
* group search filter
*/
private
String
groupSearch
;
/**
* group membership prop
*/
private
String
groupMembership
;
public
String
getGroupBase
()
{
return
groupBase
;
}
public
void
setGroupBase
(
String
groupBase
)
{
this
.
groupBase
=
groupBase
;
}
public
String
getGroupSearch
()
{
return
groupSearch
;
}
public
void
setGroupSearch
(
String
groupSearch
)
{
this
.
groupSearch
=
groupSearch
;
}
public
String
getGroupMembership
()
{
return
groupMembership
;
}
public
void
setGroupMembership
(
String
groupMembership
)
{
this
.
groupMembership
=
groupMembership
;
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/LdapGroupProperties.java
0 → 100644
浏览文件 @
1a5db6c5
package
com.ctrip.framework.apollo.portal.spi.configuration
;
/**
* the LdapGroupProperties description.
*
* @author wuzishu
*/
public
class
LdapGroupProperties
{
/**
* group search base
*/
private
String
groupBase
;
/**
* group search filter
*/
private
String
groupSearch
;
/**
* group membership prop
*/
private
String
groupMembership
;
public
String
getGroupBase
()
{
return
groupBase
;
}
public
void
setGroupBase
(
String
groupBase
)
{
this
.
groupBase
=
groupBase
;
}
public
String
getGroupSearch
()
{
return
groupSearch
;
}
public
void
setGroupSearch
(
String
groupSearch
)
{
this
.
groupSearch
=
groupSearch
;
}
public
String
getGroupMembership
()
{
return
groupMembership
;
}
public
void
setGroupMembership
(
String
groupMembership
)
{
this
.
groupMembership
=
groupMembership
;
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/configuration/LdapMappingProperties.java
0 → 100644
浏览文件 @
1a5db6c5
package
com.ctrip.framework.apollo.portal.spi.configuration
;
/**
* the LdapMappingProperties description.
*
* @author wuzishu
*/
public
class
LdapMappingProperties
{
/**
* user ldap objectClass
*/
private
String
objectClass
;
/**
* user login Id
*/
private
String
loginId
;
/**
* user rdn key
*/
private
String
rdnKey
;
/**
* user display name
*/
private
String
userDisplayName
;
/**
* email
*/
private
String
email
;
public
String
getObjectClass
()
{
return
objectClass
;
}
public
void
setObjectClass
(
String
objectClass
)
{
this
.
objectClass
=
objectClass
;
}
public
String
getLoginId
()
{
return
loginId
;
}
public
void
setLoginId
(
String
loginId
)
{
this
.
loginId
=
loginId
;
}
public
String
getRdnKey
()
{
return
rdnKey
;
}
public
void
setRdnKey
(
String
rdnKey
)
{
this
.
rdnKey
=
rdnKey
;
}
public
String
getUserDisplayName
()
{
return
userDisplayName
;
}
public
void
setUserDisplayName
(
String
userDisplayName
)
{
this
.
userDisplayName
=
userDisplayName
;
}
public
String
getEmail
()
{
return
email
;
}
public
void
setEmail
(
String
email
)
{
this
.
email
=
email
;
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/ldap/ApolloLdapAuthenticationProvider.java
0 → 100644
浏览文件 @
1a5db6c5
package
com.ctrip.framework.apollo.portal.spi.ldap
;
import
com.ctrip.framework.apollo.portal.spi.configuration.LdapExtendProperties
;
import
org.springframework.ldap.core.DirContextOperations
;
import
org.springframework.security.authentication.BadCredentialsException
;
import
org.springframework.security.authentication.UsernamePasswordAuthenticationToken
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.security.core.AuthenticationException
;
import
org.springframework.security.core.userdetails.UserDetails
;
import
org.springframework.security.ldap.authentication.LdapAuthenticationProvider
;
import
org.springframework.security.ldap.authentication.LdapAuthenticator
;
import
org.springframework.security.ldap.userdetails.LdapAuthoritiesPopulator
;
import
org.springframework.util.Assert
;
import
org.springframework.util.StringUtils
;
/**
* Inherited from LdapAuthenticationProvider and rewritten the authenticate method,
* modified the userId used by the previous user input,
* changed to use the userId in the LDAP system.
*
* @author wuzishu
*/
public
class
ApolloLdapAuthenticationProvider
extends
LdapAuthenticationProvider
{
private
LdapExtendProperties
properties
;
public
ApolloLdapAuthenticationProvider
(
LdapAuthenticator
authenticator
,
LdapAuthoritiesPopulator
authoritiesPopulator
)
{
super
(
authenticator
,
authoritiesPopulator
);
}
public
ApolloLdapAuthenticationProvider
(
LdapAuthenticator
authenticator
)
{
super
(
authenticator
);
}
public
ApolloLdapAuthenticationProvider
(
LdapAuthenticator
authenticator
,
LdapAuthoritiesPopulator
authoritiesPopulator
,
LdapExtendProperties
properties
)
{
super
(
authenticator
,
authoritiesPopulator
);
this
.
properties
=
properties
;
}
public
ApolloLdapAuthenticationProvider
(
LdapAuthenticator
authenticator
,
LdapExtendProperties
properties
)
{
super
(
authenticator
);
this
.
properties
=
properties
;
}
@Override
public
Authentication
authenticate
(
Authentication
authentication
)
throws
AuthenticationException
{
Assert
.
isInstanceOf
(
UsernamePasswordAuthenticationToken
.
class
,
authentication
,
this
.
messages
.
getMessage
(
"LdapAuthenticationProvider.onlySupports"
,
"Only UsernamePasswordAuthenticationToken is supported"
));
UsernamePasswordAuthenticationToken
userToken
=
(
UsernamePasswordAuthenticationToken
)
authentication
;
String
username
=
userToken
.
getName
();
String
password
=
(
String
)
authentication
.
getCredentials
();
if
(
this
.
logger
.
isDebugEnabled
())
{
this
.
logger
.
debug
(
"Processing authentication request for user: "
+
username
);
}
if
(!
StringUtils
.
hasLength
(
username
))
{
throw
new
BadCredentialsException
(
this
.
messages
.
getMessage
(
"LdapAuthenticationProvider.emptyUsername"
,
"Empty Username"
));
}
else
if
(!
StringUtils
.
hasLength
(
password
))
{
throw
new
BadCredentialsException
(
this
.
messages
.
getMessage
(
"AbstractLdapAuthenticationProvider.emptyPassword"
,
"Empty Password"
));
}
else
{
Assert
.
notNull
(
password
,
"Null password was supplied in authentication token"
);
DirContextOperations
userData
=
this
.
doAuthentication
(
userToken
);
String
loginId
=
userData
.
getStringAttribute
(
properties
.
getMapping
().
getLoginId
());
UserDetails
user
=
this
.
userDetailsContextMapper
.
mapUserFromContext
(
userData
,
loginId
,
this
.
loadUserAuthorities
(
userData
,
loginId
,
(
String
)
authentication
.
getCredentials
()));
return
this
.
createSuccessfulAuthentication
(
userToken
,
user
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录