我正在开发基于Spring MVC的webapp.
下面是我的环境信息: - ,
Java 1.8.0_162 (64 bit)
,,Spring 4.3.1
为SSO,和.Apache Tomcat 8.0.49
Waffle-1.8.3
jquery-1.11.3
Google Charts API
将以下JavaScript代码放在一个常见的JS文件中: -
$.ajaxSetup({ cache: false });
POST
对服务器的jQuery AJAX 请求在Mozilla和Chrome浏览器中完美运行.但是当谈到IE 11浏览器时,jQuery AJAX POST
请求只有在第一次加载窗口时才能正常工作.然后随机失败并且一旦失败,后续请求也会失败.
以下是IE 11浏览器的" 网络"选项卡的快照: -
这两个请求在其各自的请求主体中都有JSON对象.但是,成功请求的Content-Length
属性值为416(字符串化JSON对象的总字符数),失败的属性值为0.对于随机失败的POST
请求和后续请求,Content-Length
始终为0,但计算的JSON对象始终存在于请求正文中.在每个请求中,JSON对象都是动态构建的.
UPDATE-1(26March2018)以下是文件中Waffle
定义的AD身份验证配置web.xml
: -
<filter>
<filter-name>SecurityFilter</filter-name> …
Run Code Online (Sandbox Code Playgroud) 我一直在努力使用spring java配置来解决使用spring 4.2.5的问题.我想我也可以在同样的情况下帮助别人.
我们使用自定义preWaffle和postWaffle过滤器来验证用户在通过华夫饼NTLM协议验证后存在于我们的数据库中.
我们还有使用EnableGlobalMethodSecurity批注授权用户操作的方法.
为了让这个工作在春季java配置是一些麻烦,至少可以说.您可以在下面的答案中找到我们的解决方案.我希望它会有所帮助.
我正在测试 ERC721 代币的智能合约,该代币继承自 OpenZeppelin,使用 waffle 和 chai 以及 NodeJS v14.18.0,但 chai 的恢复断言似乎没有按预期运行。
依赖项:
"devDependencies": {
"@nomiclabs/hardhat-ethers": "^2.0.1",
"@nomiclabs/hardhat-etherscan": "^2.1.0",
"@nomiclabs/hardhat-waffle": "^2.0.1",
"@typechain/ethers-v5": "^5.0.0",
"@types/chai": "^4.2.14",
"@types/mocha": "^8.2.0",
"@types/node": "^14.14.14",
"chai": "^4.2.0",
"dotenv": "^8.2.0",
"ethereum-waffle": "^3.2.1",
"ethers": "^5.0.24",
"hardhat": "^2.0.5",
"hardhat-typechain": "^0.3.4",
"ts-generator": "^0.1.1",
"ts-node": "^9.1.1",
"typechain": "^4.0.1",
"typescript": "^4.1.3"
},
Run Code Online (Sandbox Code Playgroud)
示例代码:
let genesisTokenHolders: Array<string>;
beforeEach(async () => {
genesisTokenHolders = new Array(230).fill('0x0000000000000000000000000000000000000000')
genesisTokenHolders[1] = addr1.address;
genesisTokenHolders[2] = addr2.address;
})
describe('airdrop genesis tokens', async () => {
it('should fail when non-owner …
Run Code Online (Sandbox Code Playgroud) 我正在尝试在Windows上实现SSO(在Java中).最近我发现这个例子完全符合我对Waffle的要求:
// client credentials handle
IWindowsCredentialsHandle credentials= WindowsCredentialsHandleImpl.getCurrent("Negotiate");
credentials.initialize();
// initial client security context
WindowsSecurityContextImpl clientContext = new WindowsSecurityContextImpl();
clientContext.setPrincipalName(Advapi32Util.getUserName());
clientContext.setCredentialsHandle(credentials.getHandle());
clientContext.setSecurityPackage(securityPackage);
clientContext.initialize();
// accept on the server
WindowsAuthProviderImpl provider = new WindowsAuthProviderImpl();
IWindowsSecurityContext serverContext = null;
do {
if (serverContext != null) {
// initialize on the client
SecBufferDesc continueToken = new SecBufferDesc(Sspi.SECBUFFER_TOKEN, serverContext.getToken());
clientContext.initialize(clientContext.getHandle(), continueToken);
}
// accept the token on the server
serverContext = provider.acceptSecurityToken(clientContext.getToken(), "Negotiate");
} while (clientContext.getContinue() || serverContext.getContinue());
System.out.println(serverContext.getIdentity().getFqn());
for …
Run Code Online (Sandbox Code Playgroud) 我正在尝试从http://repo1.maven.org/maven2/com/github/dblock/waffle/waffle-filter-demo/1.6/waffle-filter-demo-1.6下载华夫饼'华夫饼过滤器演示'的演示 .战争
我使用tomcat作为servlet容器并部署war文件.
当我尝试使用URL http:// localhost:8080/waffle-filter-demo-1.6访问服务器时,我可以通过当前的Windows登录进行身份验证,并且我的Windows用户已经过身份验证.
但是当我使用IP地址http:// 192.168.2.63:8080/waffle-filter-demo-1.6/访问相同的URL时.华夫饼要我输入用户名和密码.
以前有人遇到过这种情况吗?如何通过使用IP地址访问来获得身份验证成功?
我正在尝试获取已经过身份验证的当前用户的所有角色并在JSP页面中显示它们.
我注意到这里列出了一些内置表达式:http://static.springsource.org/spring-security/site/docs/3.0.x/reference/el-access.html但我没有看到任何内容列出所有角色.
我正在使用以下代码来获取实际登录的用户:
IWindowsSecurityContext clientContext = WindowsSecurityContextImpl.getCurrent("Negotiate", "localhost");
WindowsAuthProviderImpl provider = new WindowsAuthProviderImpl();
IWindowsSecurityContext serverContext = null;
do {
if (serverContext != null) {
byte[] tokenForTheClientOnTheServer = serverContext.getToken();
SecBufferDesc continueToken = new SecBufferDesc(Sspi.SECBUFFER_TOKEN, tokenForTheClientOnTheServer);
clientContext.initialize(clientContext.getHandle(), continueToken, "localhost");
}
byte[] tokenForTheServerOnTheClient = clientContext.getToken();
serverContext = provider.acceptSecurityToken("server-connection", tokenForTheServerOnTheClient, "Negotiate");
System.out.println("SSO-Identity: " + serverContext.getIdentity().getFqn());
} while (clientContext.getContinue());
System.out.println("Identity: " + serverContext.getIdentity().getFqn());
Run Code Online (Sandbox Code Playgroud)
当我在Eclipse中启动它并返回我的用户名时,它运行良好。
当我部署Web应用程序并在Tomcat中启动它时,它将返回nt-authority \ system。但是我需要实际登录用户的名称。(在Tomcat中使用Waffle SSO可以正常工作,但是我无法获得用户名)
拜托,有人知道吗?
编辑:Eclipse中的用户主体也是正确的。当我从Tomcat启动时,它始终为null。
我在服务中将Spring Security与Waffle一起使用。当我在本地连接服务(浏览器和Tomcat在同一台计算机上启动)时,一切工作都很好(浏览器不询问登录名和密码)。当我从另一台计算机连接到服务时,浏览器总是询问登录名和密码。
这是我的web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>Struts 2 Spring Security 4</display-name>
<!--SPRING SECURITY-->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring-security/context.xml
</param-value>
</context-param>
<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>
<!--SPRING SECURITY-->
<filter>
<filter-name>SecurityFilter</filter-name>
<filter-class>waffle.servlet.NegotiateSecurityFilter</filter-class>
<init-param>
<param-name>waffle.servlet.spi.NegotiateSecurityFilterProvider/protocols</param-name>
<param-value>
Negotiate
NTLM
</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>SecurityFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Struts 2-->
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Struts 2-->
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<listener>
<listener-class>org.springframework.security.web.session.HttpSessionEventPublisher</listener-class>
</listener>
<!-- Struts Tiles Listener -->
<listener> …
Run Code Online (Sandbox Code Playgroud) 在官方华夫饼文档中,您可能会找到实现装置的下一种方法:
import {expect} from 'chai';
import {loadFixture, deployContract} from 'ethereum-waffle';
import BasicTokenMock from './build/BasicTokenMock';
describe('Fixtures', () => {
async function fixture([wallet, other], provider) {
const token = await deployContract(wallet, BasicTokenMock, [
wallet.address, 1000
]);
return {token, wallet, other};
}
it('Assigns initial balance', async () => {
const {token, wallet} = await loadFixture(fixture);
expect(await token.balanceOf(wallet.address)).to.equal(1000);
});
it('Transfer adds amount to destination account', async () => {
const {token, other} = await loadFixture(fixture);
await token.transfer(other.address, 7);
expect(await token.balanceOf(other.address)).to.equal(7);
});
});
Run Code Online (Sandbox Code Playgroud)
但是,在安全帽上使用该插件时这将不起作用。插件文档没有给出官方说明。
回答如下。
我正在使用 Spring Security 与 Waffle 相结合来对我的 web 应用程序的用户进行身份验证。我使用以下配置配置了 Spring Security:
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.annotation.web.servlet.configuration.EnableWebMvcSecurity;
import org.springframework.security.web.authentication.www.BasicAuthenticationFilter;
import waffle.servlet.spi.BasicSecurityFilterProvider;
import waffle.servlet.spi.NegotiateSecurityFilterProvider;
import waffle.servlet.spi.SecurityFilterProvider;
import waffle.servlet.spi.SecurityFilterProviderCollection;
import waffle.spring.NegotiateSecurityFilter;
import waffle.spring.NegotiateSecurityFilterEntryPoint;
import waffle.windows.auth.impl.WindowsAuthProviderImpl;
@Configuration
@EnableWebMvcSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private NegotiateSecurityFilterEntryPoint entryPoint;
@Autowired
private NegotiateSecurityFilter filter;
@Override
protected void configure(HttpSecurity http) throws Exception {
http.exceptionHandling().authenticationEntryPoint(entryPoint);
http.addFilterBefore(filter, BasicAuthenticationFilter.class).authorizeRequests().anyRequest()
.fullyAuthenticated();
}
@Bean
public WindowsAuthProviderImpl windowsAuthProviderImpl() {
return new WindowsAuthProviderImpl();
}
@Bean
public NegotiateSecurityFilterProvider negotiateSecurityFilterProvider(final …
Run Code Online (Sandbox Code Playgroud) waffle ×10
java ×5
solidity ×2
spring ×2
ajax ×1
chai ×1
ethereum ×1
ethers.js ×1
hardhat ×1
jquery ×1
kerberos ×1
openzeppelin ×1
spring-mvc ×1
tomcat ×1
typescript ×1