简体   繁体   English

如何在 SHIRO 配置 INI 文件中添加其他参数,尤其是对于 db 查询

[英]How do you add additional parameters in a SHIRO configuration INI file, especially for db query

I have a standard shiro.ini file that is used to authenticate/authorize my Java EE maven project.我有一个标准的shiro.ini文件,用于验证/授权我的 Java EE maven 项目。 I am stuck at a point where I cannot use multiple fields for the username authentication using the shiro INI config file.我被困在无法使用 shiro INI 配置文件使用多个字段进行用户名身份验证的地步。 Here is how it is这是怎么回事

jdbcRealm = org.apache.shiro.realm.jdbc.JdbcRealm
jdbcRealm.dataSource = $ds
jdbcRealm.credentialsMatcher = $passwordMatcher
jdbcRealm.permissionsLookupEnabled = false
jdbcRealm.authenticationQuery = SELECT user_password FROM user WHERE user_name = ? AND user_status = 1
jdbcRealm.userRolesQuery = SELECT login_type_name FROM login_type t INNER JOIN schooler_user_rel r ON r.login_type_id = t.login_type_id INNER JOIN user u ON u.user_id = r.user_id WHERE u.user_name = ?

authc.usernameParam = username
authc.passwordParam = password

Here the problem is that I cannot use another field like a user-email or user-id for authenticating.这里的问题是我不能使用另一个字段,如用户电子邮件或用户 ID 进行身份验证。 When I add this当我添加这个

jdbcRealm.authenticationQuery = SELECT user_password FROM user WHERE (user_name = ? OR user_id = ?) AND user_status = 1

This says I do not have the second parameter setup.这表示我没有第二个参数设置。 Help!帮助!

您需要实现自己的领域,可能扩展JdbcRealm并覆盖doGetAuthenticationInfo()方法以实现您自己的逻辑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM