GVKun编程网logo

Redis (error) NOAUTH Authentication required.

5

在本文中,我们将给您介绍关于Redis(error)NOAUTHAuthenticationrequired.的详细内容,此外,我们还将为您提供关于407ProxyAuthenticationRequ

在本文中,我们将给您介绍关于Redis (error) NOAUTH Authentication required.的详细内容,此外,我们还将为您提供关于407 Proxy Authentication Required、An application is attempting to perform an action that requires privileges. Authentication is requir、asp.net – 如何在不使用FormsAuthentication.RedirectFromLoginPage时将Request.IsAuthenticated设置为true?、asp.net-core – options的用途.AutomaticAuthenticate with UseJwtBearerAuthentication的知识。

本文目录一览:

Redis (error) NOAUTH Authentication required.

Redis (error) NOAUTH Authentication required.

首先查看 redis 设置密码没

127.0.0.1:6379> config get requirepass
1) "requirepass"
2) ""

 表示没有设置密码,设置 redis 密码

127.0.0.1:6379> config set requirepass "acy123@@"
OK

 这个时候查看密码是会报错的。

127.0.0.1:6379> config get requirepass
(error) NOAUTH Authentication required.

需要 noauth 身份验证。

127.0.0.1:6379> auth acy123@@
OK
127.0.0.1:6379> config get requirepass
1) "requirepass"
2) "acy123@@"
127.0.0.1:6379>

修改密码

127.0.0.1:6379> config set requirepass "123456"
OK
127.0.0.1:6379> auth 123456
OK
127.0.0.1:6379> config get requirepass
1) "requirepass"
2) "123456"
127.0.0.1:6379> auth acy123@@
(error) ERR invalid password
127.0.0.1:6379>

 

407 Proxy Authentication Required

407 Proxy Authentication Required

The only way I''m currently aware of for disabling proxies entirely is the following:

  • Create a session
  • Set session.trust_env to False
  • Create your request using that session
import requests

session = requests.Session()
session.trust_env = False
url = "xxxxx"
response = session.get(url)

If however you only want to disable proxies for a particular domain (like localhost), you can use the NO_PROXY environment variable:

import os
import requests

os.environ[''NO_PROXY''] = ''qq.com''

response = requests.get(''http://www.qq.com'')

An application is attempting to perform an action that requires privileges. Authentication is requir

An application is attempting to perform an action that requires privileges. Authentication is requir

An application is attempting to perform an action that requires privileges. Authentication is required to perform this action.
resolve  :   sudo command...

asp.net – 如何在不使用FormsAuthentication.RedirectFromLoginPage时将Request.IsAuthenticated设置为true?

asp.net – 如何在不使用FormsAuthentication.RedirectFromLoginPage时将Request.IsAuthenticated设置为true?

我使用表单身份验证,并向服务器发送Aajx请求进行身份验证。基于json结果,客户端决定去哪里和做什么。这是我不使用FormsAuthentication.RedirectFromLoginPage不干扰ajax / json响应的原因。

在这种情况下,即使在使用Membership.ValidateUser验证用户后,Request.IsAuthenticated也返回false。然后我设置cookie使用

FormsAuthentication.SetAuthCookie(username,false);

虽然第二个参数,持久cookie,是false,cookie仍然有效跨浏览器会话。

任何想法如何使Request.IsAuthenticated工作,而不使用FormsAuthentication.RedirectFromLoginPage?

解决方法

您需要更新请求的当前安全主体。当您调用Response。重定向(…)一个新的请求完成,安全主体被重新初始化,并且Request.IsAuthenticated在你的case返回true。 FormsAuthentication.RedirectFromLoginPage内部调用响应。重定向(…)。您可以手动更新当前请求的安全主体,如下所示:
public void RenewCurrentUser()
{
    System.Web.HttpCookie authCookie =
        System.Web.HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName];
    if (authCookie != null)
    {
        FormsAuthenticationTicket authTicket = null;
        authTicket = FormsAuthentication.Decrypt(authCookie.Value);

        if (authTicket != null && !authTicket.Expired)
        {
            FormsAuthenticationTicket newAuthTicket = authTicket;

            if (FormsAuthentication.SlidingExpiration)
            {
                newAuthTicket = FormsAuthentication.RenewTicketIfOld(authTicket);
            }
            string userData = newAuthTicket.UserData;
            string[] roles = userData.Split(',');

            System.Web.HttpContext.Current.User =
                new System.Security.Principal.GenericPrincipal(new FormsIdentity(newAuthTicket),roles);
        }
    }
}

