server/java/renkan-web/src/main/webapp/WEB-INF/spring-security.xml
author ymh <ymh.work@gmail.com>
Sun, 14 Jul 2024 22:00:08 +0200
changeset 666 9d6550026232
parent 316 242510015401
permissions -rw-r--r--
Added tag V00.13.04 for changeset 69d13e7dd286
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
146
2f3ef07f3eef add basic security for admin pages
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<beans xmlns="http://www.springframework.org/schema/beans"
2f3ef07f3eef add basic security for admin pages
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
    xmlns:security="http://www.springframework.org/schema/security"
2f3ef07f3eef add basic security for admin pages
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
    xmlns:util="http://www.springframework.org/schema/util"
2f3ef07f3eef add basic security for admin pages
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2f3ef07f3eef add basic security for admin pages
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
    xsi:schemaLocation="
257
6bf1126c5add add header to go back to space
ymh <ymh.work@gmail.com>
parents: 231
diff changeset
     6
        http://www.springframework.org/schema/beans
6bf1126c5add add header to go back to space
ymh <ymh.work@gmail.com>
parents: 231
diff changeset
     7
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
6bf1126c5add add header to go back to space
ymh <ymh.work@gmail.com>
parents: 231
diff changeset
     8
        http://www.springframework.org/schema/security
6bf1126c5add add header to go back to space
ymh <ymh.work@gmail.com>
parents: 231
diff changeset
     9
        http://www.springframework.org/schema/security/spring-security-3.2.xsd
6bf1126c5add add header to go back to space
ymh <ymh.work@gmail.com>
parents: 231
diff changeset
    10
        http://www.springframework.org/schema/util
6bf1126c5add add header to go back to space
ymh <ymh.work@gmail.com>
parents: 231
diff changeset
    11
        http://www.springframework.org/schema/util/spring-util-3.0.xsd"
146
2f3ef07f3eef add basic security for admin pages
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
>
2f3ef07f3eef add basic security for admin pages
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
149
554a7b55c29a Simplify, put everythong in the same property file
ymh <ymh.work@gmail.com>
parents: 146
diff changeset
    14
    <util:properties id="propsLocations">
554a7b55c29a Simplify, put everythong in the same property file
ymh <ymh.work@gmail.com>
parents: 146
diff changeset
    15
        <prop key="servletContextProps">WEB-INF/renkan.properties</prop>
554a7b55c29a Simplify, put everythong in the same property file
ymh <ymh.work@gmail.com>
parents: 146
diff changeset
    16
        <prop key="classpathProps">classpath:renkan_run.properties</prop>
146
2f3ef07f3eef add basic security for admin pages
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
    </util:properties>
2f3ef07f3eef add basic security for admin pages
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
    
2f3ef07f3eef add basic security for admin pages
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
2f3ef07f3eef add basic security for admin pages
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
        <property name="order" value="1000"/>
149
554a7b55c29a Simplify, put everythong in the same property file
ymh <ymh.work@gmail.com>
parents: 146
diff changeset
    21
        <property name="location" value="#{propsLocations.servletContextProps}"/>
146
2f3ef07f3eef add basic security for admin pages
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
        <property name="ignoreUnresolvablePlaceholders" value="true"/>
2f3ef07f3eef add basic security for admin pages
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
        <property name="IgnoreResourceNotFound" value="false"/>
2f3ef07f3eef add basic security for admin pages
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
    </bean> 
2f3ef07f3eef add basic security for admin pages
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
2f3ef07f3eef add basic security for admin pages
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
        <property name="order" value="1"/>
149
554a7b55c29a Simplify, put everythong in the same property file
ymh <ymh.work@gmail.com>
parents: 146
diff changeset
    27
        <property name="location" value="#{propsLocations.classpathProps}"/>
146
2f3ef07f3eef add basic security for admin pages
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
        <property name="ignoreUnresolvablePlaceholders" value="true"/>
2f3ef07f3eef add basic security for admin pages
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
        <property name="IgnoreResourceNotFound" value="true"/>
226
d2b688aadd8c Try to save passwords
ymh <ymh.work@gmail.com>
parents: 225
diff changeset
    30
    </bean>
231
e65766f81b15 Add authorities list edit.
ymh <ymh.work@gmail.com>
parents: 229
diff changeset
    31
e65766f81b15 Add authorities list edit.
ymh <ymh.work@gmail.com>
parents: 229
diff changeset
    32
    <bean class="org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder" id="renkanPasswordEncoder">
e65766f81b15 Add authorities list edit.
ymh <ymh.work@gmail.com>
parents: 229
diff changeset
    33
        <constructor-arg name="strength" value="10" type="int"/>
