值得一提:我正在学习关于 Securing GWT apps with Spring Security 的教程.
我不明白这个。我似乎无法获得 permitAll按照我的需要工作。
这是我当前的配置:
<http auto-config="true">
<intercept-url pattern="/**" access="permitAll" />
<form-login
login-page="/login"
default-target-url="/welcome"
authentication-failure-url="/login?error"
username-parameter="username"
password-parameter="password" />
</http>
如果我在 //localhost:8080 上访问我的网站网站没有完全加载,因为请求
//localhost:8080/app/xsrf
是403 Forbidden因为某些原因。如果我理解正确的话,我配置 Spring Security 的方式应该不是这里的问题。
如果我只是添加,我不会工作
<intercept-url pattern="/**" access="permitAll" />
到<http ..> 的工作是添加这个:
<http pattern="/app/xsrf" security="none"/>
我想明白为什么,因为这不是我想要配置 Spring Security 的方式。添加应该被允许的每个 URL。
我面临的一个其他 问题是,无论出于何种原因(可能是相同的原因),我都无法访问 //localhost:8080/login .这意味着如果我将登录信息提交给 /login我得到 403 Forbidden .
现在,人们会认为添加 <http pattern="/login" security="none"/>在这里会有帮助,但没有。如果我将其添加到我的配置中,我将得到 404 Not Found在这个特定的 URL 上。
这开始让我发疯,因为我被困在这里这么多天我不敢告诉你。您的帮助将得到赞赏和返回。
整个applicationContext-service.xml
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:security="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-4.0.xsd">
<!-- Imports -->
<beans:import resource="applicationContext-jooq.xml"/>
<!-- /////////////////////////////////////////////////////////////// -->
<!-- // BEGIN Spring Security -->
<http pattern="/app/xsrf" security="none"/>
<!-- <http pattern="/login" security="none"/> -->
<http auto-config="true">
<intercept-url pattern="/**" access="permitAll" />
<form-login
login-page="/login"
default-target-url="/welcome"
authentication-failure-url="/login?error"
username-parameter="username"
password-parameter="password" />
</http>
<beans:bean id="authenticationListener"
class="com.mz.server.web.auth.CustomAuthenticationListener"/>
<beans:bean id="authenticationProvider"
class="com.mz.server.web.auth.CustomAuthenticationProvider"/>
<beans:bean id="userDetailsService"
class="com.mz.server.web.service.CustomUserDetailsService"/>
<authentication-manager alias="authenticationManager">
<authentication-provider ref="authenticationProvider"/>
</authentication-manager>
<!-- // END Spring Security -->
<!-- /////////////////////////////////////////////////////////////// -->
<!-- // BEGIN Services -->
<beans:bean id="loginService" class="com.mz.server.web.service.LoginService">
<beans:constructor-arg ref="dslContext" />
</beans:bean>
<!-- // END Services -->
</beans:beans>
编辑:
简化的 applicationContext-service.xml
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-4.0.xsd">
<!-- Imports -->
<beans:import resource="applicationContext-jooq.xml"/>
<!-- //////////////////////////////////////////////////////////////////////////////// -->
<!-- // BEGIN Spring Security -->
<global-method-security pre-post-annotations="enabled"/>
<http auto-config="true">
<intercept-url pattern="/**" access="permitAll" />
</http>
<!-- // END Spring Security-->
</beans:beans>
这是web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>GWT Application | mz</display-name>
<welcome-file-list> <!-- Default page to serve -->
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<!-- //////////////////////////////////////////////////////////////////////////////// -->
<!-- // BEGIN Filters -->
<!-- Spring Security -->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- // END FILTERS -->
<!-- //////////////////////////////////////////////////////////////////////////////// -->
<!-- // BEGIN Listeners -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>com.mz.server.web.ServerConfig</listener-class>
</listener>
<!-- // END Listeners -->
<!-- //////////////////////////////////////////////////////////////////////////////// -->
<!-- // BEGIN Servlets -->
<servlet>
<servlet-name>login</servlet-name>
<servlet-class>com.mz.server.web.servlet.LoginServletImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>login</servlet-name>
<url-pattern>/app/login</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>xsrf</servlet-name>
<servlet-class>com.google.gwt.user.server.rpc.XsrfTokenServiceServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>xsrf</servlet-name>
<url-pattern>/app/xsrf</url-pattern>
</servlet-mapping>
<servlet> <!-- Dispatcher Servlet for REST API for Mobile Devices -->
<servlet-name>mobile-restapi</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>mobile-restapi</servlet-name>
<url-pattern>/app/restapi/*</url-pattern>
</servlet-mapping>
<!-- // END Servlets -->
<!-- //////////////////////////////////////////////////////////////////////////////// -->
<!-- // BEGIN Context Parameter -->
<context-param>
<param-name>
gwt.xsrf.session_cookie_name
</param-name>
<param-value>
mzsid
</param-value>
</context-param>
<context-param>
<param-name>
contextConfigLocation
</param-name>
<param-value>
classpath:/**/spring-config.xml
classpath*:applicationContext-service.xml
</param-value>
</context-param>
<!-- // END Context Parameter -->
<!-- //////////////////////////////////////////////////////////////////////////////// -->
</web-app>
最佳答案
错误似乎在 web.xml 中。而不是 <url-pattern>/*</url-pattern> (如我所遵循的教程中所述)它应该是 /** :
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<!-- It appears that this should say '/**' and not '/*' as stated in many
tutorials
(e.g. http://websystique.com/spring-security/spring-security-4-hello-world-annotation-xml-example/). -->
<url-pattern>/**</url-pattern>
</filter-mapping>
有趣的是,我现在收到以下“INFO”:
INFO: Suspicious url pattern: "/**" in context [] - see section SRV.11.2 of the Servlet specification
我只能说,这开始让人觉得很私有(private)了..
关于xml - 为什么 'permitAll()' 不工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33220662/
类classAprivatedeffooputs:fooendpublicdefbarputs:barendprivatedefzimputs:zimendprotecteddefdibputs:dibendendA的实例a=A.new测试a.foorescueputs:faila.barrescueputs:faila.zimrescueputs:faila.dibrescueputs:faila.gazrescueputs:fail测试输出failbarfailfailfail.发送测试[:foo,:bar,:zim,:dib,:gaz].each{|m|a.send(m)resc
我正在尝试测试是否存在表单。我是Rails新手。我的new.html.erb_spec.rb文件的内容是:require'spec_helper'describe"messages/new.html.erb"doit"shouldrendertheform"dorender'/messages/new.html.erb'reponse.shouldhave_form_putting_to(@message)with_submit_buttonendendView本身,new.html.erb,有代码:当我运行rspec时,它失败了:1)messages/new.html.erbshou
我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-
我有一个模型:classItem项目有一个属性“商店”基于存储的值,我希望Item对象对特定方法具有不同的行为。Rails中是否有针对此的通用设计模式?如果方法中没有大的if-else语句,这是如何干净利落地完成的? 最佳答案 通常通过Single-TableInheritance. 关于ruby-on-rails-Rails-子类化模型的设计模式是什么?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.co
我在我的项目目录中完成了compasscreate.和compassinitrails。几个问题:我已将我的.sass文件放在public/stylesheets中。这是放置它们的正确位置吗?当我运行compasswatch时,它不会自动编译这些.sass文件。我必须手动指定文件:compasswatchpublic/stylesheets/myfile.sass等。如何让它自动运行?文件ie.css、print.css和screen.css已放在stylesheets/compiled。如何在编译后不让它们重新出现的情况下删除它们?我自己编译的.sass文件编译成compiled/t
我正在使用的第三方API的文档状态:"[O]urAPIonlyacceptspaddedBase64encodedstrings."什么是“填充的Base64编码字符串”以及如何在Ruby中生成它们。下面的代码是我第一次尝试创建转换为Base64的JSON格式数据。xa=Base64.encode64(a.to_json) 最佳答案 他们说的padding其实就是Base64本身的一部分。它是末尾的“=”和“==”。Base64将3个字节的数据包编码为4个编码字符。所以如果你的输入数据有长度n和n%3=1=>"=="末尾用于填充n%
我主要使用Ruby来执行此操作,但到目前为止我的攻击计划如下:使用gemsrdf、rdf-rdfa和rdf-microdata或mida来解析给定任何URI的数据。我认为最好映射到像schema.org这样的统一模式,例如使用这个yaml文件,它试图描述数据词汇表和opengraph到schema.org之间的转换:#SchemaXtoschema.orgconversion#data-vocabularyDV:name:namestreet-address:streetAddressregion:addressRegionlocality:addressLocalityphoto:i
为什么4.1%2返回0.0999999999999996?但是4.2%2==0.2。 最佳答案 参见此处:WhatEveryProgrammerShouldKnowAboutFloating-PointArithmetic实数是无限的。计算机使用的位数有限(今天是32位、64位)。因此计算机进行的浮点运算不能代表所有的实数。0.1是这些数字之一。请注意,这不是与Ruby相关的问题,而是与所有编程语言相关的问题,因为它来自计算机表示实数的方式。 关于ruby-为什么4.1%2使用Ruby返
我有一个对象has_many应呈现为xml的子对象。这不是问题。我的问题是我创建了一个Hash包含此数据,就像解析器需要它一样。但是rails自动将整个文件包含在.........我需要摆脱type="array"和我该如何处理?我没有在文档中找到任何内容。 最佳答案 我遇到了同样的问题;这是我的XML:我在用这个:entries.to_xml将散列数据转换为XML,但这会将条目的数据包装到中所以我修改了:entries.to_xml(root:"Contacts")但这仍然将转换后的XML包装在“联系人”中,将我的XML代码修改为
我在我的项目中添加了一个系统来重置用户密码并通过电子邮件将密码发送给他,以防他忘记密码。昨天它运行良好(当我实现它时)。当我今天尝试启动服务器时,出现以下错误。=>BootingWEBrick=>Rails3.2.1applicationstartingindevelopmentonhttp://0.0.0.0:3000=>Callwith-dtodetach=>Ctrl-CtoshutdownserverExiting/Users/vinayshenoy/.rvm/gems/ruby-1.9.3-p0/gems/actionmailer-3.2.1/lib/action_mailer