如何实现wildfly Web应用程序LDAP登录 [英] How implement LDAP login in wildfly web app
问题描述
如何实现LDAP身份验证在Java EE应用程序WildFly?是否有任何的例子吗?
How to implement LDAP authentication in a Java EE WildFly app? Are there any examples?
我是新来的Java EE和需要编写使用LDAP的应用程序,我卡住了。我读了一本书关于WildFly发展,但并没有关于LDAP有信息。
I'm new to Java EE and need to write an app using LDAP and I'm stuck. I read a book about developing in WildFly but there was no information about LDAP there.
推荐答案
下面的操作步骤将用于验证使用LDAP您的应用程序(假设LDAP已经设置)执行。
The following step of operation will have to be performed for authenticating your application using LDAP (assuming that LDAP is already setup).
在创建 standalone.xml
文件的新安全域。
Creating a new security domain in standalone.xml
file.
<security-domain name="LDAPAuth">
<authentication>
<login-module code="LdapExtended" flag="required">
<module-option name="java.naming.factory.initial" value="com.sun.jndi.ldap.LdapCtxFactory"/>
<module-option name="java.naming.provider.url" value="ldap://localhost:389"/>
<module-option name="java.naming.security.authentication" value="simple"/>
<module-option name="bindDN" value="uid=admin,dc=acme,dc=com"/>
<module-option name="bindCredential" value="secret"/>
<module-option name="baseCtxDN" value="ou=People,dc=acme,dc=com"/>
<module-option name="baseFilter" value="(uid={0})"/>
<module-option name="rolesCtxDN" value="ou=Roles,dc=acme,dc=com"/>
<module-option name="roleFilter" value="(member={1})"/>
<module-option name="roleAttributeID" value="cn"/>
<module-option name="searchScope" value="ONELEVEL_SCOPE"/>
<module-option name="allowEmptyPasswords" value="true"/>
</login-module>
</authentication> </security-domain>
您必须相应更改值
现在,您将需要添加的安全上下文中的应用程序的web.xml。假设你只想与用户
角色的用户登录到你的应用程序,那么你可以添加这样的事情
Now you will have to add the security context in your application's web.xml. Assuming that you only want users with user
Role to login to your application then you can add something like this
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee <a href="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd</a>"
id="WebApp_ID" version="3.0">
<security-constraint>
<web-resource-collection>
<web-resource-name>HtmlAuth</web-resource-name>
<description>application security constraints
</description>
<url-pattern>/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>Manager</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>LDAPAuth realm</realm-name>
</login-config>
<security-role>
<role-name>user</role-name>
</security-role>
</web-app>
你将不得不放置一个的jboss-web.xml中
在WEB-INF文件夹包含以下内容
you will have to place a jboss-web.xml
in your WEB-INF folder with the following content
<jboss-web>
<security-domain>java:/jaas/LDAPAuth</security-domain>
</jboss-web>
您可以找到关于此主题的精彩教程<一个href=\"http://www.mastertheboss.com/jboss-server/jboss-security/configure-jboss-with-ldap?showall=&start=1\"相对=nofollow>这里
you can find a wonderful tutorial on this subject here
这篇关于如何实现wildfly Web应用程序LDAP登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!