開発者の皆様、こんばんは。質問があります。私の Web アプリケーションでは、Spring セキュリティを使用しています。ユーザー、管理者の 2 つの単純な役割があります。これらのルールごとに、自分のパスワードを持っています。これは、Web アプリへのアクセス権がすべて異なるためです。したがって、すべてのパスワードを sha-256 ハッシュ エンコーディングの security.xml に保存します。
<security:http pattern="/search" security="none" />
<security:http auto-config="true" >
<security:session-management session-fixation-protection="migrateSession"/>
<security:intercept-url pattern="/input" access="ROLE_ADMIN, ROLE_USER"/>
<security:intercept-url pattern="/delete" access="ROLE_ADMIN"/>
<security:form-login login-page="/login"
authentication-failure-url="/loginfail"
default-target-url="/input"
always-use-default-target="true"
username-parameter="j_username"
password-parameter="j_password" />
<security:logout logout-success-url="/logout"/>
<security:session-management>
<security:concurrency-control max-sessions="1" error-if-maximum-exceeded="true" />
</security:session-management>
</security:http>
<security:authentication-manager>
<security:authentication-provider>
<security:password-encoder hash="sha-256"/>
<security:user-service>
<security:user name="user" password="04f8996da763b7a969b1028ee3007569eaf3a635486ddab211d512c85b9df8fb" authorities="ROLE_USER"/>
<security:user name="admin" password="8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918" authorities="ROLE_ADMIN"/>
</security:user-service>
</security:authentication-provider>
</security:authentication-manager>
それは本当に良い考えですか?保護を強化するために、それらをDB(たとえばH2)に保存する必要があるかもしれません。
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <!-- Using and configuring C3P0 proxy -->
<property name="driverClass"><value>org.h2.Driver</value></property>
<property name="jdbcUrl"><value>jdbc:h2:/home/vadim/workspace-sts-3.1.0.RELEASE/h2/EDUCATION</value></property>
<property name="user"><value>sa</value></property>
<property name="password" ><value></value></property>
<property name="initialPoolSize"><value>3</value></property> <!-- Number of Connections a pool will try to acquire upon startup -->
<property name="minPoolSize"><value>1</value></property> <!-- Minimum connection pool size -->
<property name="maxPoolSize"><value>20</value></property> <!-- Max connection pool size -->
<property name="maxConnectionAge"><value>3600</value></property> <!-- Set max connection age to 1 hour, after it will release -->
<property name="maxIdleTime"><value>600</value></property> <!-- 10 minutes connection can stay unused before be discarded -->
<property name="checkoutTimeout"><value>200000</value></property> <!-- Each what time check for unused connections -->
</bean>
パスワードが空白になりましたが、パスワードを設定する必要があります。どうやって守る??
ありがとうございました。