jjzjj

IsAuthenticated

全部标签

node.js - 如何在 Express 中模拟中间件以跳过单元测试的身份验证?

我在Express中有以下内容//index.jsvarservice=require('./subscription.service');varauth=require('../auth/auth.service');varrouter=express.Router();router.post('/sync',auth.isAuthenticated,service.synchronise);module.exports=router;我想覆盖或模拟isAuthenticated以返回此auth.isAuthenticated=function(req,res,next){retur

node.js - 如何在 Express 中模拟中间件以跳过单元测试的身份验证?

我在Express中有以下内容//index.jsvarservice=require('./subscription.service');varauth=require('../auth/auth.service');varrouter=express.Router();router.post('/sync',auth.isAuthenticated,service.synchronise);module.exports=router;我想覆盖或模拟isAuthenticated以返回此auth.isAuthenticated=function(req,res,next){retur

node.js - Passport 的 req.isAuthenticated 总是返回 false,即使我硬编码 done(null, true)

我正在尝试让我的Passport本地策略发挥作用。我已经设置了这个中间件:passport.use(newLocalStrategy(function(username,password,done){//returndone(null,user);if(username=='ben'&&password=='benny'){console.log("Passwordcorrect");returndone(null,true);}elsereturndone(null,false,{message:"IncorrectLogin"});}));然后在这里app.use('/admin'

node.js - Passport 的 req.isAuthenticated 总是返回 false,即使我硬编码 done(null, true)

我正在尝试让我的Passport本地策略发挥作用。我已经设置了这个中间件:passport.use(newLocalStrategy(function(username,password,done){//returndone(null,user);if(username=='ben'&&password=='benny'){console.log("Passwordcorrect");returndone(null,true);}elsereturndone(null,false,{message:"IncorrectLogin"});}));然后在这里app.use('/admin'

spring - isAuthenticated 和 isFullyAuthenticated 之间的区别

我正在尝试学习SpringSecurity,但我有疑问:SpringSecurity中的isAuthenticated和isFullyAuthenticated有什么区别 最佳答案 来自spring-security文档:isAuthenticated()ReturnstrueiftheuserisnotanonymousisFullyAuthenticated()Returnstrueiftheuserisnotananonymousoraremember-meuser 关于sprin

spring - isAuthenticated 和 isFullyAuthenticated 之间的区别

我正在尝试学习SpringSecurity,但我有疑问:SpringSecurity中的isAuthenticated和isFullyAuthenticated有什么区别 最佳答案 来自spring-security文档:isAuthenticated()ReturnstrueiftheuserisnotanonymousisFullyAuthenticated()Returnstrueiftheuserisnotananonymousoraremember-meuser 关于sprin

c# - 登录成功后User.Identity.IsAuthenticated为false

登录成功后需要直接获取UserIdGuid。以下代码不起作用:if(Membership.ValidateUser(txtUsername.Value,txtPassword.Value)){FormsAuthentication.SignOut();FormsAuthentication.SetAuthCookie(txtUsername.Value,true);if(HttpContext.Current.User.Identity.IsAuthenticated){//doesn'trunGuidpuk=(Guid)Membership.GetUser().ProviderUse

c# - 具有 HttpContext.Current.User.Identity.IsAuthenticated 的 Webmethods 在 Azure 上不活动后停止工作

我正在使用使用Ajax(json)/Webmethod函数的页面测试Azure服务器。其中一些函数在运行代码之前会检查HttpContext.Current.User.Identity.IsAuthenticated。不幸的是,如果用户已登录并且页面没有向服务器发出完整的回发请求,则只有那些检查HttpContext.Current.User.Identity.IsAuthenticated的webmethods函数会在一对夫妇之后完全停止运行分钟没有给出任何错误。他们甚至不运行else代码块(见下文)。我已经在本地服务器上测试了这些页面,一切正常,即使在长时间不活动之后也是如此。这是

c# - 为什么我的 ClaimsIdentity IsAuthenticated 总是错误的(对于 web api 授权过滤器)?

在WebAPI项目中,我覆盖了正常的身份验证过程以检查token。代码看起来像这样:if(true)//validatethetokenorwhateverhere{varclaims=newList();claims.Add(newClaim(ClaimTypes.Name,"MyUser"));claims.Add(newClaim(ClaimTypes.NameIdentifier,"MyUserID"));claims.Add(newClaim(ClaimTypes.Role,"MyRole"));varclaimsIdentity=newClaimsIdentity(clai

node.js - Passport JS 中的 req.isAuthenticated() 是如何实现的?

关闭。这个问题需要更多focused.它目前不接受答案。想要改进这个问题吗?更新问题,使其只关注一个问题editingthispost.关闭6年前。Improvethisquestion在passportJS文档中,我认为PassportisAuthenticated功能没有很好地记录。PassportJS中的req.isAuthenticated()是如何实现的? 最佳答案 对于任何请求,您都可以使用此方法检查用户是否已通过身份验证。app.get('/some_path',checkAuthentication,function