Spring Security 1.2.7.1 および Spring Security UI 0.2 で Grails 2.1.1 を使用しています。
メモリ内データベースを使用して BootStrap.groovy にテスト ユーザーを作成すると、ログインしてユーザーを管理できます。すべて正常に動作します。ただし、データ ソースを MySQL データベースに切り替えると、ログインしようとすると、ユーザー アカウントが無効になっているとサービスに表示されます。確認したところ、パスワードが正しくハッシュされているようです (つまり、データベースの内容と一致しています)。 . 私がユーザーに対して行った唯一の変更は、調査 ID を含めることです。コードをデバッグしようとすると、org.codehaus.groovy.grails.plugins.springsecurity.GrailsUser が enabled=false を示していることがわかりました。
どんな助けでも大歓迎です!
私のデータソース:
dataSource {
driverClassName = "com.mysql.jdbc.Driver"
dialect = org.hibernate.dialect.MySQL5InnoDBDialect
url = "jdbc:mysql://localhost/users"
username = "root"
password = ""
dbCreate = "create-drop"
}
私の BootStrap.groovy コード:
def adminRole = new Role(authority: 'ROLE_ADMIN').save(flush: true)
def userRole = new Role(authority: 'ROLE_USER').save(flush: true)
def testAdmin = new User(username: 'me', enabled: true, password: 'password', studyID: '0')
testAdmin.save(flush: true)
UserRole.create testAdmin, adminRole, true
def testUser = new User(username: '100', enabled: true, password: 'test', studyID: '101')
testUser.save(flush: true)
UserRole.create testUser, userRole, true
assert User.count() == 2
assert Role.count() == 2
assert UserRole.count() == 2
アプリケーションを起動した後の User.user テーブルの行。これらの値をどのように変更しても、ログインしようとすると、ユーザーが無効になっていることが示されます。
id version account_expired account_locked enabled password password_expired studyid username
1 0 1 1 1 5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a... 1 0 me