我有一个带有几个REST控制器的Spring Boot Web应用程序。它使用Spring Security进行基于表单的身份验证(1)
此外,应用程序正在读取存储的请求并将它们分发给自己。为此,我有一个自定义的Spring Dispatcher servlet和一个用于存储请求的过滤器链。调用时,它允许Spring DispatcherServlet将HTTP请求分派给正确的REST控制器(2)
我想以一种不需要对(2)情况进行身份验证的方式设置Spring安全性 - 即http请求来自应用程序本身。
有没有人知道如何实现这个目标?
答案 0 :(得分:4)
您可以创建自定义standard draft:
匹配
LEFT RIGHT OUTTER
的简单策略。
用您的逻辑来决定是否应该忽略该请求。
然后使用RequestMatcher
添加自定义observe({
if (input$startkegg != 0) {
kegg <- reactive({ enrichKEGG(entrezIDs(), pAdjustMethod=input$adjmk, pvalueCutoff=input$keggp, qvalueCutoff=input$keggq)})
output$pathway1 <- renderImage({
width <- session$clientData$output_pathway1_width
height <- session$clientData$output_pathway1_height
#This is the file that will be saved
outfile <- paste0(tempdir(),"\\",as.matrix(as.data.frame(kegg())[1])[1:1], ".png")
#Save the file in the temp folder
pathview(gene.data=entrezIDs(), pathway.id=as.matrix(as.data.frame(kegg())[1])[1:1],species = "hsa",
limit=3, kegg.dir = tempdir())
# Pathview generates a png file (it is possible to generate many png at once by changing '[1:1]' by other numbers)
list(src = outfile,
contentType = 'image/png+xml',
width = width,
height = height,
alt = "plotGoGraph")
}, deleteFile =FALSE)
}
})
:
将RequestMatcher实例列表与
相关联HttpServletRequest
到AbstractRequestMatcherRegistry#requestMatchers
的忽略RequestMatcher
列表:
允许添加Spring Security应忽略的
AbstractConfigAttributeRequestMatcherRegistry
个实例。
在您的WebSecurity#ignoring
方法中:
重写此方法以配置
RequestMatcher
。例如,如果您希望忽略某些请求。
例如:
RequestMatcher
答案 1 :(得分:0)
添加以下来自应用程序的路径的url拦截。
<security:intercept-url pattern="path" access="IS_AUTHENTICATED_ANONYMOUSLY" />