![](/img/trans.png)
[英]Is the permission parameter case-sensitive when using with hasPermission in spring security?
[英]Spring Security Case Sensitive
MySql數據庫區分大小寫,在休眠狀態下一切正常,數據庫中的表名與我的類相同。 但是在Spring Security上,默認身份驗證不能很好地工作,使用表名的首字母小寫而不是大寫來構建SQL。 有什么方法可以使Spring安全性像休眠狀態一樣理解大寫嗎? 還是只需要將表名更改為大寫字母就需要構建自定義身份驗證?
<!-- Session Factory Hibernate -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="packagesToScan" value="br.com.empresa.domain" />
<property name="dataSource">
<ref local="mySQLdataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.hbm2ddl.auto">create-drop</prop>
<!-- Novos geradores de ids recomendados pela documentação do hibernate -->
<prop key="hibernate.id.new_generator_mappings">false</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<!-- Conexão com o Banco de Dados -->
<bean id="mySQLdataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/db" /> -->
<property name="username" value="root" />
<property name="password" value="asd123456" />
</bean>
<!-- It is responsible for validating the user's credentials -->
<security:authentication-manager>
<!-- It is responsible for providing credential validation to the AuthenticationManager -->
<security:authentication-provider>
<security:password-encoder ref="passwordEncoder" />
<security:jdbc-user-service
data-source-ref="mySQLdataSource" />
</security:authentication-provider>
</security:authentication-manager>
<bean
class="org.springframework.security.crypto.password.StandardPasswordEncoder"
id="passwordEncoder" />
我想您使用JdbcDaoImpl (通過jdbc-user-service元素)。 如果是這樣,則可以為默認查詢提供自己的SQL。
<jdbc-user-service
users-by-username-query="select username, password, enabled from Users where username = ?"
authorities-by-username-query="select username, authority from Authorities where username = ?"
/>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.