让数据库身份验证在Apache Guacamole上工作



让Apache Guacamole和Tomcat在两台笔记本电脑和一台PC之间工作兰。

但是,始终通过更新用户和连接详细信息user-mapping.xml

然后我决定设置数据库身份验证,以便更容易地更改用户映射

安装并拥有活动的SQLServer、MYSQL以及现在的PostGreSQL,都是活动且正在运行(不同时进行,逐个尝试,然后卸载(然而,鳄梨酱的登录详细信息保持不变,似乎不受鳄梨酱属性的变化。

这是我最新的鳄梨酱属性文件供参考。(PostGreSQL版本atm(

guacd-hostname:localhost
guacd-port: 4822
user-mapping:/etc/guacamole/user-mapping.xml
auth-provider:
net.sourceforge.guacamole.net.basic.BasicFileAuthenticationProvider
# MySQL properties
#mysql-hostname: localhost
#mysql-port: 3306
#mysql-database: guacamole_db
#mysql-username: SHRDC
#mysql-password: Shrdc_1234
#mysql-user-required: true
# PostgreSQL properties
postgresql-hostname: localhost
postgresql-port: 5432
postgresql-database: guacamole_db
postgresql-username: SHRDC
postgresql-password: Shrdc_1234
postgresql-user-required: true

我感觉它的一些连接器,驱动程序的问题,因此没有被识别。/lib或/extensions中需要更改什么?

作为参考,我目前使用的身份验证驱动程序和身份验证连接器是:

in/extensions:鳄梨酱-auth-jdbc-postgresql.jar(以前是鳄梨酱-auth-jdbc-postgresql-1.2.0.jar在我重命名它之前尝试smthout(

在/lib中:postgresql-42.2.14.jar

所有步骤按照:https://guacamole.apache.org/doc/gug/jdbc-auth.html

希望得到一些反馈,一直在尝试让DB身份验证工作一个多星期了!

真诚的

我遇到了完全相同的问题,但我的设置使用了docker。就我而言,实际代码和文档之间存在差异。我将解释如何找到根本原因,因为它是相似的。

  1. 启用Logback调试

因为您是手动安装的(不使用docker容器(。你很可能知道GUACAMOLE_HOME在哪里。只是提醒你,默认情况下它在/etc/guacamole中,但如果你有/home/$USER/.guacamole,它会被使用。

添加logback.xml,如下所述:https://guacamole.apache.org/doc/gug/configuring-guacamole.html在您的GUACAMOLE_HOME目录中

  1. 查看您的catalina输出

新的调试设置将输出所有调试消息。如果没有[DEBUG]消息,那么您将logback.xml放错了位置。

一旦您有了DEBUG输出流,就可以看到重要的输出,如当前使用的GUACAMOLE_HOME、当前使用的AuthBinding等。这是catalina启动的时候。

例如,这是我的日志摘录:

19:23:08.933 [localhost-startStop-1] DEBUG o.a.g.extension.ExtensionModule - Loading extension: "guacamole-auth-jdbc-postgresql-1.2.0.jar"
19:23:08.973 [localhost-startStop-1] DEBUG o.a.g.extension.ExtensionModule - [0] Binding AuthenticationProvider "org.apache.guacamole.auth.postgresql.PostgreSQLAuthenticationProvider".
19:23:08.980 [localhost-startStop-1] INFO  o.a.g.environment.LocalEnvironment - GUACAMOLE_HOME is "/root/.guacamole".
19:23:10.150 [localhost-startStop-1] DEBUG o.a.g.extension.ExtensionModule - [1] Binding AuthenticationProvider "org.apache.guacamole.auth.postgresql.PostgreSQLSharedAuthenticationProvider".
19:23:10.207 [localhost-startStop-1] DEBUG o.a.g.e.LanguageResourceService - Merged strings with existing language: "es"
19:23:10.213 [localhost-startStop-1] DEBUG o.a.g.e.LanguageResourceService - Merged strings with existing language: "ru"
19:23:10.216 [localhost-startStop-1] DEBUG o.a.g.e.LanguageResourceService - Merged strings with existing language: "de"
19:23:10.222 [localhost-startStop-1] DEBUG o.a.g.e.LanguageResourceService - Merged strings with existing language: "fr"
19:23:10.227 [localhost-startStop-1] DEBUG o.a.g.e.LanguageResourceService - Merged strings with existing language: "ja"
19:23:10.233 [localhost-startStop-1] DEBUG o.a.g.e.LanguageResourceService - Merged strings with existing language: "en"
19:23:10.234 [localhost-startStop-1] INFO  o.a.g.extension.ExtensionModule - Extension "PostgreSQL Authentication" loaded.

请注意,必须首先加载postgresql-auth绑定。

如果没有这样的输出,那么Tomcat甚至找不到您的设置。如果Tomcat找到了设置,但未能加载绑定,那么Tomcat就找不到您的绑定。

如果发生这种情况,这是一个日志示例(catalina启动运行良好,但通过鳄梨酱面板登录会出现此错误(。

### Error querying database.  Cause: java.sql.SQLException: Error setting driver on UnpooledDataSource. Cause: java.lang.ClassNotFoundException: org.postgresql.Driver
### The error may exist in org/apache/guacamole/auth/jdbc/user/UserMapper.xml
### The error may involve org.apache.guacamole.auth.jdbc.user.UserMapper.selectOne
### The error occurred while executing a query
### Cause: java.sql.SQLException: Error setting driver on UnpooledDataSource. Cause: java.lang.ClassNotFoundException: org.postgresql.Driver
19:44:44.511 [http-nio-8080-exec-12] DEBUG o.a.g.rest.RESTExceptionMapper - Unexpected error in REST endpoint.
org.apache.ibatis.exceptions.PersistenceException:
### Error querying database.  Cause: java.sql.SQLException: Error setting driver on UnpooledDataSource. Cause: java.lang.ClassNotFoundException: org.postgresql.Driver
### The error may exist in org/apache/guacamole/auth/jdbc/user/UserMapper.xml
### The error may involve org.apache.guacamole.auth.jdbc.user.UserMapper.selectOne
### The error occurred while executing a query
### Cause: java.sql.SQLException: Error setting driver on UnpooledDataSource. Cause: java.lang.ClassNotFoundException: org.postgresql.Driver

最后,如果它找到了你的设置,但没有找到你的鳄梨酱auth-postgresql绑定,它将喷出以下日志:

19:47:49.654 [http-nio-8080-exec-15] DEBUG o.a.g.extension.ExtensionModule - [0] Binding AuthenticationProvider "org.apache.guacamole.auth.file.FileAuthenticationProvider".

请注意,现在首先加载FileAuth绑定(它没有找到您的postgresjdbc绑定(。

  1. 根据日志信息,系统地尝试找出根本原因

它可以像错误的GUACAMOLE_HOME一样简单。例如,您编辑了/etc/guacamole/guacamole.properties,但Tomcat实际上加载了/home/$USER/.guacamole/guacamole.properties。或者你的目录结构不正确。

这是我的目录树,如果你想比较一下:

root@guacamole-7988d57c8d-nwfk7:~/.guacamole# tree .
.
├── extensions
│   ├── guacamole-auth-jdbc-postgresql-1.2.0.jar -> /opt/guacamole/postgresql/guacamole-auth-jdbc-postgresql-1.2.0.jar
│   └── lost+found
├── guacamole.properties
├── lib
│   └── postgresql-9.4-1201.jdbc41.jar -> /opt/guacamole/postgresql/postgresql-9.4-1201.jdbc41.jar
└── logback.xml
3 directories, 4 files
  1. 检查您是否真的可以访问数据库

在鳄梨酱运行的机器内(tomcat(。请检查您是否可以使用给定的凭据访问数据库。如果您正在使用postgres,请尝试通过psql访问它。只是为了确保你有适当的权限访问数据库

  1. 确保您使用的jdbc驱动程序适用于正确的Java版本

医生可能已经给了我足够的压力。但也许你可以再检查一下。

最新更新