Tag: 基本authentication

节点护照邀请策略

我正在创build一个多用户的应用程序,只有pipe理员可以通过邀请添加新用户。 我看护照,但没有看到实施一种“邀请策略”(类似于RoR的devise)的方式; 有任何想法吗 ?

将非用户字段添加到有效内容以用于JWT令牌

您好我正在寻找添加一个非用户字段的身份validation过程中的有效载荷,所以我可以包含在JWT令牌。 请求是这样的: { "scriptId": "script1", "password": "password", "userName": "user1" } configuration是这样的: "auth": { "local": { "usernameField" : "scriptId" }, "token": { "secret": "mysecret", "payload": ["scriptId","userName"], "expiresIn": "10min" }, "successRedirect": "/chat.html" } 我怎样才能传递userName参数,所以我可以在auth /令牌服务的前钩子检索它,所以我可以把它的hook.data 或者如果有更好的方法来做,只需让我知道。

关心JWT安全

最近,我使用护照和node.js实现了JWT策略…但是,我开始担心这个概念。 一旦有人访问了智威汤逊,是否可以用来检索受保护的数据呢? 而不是获得访问JWT,就像使用chrome开发工具一样简单? 我可以尝试减less失效date,但是……只要用户的详细信息是相同的,每次产生的令牌也是一样的,这是不是真的? 那么到期日是什么时候,如果你最后还是以同样的道理结束呢? 我相信我在某处错过了这个观点。 指导将不胜感激。 谢谢。

在对Google表单进行多次调用时,API身份validation不适用于第二次调用:请求的身份validation范围不足

所以基本上我在这里所做的是我为我自己的目的劫持了Google表格api node.js快速入门指南。 一切都在这里工作,直到它碰到我的spreadsheets.batchUpdate,然后一切都变得古怪。 如果我注释掉spreadsheets.batchUpdate中的“auth”初始化,我会收到错误消息: The API returned an error: Error: The request does not have valid authentication credentials. 如果我注释掉spreadsheets.batchUpdate中的“auth”初始化,我得到错误消息: The API returned an error: Error: Request had insufficient authentication scopes. 所有我想要做的这些调用是从表中获取一些数据,然后删除行后,但我无法弄清楚这个身份validation问题。 var fs = require('fs'); var updateDB = require('./updateDB.js'); var readline = require('readline'); var google = require('googleapis'); var googleAuth = require('google-auth-library'); var splitData; // If […]

用户在Firebase / Node.js中全局logging

我遇到了Firebase的问题。 我正在尝试使用Node.js(客户端),这意味着我在Express上初始化SDK,而不是在客户端上: // initializing Firebase Node.js (Client) const configFb = { apiKey: "key", authDomain: "xxx.firebaseapp.com", databaseURL: "https://xxxx.firebaseio.com", storageBucket: "xxxx.appspot.com" }; firebase.initializeApp(configFb); 而且我也在使用SDK Admin。 问题是:一旦有人login,这个用户将是唯一一个login。 如果我在这里打开应用程序,我将与他的帐户login。 如果我退出,此用户也将被注销。 我做错了什么? 谢谢!

如何在函数内的node.js中返回一个导入的模块?

我是一个创build一个node.js单页面的应用程序。 如果用户通过validation,我想在主页中显示特定的视图。 为此,我创build了一个函数来检查用户是否是auth。 它工作正常。 但是,当我想要返回一个特定的视图时,我会遇到一些问题。 我尝试了几种不同的方法,但是我不能返回任何视图。 意见 const notAuth = require('../view1') const isAuth = require('../view2') 这是我第一次尝试: const home = function (ctx) { if (ctx.auth) { return isAuth } else { return notAuth } } module.exports = home 然后,我试图只使用module.exports : module.exports = function home (ctx, next) { if (ctx.auth) { return isAuth } else { return […]

如何限制API只能在浏览器中运行?

我正在使用节点js,我把政策限制在api的浏览器的保证。为此,我把以下条件 app.route('/students').all(policy.checkHeader).get(courses.list) exports.checkHeader = function(req, res, next) { var headers = req.headers; if ( headers['upgrade-insecure-requests'] || headers['postman-token']) { res.status(401).json('Page not found'); } else { return next(); } } 我不知道我的过程是否正确。我正在寻找只存在于浏览器中的公共参数(header-parameter)。是否有人可以帮助我。谢谢。

我的AJAX代码(将Firebase令牌发送到服务器)有什么问题?

我是初学者。 我试图通过AJAX从login用户的状态发送的令牌发送。 但是,当我运行下面的代码,我得到内部服务器错误,所以一些东西closures。 我错过了什么? app.post('/auth', function(req,res,next){ var idToken = admin.auth().verifyIdToken(idToken) .then(function(decodedToken) { var uid = decodedToken.uid console.log(uid) res.send(uid) }).catch(function(error) { console.log(error.message) }) }) $("#sign-in").on('click', function(event) { event.preventDefault() var email = $("#email").val() var password = $("#password").val() firebaseAUTH.signInWithEmailAndPassword(email, password).then(function (user) { console.log('user has signed in with e-mail address: '+user.email+' and user ID: '+user.uid) //window.location = '/members-area' firebaseAUTH.currentUser.getToken(true).then(function(idToken) […]

NodeJS&Express身份validation中间件无法正常运行

我试图运行函数isUserAuthenticated每个请求到服务器通过要求它在app.js和'使用'它是这样的: app.use(authenticate.isUserAuthenticated) 。 我有一个/authenticatecallback路由,由我们的SAML身份提供商POSTED,其中包含validation用户和会话所需的信息。 这是我的authenticate.js文件中的内容: module.exports = router; module.exports.isUserAuthenticated = function(req, res, next) { console.log(req.cookies.subject); if (req.cookies.subject) { console.log(req.cookies.subject) return next(); } res.redirect("LINK TO IDP FOR VERIFICATION, callback func. is then ran to get value of user and session"); } 正如所引用的,这个authentication函数在app.js需要和使用: authenticate = require('./routes/authenticate')和app.use(authenticate.isUserAuthenticated) 。 问题:无论if语句的哪个变体validation请求中是否存在主题cookie,身份validation检查都不会被触发,redirect到IDP身份validation路由也不会被redirect。 上面的代码中的console.log检查正在返回: undefined和{} 。 当我使用isUserAuthenticated函数像这样: router.use('/', isUserAuthenticated, function(req, res, next) […]

在进行api调用时,Docusign遗留标头错误

尝试使用Docusign API的传统标头时收到错误消息。 这是我的代码 request({ headers: { "X-DocuSign-Authentication": [{ "Username": "zabie@toplevelstaging.com", "Password": "xxxxxxxx", "IntegratorKey": "xxxxxxxxxxx-11xxx2f567xxxx0dbxxxx2d" }] }, url: "https://demo.docusign.net/restapi/v2/accounts/3465212/envelopes", json: true, // <–Very important!!! body: data, method: "POST", }, function (error, response, body) { console.log(response.body); }); console.log(data[0].templateRoles[0].tabs.textTabs[0].value); console.log(data[0].templateRoles[0].roleName); res.redirect('/contracts'); }); 这是错误 { errorCode: 'INVALID_TOKEN_FORMAT', message: 'The security token format does not conform to expected schema.' }