asp.net-core – options的用途.AutomaticAuthenticate with UseJwtBearerAuthentication

asp.net-core – options的用途.AutomaticAuthenticate with UseJwtBearerAuthentication

在将代码库从ASP 5 beta 7更新到RC1-final之后,我开始从JwtBearer中间件接收此异常

Unable to cast object of type 'Newtonsoft.Json.Linq.JArray' to type 'System.IConvertible'.

到目前为止我可以看到的决定因素似乎是选项的设置.AutomaticAuthenticate.如果这是真的,那么我得到例外,否则,我没有.

什么是AutomaticAuthenticate,为什么我需要启用它?

app.UseJwtBearerAuthentication(options =>
    {
        options.AutomaticAuthenticate = true; 
    }

这是完整的堆栈跟踪:

at System.Convert.ToInt32(Object value,IFormatProvider provider)
   at System.IdentityModel.Tokens.Jwt.JwtPayload.GetIntClaim(String claimType)
   at System.IdentityModel.Tokens.Jwt.JwtPayload.get_Nbf()
   at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.Validatetoken(String token,TokenValidationParameters validationParameters,SecurityToken& validatedToken)
   at Microsoft.AspNet.Authentication.JwtBearer.JwtBearerHandler.<HandleAuthenticateAsync>d__1.MoveNext()
--- End of stack trace from prevIoUs location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw()
   at Microsoft.AspNet.Authentication.JwtBearer.JwtBearerHandler.<HandleAuthenticateAsync>d__1.MoveNext()
--- End of stack trace from prevIoUs location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Microsoft.AspNet.Authentication.AuthenticationHandler`1.<InitializeAsync>d__48.MoveNext()
--- End of stack trace from prevIoUs location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at Microsoft.AspNet.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
--- End of stack trace from prevIoUs location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at Api.Startup.<<Configure>b__9_0>d.MoveNext() in ...\Startup.cs:line 156

更新根本原因

我们的代码库正在为nbf,exp和iat创建重复声明.这就解释了为什么get_Nbf在堆栈跟踪中以及关于“JArray”的抱怨,因为每个值都是数组而不是值.

解决方法

如果设置为true,则中间件将在每个入站请求上运行,查找JWT令牌,如果存在,则将验证它,如果有效则从中创建标识并将其添加到当前用户.

如果它没有发生,那么您需要通过在authorize属性中指定承载的方案来请求中间件设置标识.

[Authorize(AuthenticationSchemes = "YourBearerSchemeName")]

或者你在政策中设置这个;

options.AddPolicy("RequireBearer",policy =>
{
    policy.AuthenticationSchemes.Add("YourBearerSchemeName");
    policy.RequireAuthenticatedUser();

});

因此,通过将其设置为false,您实际上并没有运行持有者的东西,直到您要求它为止,您只是将异常关闭直到稍后.

关于Redis (error) NOAUTH Authentication required.的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于407 Proxy Authentication Required、An application is attempting to perform an action that requires privileges. Authentication is requir、asp.net – 如何在不使用FormsAuthentication.RedirectFromLoginPage时将Request.IsAuthenticated设置为true?、asp.net-core – options的用途.AutomaticAuthenticate with UseJwtBearerAuthentication等相关知识的信息别忘了在本站进行查找喔。

本文标签: