【问题标题】:Restrict the access of REST URL's in browser限制浏览器中 REST URL 的访问
【发布时间】:2015-03-15 04:38:44
【问题描述】:

如何限制浏览器中 REST url 的访问,谁能指导我在 security.xml 中进行哪些必要的更改。我的 Web 应用在 Spring MVC 框架上运行。

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"   xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
          http://www.springframework.org/schema/security  http://www.springframework.org/schema/security/spring-security.xsd">

<http pattern="/images/**" security="none" />
<http pattern="/styles/**" security="none" />
<http pattern="/scripts/**" security="none" />
<http pattern="/assets/**" security="none" />


<http auto-config="true">
    <intercept-url pattern="/app/admin/**" access="ROLE_ADMIN" />
    <intercept-url pattern="/app/passwordHint*" access="ROLE_ANONYMOUS,ROLE_ADMIN,ROLE_USER" />
    <intercept-url pattern="/app/requestRecoveryToken*" access="ROLE_ANONYMOUS,ROLE_ADMIN,ROLE_USER, ROLE_PHYSICIAN, ROLE_PRACTICE_STAFF" />
    <intercept-url pattern="/app/updatePassword*" access="ROLE_ANONYMOUS,ROLE_ADMIN,ROLE_USER, ROLE_PHYSICIAN, ROLE_PRACTICE_STAFF" />
    <intercept-url pattern="/app/signup*" access="ROLE_ADMIN" />
    <intercept-url pattern="/app/practice*" access="ROLE_ADMIN"/>   
    <!-- <intercept-url pattern="/app/patientReports*" access="ROLE_ADMIN"/> -->        
    <intercept-url pattern="/app/mediaFile/**" access="ROLE_ANONYMOUS"/>
    <intercept-url pattern="/app/**" access="ROLE_ADMIN, ROLE_USER, ROLE_PHYSICIAN, ROLE_PRACTICE_STAFF" />
    <form-login login-page="/login" authentication-failure-url="/login?error=true" login-processing-url="/j_security_check" />
    <remember-me user-service-ref="userDao" key="e37f4b31-0c45-11dd-bd0b-0800200c9a66" />
</http>

<authentication-manager>
    <authentication-provider user-service-ref="userDao">
        <password-encoder ref="passwordEncoder">
        </password-encoder>
    </authentication-provider>
</authentication-manager>


<!-- Override the default password-encoder (BCrypt) by uncommenting the following and changing the class -->
<!-- <bean id="passwordEncoder" class="org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder"/> -->

<global-method-security>
    <protect-pointcut expression="execution(* *..service.UserManager.getUsers(..))" access="ROLE_ADMIN" />
    <protect-pointcut expression="execution(* *..service.UserManager.removeUser(..))" access="ROLE_ADMIN" />
</global-method-security>

【问题讨论】:

    标签: spring-mvc restlet-2.0 appfuse


    【解决方案1】:

    你读过Spring security manual吗?

    您需要限制某些角色对您的休息 URL 的访问。您如何通过用户获得这些角色取决于您的设置。 对于 REST 调用,您可能不需要表单登录,而是需要基本身份验证。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-08-28
      • 1970-01-01
      • 2012-06-13
      • 2021-11-01
      • 1970-01-01
      • 2014-05-01
      • 2021-04-13
      • 2013-09-28
      相关资源
      最近更新 更多