问题描述
我搜索了很多关于此主题的内容,但找不到解决方案.
I was searching a lot about this topic but can't find a solution.
要求的简短描述:
- Wildfly 8.2 下 Web 应用程序上的 SSO
- 向 Active Directory 验证 Windows 用户
- 当 SSO 失败时回退到登录表单
- 在 Wildfly 的域配置中运行
环境:
- Microsoft AD Windows Server 2012 R2(1. 机器)
- 带有 Wildfly 8.2 的 Microsoft Server 2012 R2(2. 机器)
- 2.Machine 加入域
到目前为止,我尝试过的方法是通过 ktpass、kinit 将 AD 和 Wildfly Server 绑定起来……它有效!
What I tried so far, is bound the AD and the Wildfly Server via ktpass, kinit, ... it works!
尝试了以下方法:
github.com/dstraub/spnego-wildfly
实际上不起作用,没有后备(基于表单)和 Java 版本 1.8.0_45 的问题sourceforge.net/p/spnego/discussion/1003769/thread/700b6941/#cb84.
Tried following:
github.com/dstraub/spnego-wildfly
Is NOT working in fact, that there is no fallback (form based) and a Problem with the Java Version 1.8.0_45sourceforge.net/p/spnego/discussion/1003769/thread/700b6941/#cb84.
接下来尝试:github.com/kwart/spnego-demo
同样不起作用,Wildfly 8.2 似乎有不同的行为.
Tried next:github.com/kwart/spnego-demo
Also not working, it seems the Wildfly 8.2 has a different behavior.
华夫饼库:不能让它在 Wildfly 下工作,对 Tomcat 的良好支持,但仅此而已.
WAFFLE Library:Cannot bring that to work under Wildfly, good support for Tomcat but not more.
有人对此配置有经验并有解决方案吗?
Has someone made experience with this configuration an has a solution for that?
推荐答案
解释如下:
我创建了一个包含以下库的网络应用程序:
I've created a webapp with following libraries included:
- guava-18.0.jar
- jna-4.1.0.jar
- jna-platform-4.1.0.jar
- slf4j-api-1.7.12.jar
- waffle-jna-1.7.4.jar
我已经在 web.xml 中声明了 Webfilter:
I've declared the Webfilter in the web.xml:
<filter>
<filter-name>SecurityFilter</filter-name>
<filter-class>waffle.servlet.NegotiateSecurityFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>SecurityFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
- 之后,您可以从 HttpServletRequest 中读取用户
public String getUserName() {
Enumeration<String> headerNames = servletRequest.getHeaderNames();
while (headerNames.hasMoreElements()) {
String headerName = headerNames.nextElement();
String headerValue = servletRequest.getHeader(headerName);
System.out.println("Header Name:" + headerName + " " + headerValue);
}
return servletRequest.getUserPrincipal().getName();
}
- 为单点登录配置浏览器:
https://github.com/dblock/waffle/blob/master/Docs/ConfiguringBrowsers.md
这篇关于带有 Wildfly 8、Java 1.8.0_45 和 Active Directory 的 Java SSO的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!