- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我创建了一个 CustomWebSecurityExpressionHandler 来通过搜索函数 ID 检查数据库表上的用户。我想通过一些数据库更新和上下文的重新启动来更改我在每个函数上的角色,而无需重新编译和编辑大量的 XML。
我想在 webflow 中使用 SpringSecurityExpression!就像我可以在 Spring 的任何其他部分做的那样......
<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow
http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
<secured attributes="isFUUU('key')" />
<view-state id="main" view="dashboard/main.html" >
</view-state>
</flow>
如何让 isFUU("key") 正常工作?需要自定义 CustomAccessDecisionManager 吗?
最佳答案
我找到了解决方法
我必须调试 20 个类的 spring security 和 webflow 才能发现,在 SecurityFlowExecutionListener 中,即使您将 spring security 设置为使用表达式,监听器也将仅基于角色。我发现为了解析表达式 a 需要一个特定类型的配置属性,准确地说是 WebExpressionConfigAttribute。但这不是公开课!!! https://jira.spring.io/browse/SEC-1727 .因此,正如这个 OLD Jira 中所建议的,我需要在同一个包中创建我的 CustomSecurityFlowExecutionListener (org.springframework.security.web.access.expression)
这里是例子
CustomSecurityFlowExecutionListener:
package org.springframework.security.web.access.expression; //First part of the trick!
import foo.bar.example.services.security.CustomAccessDecisionManager;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.springframework.expression.ExpressionParser;
import org.springframework.security.access.AccessDecisionManager;
import org.springframework.security.access.ConfigAttribute;
import org.springframework.security.access.SecurityConfig;
import org.springframework.webflow.security.SecurityFlowExecutionListener;
import org.springframework.webflow.security.SecurityRule;
/**
* Force Spring WebFlow Security listener to use expression!
*
* @author roberto.gabrieli
*/
public class CustomSecurityFlowExecutionListener<T > extends SecurityFlowExecutionListener
{
/**
* Convert SecurityRule into a form understood by Spring Security Force the usage of WebExpressionConfigAttribute!
*
* @param rule
* the rule to convert
* @return list of ConfigAttributes for Spring Security
*/
@Override
@SuppressWarnings("deprecation")
protected Collection<ConfigAttribute> getConfigAttributes(SecurityRule rule)
{
// Get Access Decision Manager to find if has my expression handler
AccessDecisionManager adm = getAccessDecisionManager();
ExpressionParser ep = null;
// Check if is my CustomAccessDecisionManager so I can use my expressions
if ( adm instanceof CustomAccessDecisionManager )
{
ep = ((CustomAccessDecisionManager) adm).getWebSecurityExpressionHandler().getExpressionParser();
}
List<ConfigAttribute> configAttributes = new ArrayList<ConfigAttribute>();
for ( String attribute : rule.getAttributes() )
{
if ( ep != null )
// this will end the trick with fireworks!
configAttributes.add(new WebExpressionConfigAttribute(ep.parseExpression(attribute)));
else
configAttributes.add(new SecurityConfig(attribute));
}
return configAttributes;
}
}
WebFlow-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util" xmlns:webflow="http://www.springframework.org/schema/webflow-config"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.1.xsd
http://www.springframework.org/schema/webflow-config http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.4.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd">
...
<bean id="securityFlowExecutionListener"
class="org.springframework.security.web.access.expression.MamSecurityFlowExecutionListener">
<property name="accessDecisionManager" ref="customAccessDecisionManager"/>
</bean>
...
</beans>
关于java - Spring WebFlow + Spring 安全 : use expression instead of role,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29828569/
我的 Web 应用程序在后端使用 Node.js 和 Express。当违反内容安全策略 (CSP) 时,报告 URI 报告空对象。我的后台代码如下: app.use(bodyParser.urlen
在服务器端提供静态服务的方式在 Express 中似乎非常简单: To serve static files such as images, CSS files, and JavaScript fil
var express = require('express'); var app = express(); 这就是我们创建快速应用程序的方式。但是这个'express()'是什么?它是方法还是构造函
我在尝试安装时收到以下错误 express : npm ERR! code ERR_OSSL_PEM_NO_START_LINE npm ERR! errno ERR_OSSL_PEM_NO_STAR
如 express 所述routing guide和 this answer ,我们可以创建“迷你应用程序”并从主应用程序使用它。但是我看到一段代码,它在模块中使用 app 而不是 router ap
我正在写一个 NestJS应用。现在我想安装 Express中间件 express-openapi-validator . 但是,我无法让它工作。有一个 description for how to
我看过很多类似的帖子,似乎我声明的 var1 似乎需要在其他地方传递,但我似乎无法弄清楚。 public Expression> CreateEqualNameExpression(string ma
Express(或 Connect 的)bodyParser 中间件被标记为已弃用,建议用户改用: app.use(connect.urlencoded()) app.use(connect.json
我只是想知道这种看似尴尬的配置的原因是什么(来自 Getting Started w/ Apollo Server ), const server = new ApolloServer({ //
我正在尝试在表单组中写入表单控件特定的验证错误消息。我在网上找到了几个教程和示例 ( such as this one ),概述了一个看似简单的 *ngIf div,如果在控件上检测到错误,则显示错误
我有一个简单的 Express 应用程序,托管在 AWS 上,使用无服务器框架。 我正在使用 serverless-http 包装 express 应用程序以部署到 AWS lambda 函数,并使用
我最近在 mozilla 教程的帮助下安装了 node 和 express。我正在安装应用程序生成器的下一步,但是当我运行时 npm install express-generator -g 在我的终
我遇到过两种不同的方式来定义 express、use() 中间件,我想知道它们之间是否有任何区别,或者它是否只是语法糖? 一个 const app = express(); app.use(cors(
我试图让我的 Jade 模板编写一个相对于当前 URL 的超链接 ( )。 例如,我的 View 是从 http://localhost/cats 调用的它看起来像这样: extends layou
检查 Express 文档我在下面看到了这种解决方案: app.all('/*', function(req, res) { console.log('Intercepting request
我似乎无法弄清楚如何包含多个模型。 我有三个模型。Tabs, Servers, and PointsTabs hasMany ServerServers belongsTo Tabs and hasM
我已使用Web PI安装IIS Express。在托盘中,没有IIS Express图标。如何在不使用命令行的情况下启动IIS Express?我希望IIS永久运行,因此没有命令行。 最佳答案 参见R
我不想在我的网站上使用 Jade 或 EJS。如何在不默认使用 Jade 模板的情况下创建快速站点?谢谢 最佳答案 如果您想要的是直接为静态 html 文件提供缓存资源的可能性,同时仍然能够点击“/”
Express是否支持HTTP动词“PATCH”,例如: app.patch("/api/resource", function(req, res){ ... }); 我检查了文档,对我来说似乎还不清
我正在快速服务器中运行 vue SPA。问题是当使用历史模式并刷新页面时,我得到一个 404 not found 异常。我尝试使用 connect-history-api-fallback 但不起作用
我是一名优秀的程序员,十分优秀!