我已经为标题中的问题苦苦挣扎了几天,我感到非常沮丧。我不知道我做错了什么以及为什么我的实现不起作用。
让我告诉你我有什么:
自定义身份验证提供程序:
@Component
public class AuthProvider implements AuthenticationProvider {
private Logger logger = LoggerFactory.getLogger(AuthProvider.class);
public AuthProvider() {
logger.info("Building...");
}
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
logger.info("Authenticate...");
return null;
}
public boolean supports(Class<?> authentication) {
logger.info("Supports...");
return true;
}
}
Run Code Online (Sandbox Code Playgroud)
网络安全配置:
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private AuthProvider authProvider;
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.authenticationProvider(authProvider);
}
@Override
public void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests().anyRequest().authenticated();
}
}
Run Code Online (Sandbox Code Playgroud)
如您所见,我已将记录器添加到 AuthenticationProvider 中,但并未调用任何记录器。
我试过的: …
我有这样的事情:
#container {
width: 300px;
background-color: red;
display: flex;
justify-content: center;
}
#child {
background-color: green;
width: 250px;
height: 150px;
position: relative;
top: 75px;
}Run Code Online (Sandbox Code Playgroud)
<div id="container">
<div id="child"></div>
</div>Run Code Online (Sandbox Code Playgroud)
红色框是容器,它的高度等于其内容 - 在本例中为 150px。我想要实现的是使容器高度等于其内容大小的一半。
我想要达到的效果是填充background-color容器内容的一半。
如果可以通过改变容器高度以外的其他方式来实现这一点 - 请随意提出解决方案。
我想为我的服务器创建集成测试。不幸的是,有许多错误情况我无法涵盖,因为这取决于我的项目深处的某些依赖项的失败。
为了更容易地解释这个问题,请考虑这个项目:
主要的:
const dep = require('./dep');
module.exports = () => {
return dep();
}
Run Code Online (Sandbox Code Playgroud)
依赖性:
const uuid = require('uuid/v4');
module.exports = () => {
return uuid();
}
Run Code Online (Sandbox Code Playgroud)
测试:
const t = require('tap');
const subject = require('./subject');
t.test('should return 12345', t => {
// mock uuid/v4 module to return 12345
const result = subject();
t.equal(result, '12345');
t.end();
});
Run Code Online (Sandbox Code Playgroud)
这是 1 级深度依赖情况,但可以考虑dependency为 5 级更深。
所以我来这里有几个问题:
重要的提示:
我已经尝试过许多模拟库(mock-require、、、、、) ,但它们中没有一个是在考虑集成测试的proxyquire情况下创建的(它们更专注于单元测试)。rewiretestdoublemockery …
所以我想从 Gatsby 的 GraphQL 查询一个不是数组的 JSON 文件,但我真的不知道该怎么做。
据我了解gatsby-transformer-json文档 - 它只支持加载数组并通过allFileNameJson模式访问它们。
我的gatsby-config插件(只有这个问题的必要插件):
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'data',
path: `${__dirname}/src/data`
}
},
'gatsby-transformer-json'
Run Code Online (Sandbox Code Playgroud)
然后让我们说src/data我有一个something.json文件,如下所示:
{
"key": "value"
}
Run Code Online (Sandbox Code Playgroud)
现在我想从something.json文件中查询数据,但没有somethingJson我可以查询的模式(尝试使用 Gatsby 的 GraphiQL)。
有人可以指出我做错了什么或者我该如何解决这个问题?
我想通过JWT身份验证来保护SPA专用路由。为了使所有内容尽可能地安全,我想使用httpOnlycookie将我的access_token内容存储在客户端。
使用httpOnlycookie可以保护我免受XSS攻击,但是不幸的是,这种方法不允许我检查cookie是否确实存在于浏览器中。
在这种情况下,如何实现一些逻辑以防止未登录的用户访问SPA的私有安全路由?
我是否被迫使用非httpOnlyCookie localStorage?