Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache 为JDBC连接配置shiro.ini_Apache_Shiro - Fatal编程技术网

Apache 为JDBC连接配置shiro.ini

Apache 为JDBC连接配置shiro.ini,apache,shiro,Apache,Shiro,作为我的新年学习新技术计划的一部分,我开始玩弄ApacheShiro安全框架 我成功地使基本示例工作起来,它在shiro.ini文件中存储用户名、密码和角色,但是当我修改shiro.ini文件以使用JDBC时,它就停止了工作。现在,当我尝试访问我的应用程序时,会不断收到输入用户名和密码的提示。我尽可能地保持简单(密码甚至没有散列) 下面是我的shiro.ini文件,有人知道我做错了什么吗 [main] authc.usernameParam = j_username authc.password

作为我的新年学习新技术计划的一部分,我开始玩弄ApacheShiro安全框架

我成功地使基本示例工作起来,它在shiro.ini文件中存储用户名、密码和角色,但是当我修改shiro.ini文件以使用JDBC时,它就停止了工作。现在,当我尝试访问我的应用程序时,会不断收到输入用户名和密码的提示。我尽可能地保持简单(密码甚至没有散列)

下面是我的shiro.ini文件,有人知道我做错了什么吗

[main]
authc.usernameParam = j_username
authc.passwordParam = j_password
authc.failureKeyAttribute = shiroLoginFailure

jdbcRealm = org.apache.shiro.realm.jdbc.JdbcRealm
jdbcRealm.permissionsLookupEnabled = true

jdbcRealm.authenticationQuery = "SELECT password FROM user WHERE username = ?"
jdbcRealm.userRolesQuery = "SELECT role FROM user WHERE username = ?"

ds = com.mysql.jdbc.jdbc2.optional.MysqlDataSource
ds.serverName = localhost
ds.user = root
ds.password = password
ds.databaseName = database
jdbcRealm.dataSource = $ds

# Use Built-in Chache Manager
builtInCacheManager = org.apache.shiro.cache.MemoryConstrainedCacheManager
securityManager.cacheManager = $builtInCacheManager

securityManager.realms = $jdbcRealm

[users]
[roles]
[urls]
/* = authcBasic

如果您不提供权限查询,那么最好禁用权限查找。此外,如果要使用基本身份验证,为什么要使用authc属性

试着跟随

    [main]
    #authc.usernameParam = j_username
    #authc.passwordParam = j_password
    #authc.failureKeyAttribute = shiroLoginFailure

    jdbcRealm = org.apache.shiro.realm.jdbc.JdbcRealm
    jdbcRealm.permissionsLookupEnabled = false

    jdbcRealm.authenticationQuery = SELECT password FROM user WHERE username = ?
    jdbcRealm.userRolesQuery = SELECT role FROM user WHERE username = ?

    ds = com.mysql.jdbc.jdbc2.optional.MysqlDataSource
    ds.serverName = localhost
    ds.user = root
    ds.password = password
    ds.databaseName = database
    jdbcRealm.dataSource = $ds

    # Use Built-in Chache Manager
    builtInCacheManager = org.apache.shiro.cache.MemoryConstrainedCacheManager
    securityManager.cacheManager = $builtInCacheManager

    securityManager.realms = $jdbcRealm

    [users]
    [roles]
    [urls]
    /* = authcBasic

您可以尝试从查询中删除引号吗?