Have config (applicationContext-security.xml):स्प्रिंग सुरक्षा: डीबी में और applicationContext में पासवर्ड एन्कोडिंग
...
public static final String DEF_USERS_BY_USERNAME_QUERY =
"select username,password,enabled " +
"from users " +
"where username = ?";
...
: दूसरी तरफ से
<authentication-manager alias="authenticationManager">
<authentication-provider>
<password-encoder hash="sha"/>
<jdbc-user-service data-source-ref="dataSource"/>
</authentication-provider>
</authentication-manager>
मेरी dataSource
(यह JdbcDaoImpl है) से SQLs है इस कोड में अब sha
के बारे में शब्द है, इसलिए मानक स्प्रिंग सुरक्षा users
तालिका से चयनित पासवर्ड एन्कोड नहीं किया गया है। अब उसी रूप में डीबी को बचाया पासवर्ड के लिए
<class name="model.UserDetails" table="users">
<id name="id">
<generator class="increment"/>
</id>
<property name="username" column="username"/>
<property name="password" column="password"/>
<property name="enabled" column="enabled"/>
<property name="mail" column="mail"/>
<property name="city" column="city"/>
<property name="confirmed" column="confirmed"/>
<property name="confirmationCode" column="confirmation_code"/>
<set name="authorities" cascade="all" inverse="true">
<key column="id" not-null="true"/>
<one-to-many class="model.Authority"/>
</set>
</class>
, लेकिन इनकोडिंग किया जाना चाहिए:
शायद, मैं password
स्तंभ के लिए कुछ sha
विशेषता मेरी हाइबरनेट मानचित्रण config में यहाँ प्रदान करना चाहिए।
applicationContext
कॉन्फ़िगरेशन और डीबी प्रश्नों को एक ही पासवर्ड एन्कोडिंग के रूप में कैसे करें? datasource
को service
और service
अंक के authentication-provider
अंक:
ल्यूक टेलर, धन्यवाद, कि मैं जानना चाहता था - कि मुझे इसे डीबी में डालने से पहले हैश पासवर्ड होना चाहिए। – sergionni
नमक के बारे में, मुझे पता है, यह मेरी सुरक्षा चुनौती का अगला चरण है)) – sergionni
यदि आप bcrypt की तरह कुछ उपयोग करते हैं, तो यह स्वचालित रूप से आपके लिए संभाला जाता है, इसलिए वास्तव में कोई चुनौती नहीं है :-)। आपको खुद को नमक को संभालना नहीं है। –