我有一個PHP應用程序正在轉換爲Grails。 PHP應用程序使用salt機制來編碼所有用戶的密碼。如何在Grails項目中使用PHP生成的鹽
將鹽和鹽漬密碼移動到Grails中的(自定義)用戶數據庫中時,我無法在我的Grails應用程序中登錄。
當然,我使用的是Spring Security Core plugin,我已經添加了鹽爲this tutorial指定的用戶域類,我發現在這裏:Grails with Spring Security Plugin and Salted Passwords
通過教程運行後,我能夠添加一個用戶,併成功地與該用戶登錄:
[BootStrap.groovy]:
new User(username:"user", email:"[email protected]", password:"password", enabled:true).save(flush: true)
(你可能也注意到另外的電子郵件,其中我添加使用this tutorial)
但我不能使用從PHP項目轉移過來的任何用戶登錄。如果它的任何幫助,這裏是如何的密碼被編碼:
$password = "password";
$salt = bin2hex(openssl_random_pseudo_bytes(32));
$passwordSalted = hash("sha256", $salt . $password);