【发布时间】:2019-03-14 21:26:05
【问题描述】:
我目前正在使用护照在 node.js 中使用二重奏,看看我是否可以将它实现到测试应用程序中......我正在使用护照二重奏来执行此操作,并且位于 GitHub 存储库here 我尝试使用给出的示例,但无法在我自己的应用程序中使用。
但似乎每次我去为 duo 加载 iframe 时,它总是给我同样的错误ERR|The username passed to sign_request() is invalid.
它不断跌倒的sn-p如下:
app.get('/login-duo', checkLoggedIn, function (req, res, next) {
console.log(req.user);
console.log(req.user['id']);
console.log(req.query.host);
console.log(req.query.post_action);
console.log(req.query.signed_request);
var username= req.user['id'];
res.render('login-duo', {
user : req.user['id'],
host : req.query.host,
post_action : req.query.post_action,
sig_request : req.query.signed_request
});
});
HTML
<!DOCTYPE html>
<html>
</script>
<style>
body {
background: #f1f1f1;
}
.iframe_div {
width: 90%;
max-width: 620px;
margin: 0 auto;
}
#duo_iframe {
height: 500px;
width: 100%;
}
div {
background: transparent;
}
</style>
<form method="POST" style="display:none;" id="duo_form">
</form>
<meta name="viewport" content="width=device-width, initial-scale=1">
<head>
<title>Passport-Duo Example</title>
</head>
<body>
<div class="iframe_div">
<iframe id="duo_iframe" frameborder="0" allowtransparency="true"></iframe>
</div>
</body>
<script src="js/Duo-Web-v1.bundled.min.js"></script>
<script>
Duo.init({
'host': '<%= host %>',
'post_action': '<%= post_action %>',
'sig_request': '<%= sig_request %>'
});
</script>
</html>
想知道任何有实施护照二重奏经验的人,并且知道为什么sig_request 会抛出该错误。
【问题讨论】:
标签: javascript node.js authentication passport.js