在 Shiro 中,有没有办法根据 Postgresql 用户表对用户进行身份验证

问题描述

我正在探索使用 Apache Shiro 的 Zeppelin 身份验证。到目前为止,我可以使用基本的 JDBC 领域。

我的 Shiro.ini 看起来像:

[main]
dataSource                    = org.postgresql.ds.PGPoolingDataSource
dataSource.serverName         = localhost
dataSource.databaseName       = dp
dataSource.user               = dp_test
dataSource.password           = Welcome123
jdbcRealm = org.apache.shiro.realm.jdbc.JdbcRealm

ps = org.apache.shiro.authc.credential.DefaultPasswordService
pm = org.apache.shiro.authc.credential.PasswordMatcher
pm.passwordService = $ps
jdbcRealm.dataSource = $dataSource

jdbcRealm.authenticationQuery = select password from zeppelin.zeppelin_users where username = ?
jdbcRealm.userRolesQuery    = select role_name from zeppelin.zeppelin_user_roles where username = ?

sessionManager = org.apache.shiro.web.session.mgt.DefaultWebSessionManager

cookie = org.apache.shiro.web.servlet.SimpleCookie
cookie.name = JSESSIONID
cookie.httpOnly = true

sessionManager.sessionIdCookie = $cookie
securityManager.sessionManager = $sessionManager

securityManager.sessionManager.globalSessionTimeout = 86400000
shiro.loginUrl = /api/login
[roles]
role1 = *
role2 = *
role3 = *
admin = *
[urls]
/api/version = anon
/api/cluster/address = anon
# Allow all authenticated users to restart interpreters on a notebook page.
# Comment out the following line if you would like to authorize only admin users to restart interpreters.
/api/interpreter/setting/restart/** = authc
/api/interpreter/** = authc,roles[admin]
/api/notebook-repositories/** = authc,roles[admin]
/api/configurations/** = authc,roles[admin]
/api/credential/** = authc,roles[admin]
/api/admin/** = authc,roles[admin]
#/** = anon
/** = authc

通过以上,我可以对 zeppelin_users 表进行身份验证。

我正在寻找一种方法来使用 Postgresql 用户表,即 pg_users 表。

意图是谁可以访问数据库,也应该可以访问 zeppelin。

似乎 Postgresql 正在使用 MD5 来散列密码。

show password_encryption ;

'ON' //an alias for MD5

看起来 Postgresql 实际上用用户名作为密码的后缀,然后 MD5 散列是由它构成的,然后该散列以 'md5' 为前缀。

select passwd from pg_shadow;

md52c92c858aa1fa12144f1dcbd4ca9c3a0

这可能吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...