e65766f81b15 Add authorities list edit.
ymh <ymh.work@gmail.com>
parents: 229
diff changeset
    34
    </bean>
226
d2b688aadd8c Try to save passwords
ymh <ymh.work@gmail.com>
parents: 225
diff changeset
    35
    
231
e65766f81b15 Add authorities list edit.
ymh <ymh.work@gmail.com>
parents: 229
diff changeset
    36
    <bean class="org.iri_research.renkan.services.RenkanUserDetailsService" id="renkanUserDetailsService" />
146
2f3ef07f3eef add basic security for admin pages
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
 
150
5b62100b8562 - replace simple http authentication by form auth
ymh <ymh.work@gmail.com>
parents: 149
diff changeset
    38
    <security:http auto-config="true" use-expressions="true">
5b62100b8562 - replace simple http authentication by form auth
ymh <ymh.work@gmail.com>
parents: 149
diff changeset
    39
        <security:intercept-url pattern="/admin" access="hasRole('ROLE_ADMIN')" />
225
0fcce86e650c add validation for users
ymh <ymh.work@gmail.com>
parents: 150
diff changeset
    40
        <security:intercept-url pattern="/admin/**" access="hasRole('ROLE_ADMIN')" />
150
5b62100b8562 - replace simple http authentication by form auth
ymh <ymh.work@gmail.com>
parents: 149
diff changeset
    41
        <security:form-login login-page="/auth/login" authentication-failure-url="/auth/loginfailed" password-parameter="password" username-parameter="username" />
5b62100b8562 - replace simple http authentication by form auth
ymh <ymh.work@gmail.com>
parents: 149
diff changeset
    42
        <security:logout />
146
2f3ef07f3eef add basic security for admin pages
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
    </security:http>
2f3ef07f3eef add basic security for admin pages
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
 
225
0fcce86e650c add validation for users
ymh <ymh.work@gmail.com>
parents: 150
diff changeset
    45
    <security:authentication-manager>
231
e65766f81b15 Add authorities list edit.
ymh <ymh.work@gmail.com>
parents: 229
diff changeset
    46
        <security:authentication-provider>
e65766f81b15 Add authorities list edit.
ymh <ymh.work@gmail.com>
parents: 229
diff changeset
    47
            <security:password-encoder hash="sha-256"/>
146
2f3ef07f3eef add basic security for admin pages
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
            <security:user-service>
2f3ef07f3eef add basic security for admin pages
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
                <security:user name="${user.admin.name}" password="${user.admin.password}" authorities="ROLE_ADMIN, ROLE_USER"/>
231
e65766f81b15 Add authorities list edit.
ymh <ymh.work@gmail.com>
parents: 229
diff changeset
    50
            </security:user-service>
e65766f81b15 Add authorities list edit.
ymh <ymh.work@gmail.com>
parents: 229
diff changeset
    51
        </security:authentication-provider>
e65766f81b15 Add authorities list edit.
ymh <ymh.work@gmail.com>
parents: 229
diff changeset
    52
        <security:authentication-provider user-service-ref='renkanUserDetailsService'>
e65766f81b15 Add authorities list edit.
ymh <ymh.work@gmail.com>
parents: 229
diff changeset
    53
            <security:password-encoder ref="renkanPasswordEncoder" />
e65766f81b15 Add authorities list edit.
ymh <ymh.work@gmail.com>
parents: 229
diff changeset
    54
        </security:authentication-provider>
146
2f3ef07f3eef add basic security for admin pages
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
    </security:authentication-manager>
231
e65766f81b15 Add authorities list edit.
ymh <ymh.work@gmail.com>
parents: 229
diff changeset
    56
    <!--security:authentication-manager>
e65766f81b15 Add authorities list edit.
ymh <ymh.work@gmail.com>
parents: 229
diff changeset
    57
        <security:authentication-provider user-service-ref='renkanUserDetailsService'>
e65766f81b15 Add authorities list edit.
ymh <ymh.work@gmail.com>
parents: 229
diff changeset
    58
            <security:password-encoder ref="renkanPasswordEncoder" />
e65766f81b15 Add authorities list edit.
ymh <ymh.work@gmail.com>
parents: 229
diff changeset
    59
        </security:authentication-provider>
e65766f81b15 Add authorities list edit.
ymh <ymh.work@gmail.com>
parents: 229
diff changeset
    60
    </security:authentication-manager-->
e65766f81b15 Add authorities list edit.
ymh <ymh.work@gmail.com>
parents: 229
diff changeset
    61
146
2f3ef07f3eef add basic security for admin pages
ymh <ymh.work@gmail.com>
parents:
diff changeset
    62
 
2f3ef07f3eef add basic security for admin pages
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
</beans>