- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我只需要在公共(public)域 example.local
内进行安全重定向。因此,例如以下内容是有效的:http://blog.example.local
、http://www.example.local/dashboard
而以下内容则不是:http://blog.example.local
http://blog.example.local.fake.com
var url = require('url');
app.post('/login', function (req, res, next) {
var redirect = req.query.redirect,
targetUrl = url.parse(redirect);
if (targetUrl.host !== 'example.local') {
return next(new Error('Open redirect attack detected'));
}
return res.redirect(redirect);
});
在生产中使用它是否足够安全,或者我应该修复一些东西吗?
最佳答案
在您的代码中,如果 targetUrl = 'http://blog.example.local'
,您的应用将返回错误“检测到打开重定向攻击”,因为 targetUrl.host 将为“blog.example” .local'
请稍微更改您的代码以
var expectedHost = [
'blog.example.local',
'example.local'
];
if (expectedHost.indexOf(targetUrl.host) === -1) {
return next(new Error('Open redirect attack detected'));
}
那么一切都会好起来的
关于node.js - 使用 url.parse 检查 redirectURL 是否仅在域内安全?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38086865/
我说的是两者的 setter 方法而不是 getter 方法 对我来说 $location.url doesnt always 需要一段时间才能重定向,所以我正在考虑使用 $location.path
我的登录页面是这样工作的:当您输入它时,JavaScript 会从您那里读取一些信息,将其写入某些输入中并提交,以便服务器可以读取和处理读取的数据。 function getUserInfo
我已经尝试在我的 html 中使用 gigya showLoginUI javascript 插件。该插件呈现社交图标。我正在尝试使用 gigya 的重定向功能。我在我的 javascript 中提到
我的 EditFormTemplate 中有一个 SharePoint SaveButton,我不希望浏览器重定向到默认位置,即 ListView (即 AllItems.aspx)。我希望用户被重定
如何为 adobe flash express 安装指定重定向 URL?我正在使用swfobject 2.2 ,虽然我认为 flashvars 中的 MMredirectURL 可能是我所需要的,但这
我在 React Native 应用程序中使用 React Navigation。我使用他们所说的身份验证流程管理登录步骤。也就是说,如果我存储了 token ,则用户已登录,否则未登录。 我提供了几
基本上我想要完成的是这样的: [AllowAnonymous] public ActionResult MyAction(string id) { if (Reques
根据documentation on PayPal's Developer site在高级服务器集成下,重定向 URL 必须在付款调用中提供,但是: (…) PayPal does not autom
redirectURL 似乎没有回传任何数据。它似乎使用 GET 请求。我如何知道返回 URL 上的付款 ID 或付款状态? $payment = \mollie::api()->payments()
我正在使用 express-stormpath 来处理我的 nodejs 应用程序的用户管理功能。当访问/logout路由时,默认的redirectUrl为/。 我正在尝试将用户重定向到 /login
我正在使用 Ambassador OAuth2 过滤器对 Keycloak 执行 OAuth2 授权。对于注销,我使用 RP 启动的注销,如 Docs of Ambassador 中所述。注销工作正常
我只需要在公共(public)域 example.local 内进行安全重定向。因此,例如以下内容是有效的:http://blog.example.local、http://www.example.l
我正在尝试拦截 Web 请求并将它们重定向到我保存在本地存储中的 URL,但它不起作用。我的代码如下: chrome.webRequest.onBeforeRequest.addListener(
我是 React-Native 开发领域的新手,我正在尝试了解如何配置 FormidableLabs 的 react-native-app-auth 插件,以便我们应用程序的用户可以登录我们的 Ide
使用https://learn.microsoft.com/en-us/azure/active-directory/develop/active-directory-v2-devquickstart
我们正在使用此规则将 HTTP 重定向到 HTTPS:
在带有 Identity Framework 2 的 ASP.NET 4 中,我可以在 redirectUri 后附加一个我自己的参数,例如 Google 用来限制登录域的“hd”参数: var go
我是一名优秀的程序员,十分优秀!