Configure shiro.ini for JDBC connection

后端 未结 1 686
清酒与你
清酒与你 2021-01-07 16:06

As part of my new years learning new technologies initiative I have started messing around with the Apache Shiro Security Framework.

I managed to get the basic examp

相关标签:
1条回答
  • 2021-01-07 16:17

    If you are not giving permission query then better disable permission lookup. Also if you want to use basic Authentication why use authc attributes.

    Try Following

        [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
    
    0 讨论(0)
提交回复
热议问题