如何在Spring安全中使用数据库和LDAP认证? [英] How to use both database and LDAP authentication in Spring security?

查看:359
本文介绍了如何在Spring安全中使用数据库和LDAP认证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个Spring MVC应用程序。我们现在必须在其中集成弹簧安全。

We have a Spring MVC application. We now have to integrate spring security in it.

可以使用数据库或使用LDAP进行身份验证。

The authentication can be done using either database or using LDAP.

在属性文件或数据库中决定使用哪种认证,即用户是否应针对数据库或LDAP进行认证。

We will a have a configuration setting either in a properties file or a database to decide which authentication to use i.e. if the user should be authenticated against a database or a LDAP.

在任何给定时间,只有一种类型的身份验证。

At any given time there will be only one type of authentication.

公司test1可以有一个数据库认证,另一个公司测试2可以有ldap认证。

e.g. A company test1 can have a database authentication and another company test 2 can have ldap authentication.

推荐答案

一些想法:


  1. 如果每个客户端都单独部署其自己的配置,请在2个不同的XML文件中配置DAO和LDAP身份验证。

  2. 如果只有1个WAR,请尝试在WAR中同时包含这两个XML文件,并设置一个系统属性在启动应用程序时使用 -Dmyprop = foo (某种其他方式)。然后,在您的Spring配置中,使用 $ {myprop} 包含适当的配置文件,以便调用并使用正确的文件。

  1. If each client is deployed separately with its own configuration, configure the DAO and LDAP authentication in 2 different XML files. At build time, choose which one you want to use and bundle it in your WAR.
  2. If there is only 1 WAR, maybe try including both XML files in the WAR, and set a system property using -Dmyprop=foo (o some other way) when starting up the app. Then, in your Spring config, include the appropriate config file using ${myprop} so that the correct file is called and used.

这篇关于如何在Spring安全中使用数据库和LDAP认证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