security - 微前端如何使用 Apache Wicket 工作?
问题描述
我想使用 Apache Wicket 实现微前端架构,但我无法让它工作。
add(new WebMarkupContainer("testFrame") {
@Override
protected void onComponentTag(ComponentTag tag) {
checkComponentTag(tag, "iframe");
super.onComponentTag(tag);
//Won't work like this if you want to send credentials.
//tag.put("src", "http://localhost:8089/httpBasicAuthenticated/url/page/");
}
@Override
public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
Response response = getRequestCycle().getResponse();
final CredentialsProvider provider = new BasicCredentialsProvider();
String username = "user";
String password = "password";
final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(username, password);
provider.setCredentials(AuthScope.ANY, credentials);
final HttpClient client = HttpClientBuilder.create().setDefaultCredentialsProvider(provider).build();
HttpResponse httpResponse = null;
String body = "";
try {
httpResponse = client.execute(new
HttpGet("http://localhost:8089/httpBasicAuthenticated/url/page/"));
body = IOUtils.toString(httpResponse.getEntity().getContent(), "UTF-8");
} catch (final IOException e) {
e.printStackTrace();
}
response.write(body);
}
});
我正在尝试使用 iframe,但它没有在 iframe 内呈现页面。有什么不对?我将如何通过 iframe 根据页面请求发送凭据?
编辑: 在这段代码中,我试图自动发送凭据,以便不显示身份验证提示。
解决方案
使用基本身份验证,您需要呈现<iframe src="..."></iframe>
,浏览器将显示一个对话框以输入凭据。
如果您在服务器上构建主体(即在 Wicket 代码中),那么您不需要 iframe,而是需要一个div
.
推荐阅读
- c# - C# 通过注册表获取 Windows 驱动器硬件标题
- javascript - 反应错误 index.js:1452 警告:数组或迭代器中的每个孩子都应该有一个唯一的“键”道具
- regex - 6位数字的正则表达式彼此靠近
- elasticsearch - 在 elasticsearch 中使用多个标记进行全文搜索
- javascript - 酶 shallow() 和 addEventListener
- http - AD v2.0 端点 HTTP 重定向 url
- android - 智能转换为“TaskAdapter”是不可能的,因为“recyclerView.adapter”是一个复杂的表达式
- list - 列表在 Kentico 宏中按字母顺序排序
- nlp - 依赖解析器失败的示例
- c - C中动态数组中的未初始化值