gpt4 book ai didi

authentication - Tomcat 7 : authentication with multiple UserDatabaseRealms for multiple webapps

转载 作者:行者123 更新时间:2023-11-28 22:31:29 26 4
gpt4 key购买 nike

在同一台服务器上,我需要部署同一个 webapp 的两个版本(一个用于生产,另一个用于验证)。

这两个 webapps 使用不同的数据库进行身份验证。我正在努力为这两个应用程序实现两个不同的上下文。

我在 server.xml 中实现了以下代码,但身份验证不再起作用:

        <Context path="http://localhost:8080/myapp1" docBase="/path/webapps/myapp1.war" debug="0" privileged="true">

<!--For clustering, please take a look at documentation at:
/docs/cluster-howto.html (simple how to)
/docs/config/cluster.html (reference documentation) -->
<!--
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
-->

<Realm className="org.apache.catalina.realm.LockOutRealm">
<!-- This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase". Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm. -->
<Realm className="org.apache.catalina.realm.JDBCRealm"
driverName="org.postgresql.Driver" digest="MD5"
connectionURL="jdbc:postgresql://localhost/postgres_prod?user=postgres&amp;password=postgres"
userTable="utilisateurs" userNameCol="login" userCredCol="password"
userRoleTable="user_roles" roleNameCol="role_name" resourceName="UserDatabase"/>


<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
</Realm>
</Context>

<Context path="http://localhost:8080/myapp2" docBase="/path/webapps/myapp2.war" debug="0" privileged="true">

<!--For clustering, please take a look at documentation at:
/docs/cluster-howto.html (simple how to)
/docs/config/cluster.html (reference documentation) -->
<!--
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
-->

<Realm className="org.apache.catalina.realm.LockOutRealm">
<!-- This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase". Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm. -->
<Realm className="org.apache.catalina.realm.JDBCRealm"
driverName="org.postgresql.Driver" digest="MD5"
connectionURL="jdbc:postgresql://localhost/postgres_val?user=postgres&amp;password=postgres"
userTable="utilisateurs" userNameCol="login" userCredCol="password"
userRoleTable="user_roles" roleNameCol="role_name" resourceName="UserDatabase"/>


<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
</Realm>
</Context>

我不明白是否需要更改 web.xmltomcat-users.xml 中的其他内容。当我只用一个应用程序测试它时(当我不需要 context 标签时),身份验证工作。

预先感谢您的帮助!

最佳答案

我在两个应用程序的context.xml文件中移动了两个Context标签的内容。另一个已解决的问题:使用 server.xml 中的这部分代码,我无法以 tomcat 管理器身份登录。

关于authentication - Tomcat 7 : authentication with multiple UserDatabaseRealms for multiple webapps,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15905762/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com