此处将为大家介绍关于NOAUTH需要身份验证。Laravel+Redis的详细内容,并且为您解答有关需要进行身份验证的相关问题,此外,我们还将为您介绍关于Gmail错误:SMTP服务器需要安全连接或客
此处将为大家介绍关于NOAUTH需要身份验证。Laravel + Redis的详细内容,并且为您解答有关需要进行身份验证的相关问题,此外,我们还将为您介绍关于Gmail 错误:SMTP 服务器需要安全连接或客户端未通过身份验证。服务器响应是:5.5.1 Authentication Required、Gmail错误:SMTP服务器需要安全连接,或者客户端未通过身份验证。服务器响应为:5.5.1需要身份验证、Guardian - 排除需要身份验证的路由、java – Spring OAuth2“访问此资源需要完全身份验证”的有用信息。
本文目录一览:- NOAUTH需要身份验证。Laravel + Redis(需要进行身份验证)
- Gmail 错误:SMTP 服务器需要安全连接或客户端未通过身份验证。服务器响应是:5.5.1 Authentication Required
- Gmail错误:SMTP服务器需要安全连接,或者客户端未通过身份验证。服务器响应为:5.5.1需要身份验证
- Guardian - 排除需要身份验证的路由
- java – Spring OAuth2“访问此资源需要完全身份验证”
NOAUTH需要身份验证。Laravel + Redis(需要进行身份验证)
我收到错误 NOAUTH必需的身份验证 。我的laravel版本是5.3,我正在使用predis 1.1.1连接redis。
在etc / redis / redis.conf中,我有:
bind 127.0.0.1requirepass somepassword
在.env文件中
REDIS_HOST=127.0.0.1REDIS_PASSWORD=somepasswordREDIS_PORT=6379
在config / database.php中,我有:
''redis'' => [ ''cluster'' => false, ''default'' => [ ''host'' => env(''REDIS_HOST'', ''127.0.0.1''), ''password'' => env(''REDIS_PASSWORD'', null), ''port'' => env(''REDIS_PORT'', 6379), ''database'' => 0, ],
我通过以下方式连接redis:
self::$_db = \Redis::connection(''default'');
并像这样使用它:
self::$_db->pipeline(function ($pipe) use ($profile, $time,$type, $id) { $pipe->zadd(self::getProfileKey($profile, $type), $time, $id); $pipe->zadd(self::getProfileKey($profile), $time, $type . '':'' . $id); $pipe->zadd(self::getModelKey($type,$id) . ''::favoritedBy'', $time, $profile->profile_id); });
因此,当我注释掉requirepass
并将密码发送为null时,它可以工作,但NOAUTH Authenticationrequired.
在密码到位后却无法工作并引发错误。我需要根据项目要求输入密码。请帮忙。提前致谢。
答案1
小编典典因此,在进行了一些研究之后,我得到了针对该问题的解决方案:
我们需要添加:
''options'' => [ ''parameters'' => [''password'' => env(''REDIS_PASSWORD'', null)], ],
在config
数组中。请参见下面的完整示例:database.php
''redis'' => [ ''cluster'' => false, ''default'' => [ ''host'' => env(''REDIS_HOST'', ''127.0.0.1''), ''password'' => env(''REDIS_PASSWORD'', null), ''port'' => env(''REDIS_PORT'', 6379), ''database'' => 3, ], ''options'' => [ ''parameters'' => [''password'' => env(''REDIS_PASSWORD'', null)], ], ],
在.env文件中:
REDIS_HOST=127.0.0.1REDIS_PASSWORD=mmdgreatREDIS_PORT=6379
Gmail 错误:SMTP 服务器需要安全连接或客户端未通过身份验证。服务器响应是:5.5.1 Authentication Required
我正在使用以下代码发送电子邮件。该代码在我的本地机器上正常工作。但是在生产服务器上我收到错误消息
var fromAddress = new MailAddress("mymailid@gmail.com");
var fromPassword = "xxxxxx";
var toAddress = new MailAddress("yourmailid@yourdoamain.com");
string subject = "subject";
string body = "body";
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient
{
Host = "smtp.gmail.com",Port = 587,EnableSsl = true,DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network,UseDefaultCredentials = false,Credentials = new NetworkCredential(fromAddress.Address,fromPassword)
};
using (var message = new MailMessage(fromAddress,toAddress)
{
Subject = subject,Body = body
})
smtp.Send(message);
在我的 Gmail A/c 上,从生产服务器运行代码后,我收到了以下电子邮件
你好 ,
最近有人使用您的密码尝试登录您的 Google 帐户 mymailid@gmail.com。此人正在使用电子邮件、客户端或移动设备等应用程序。
我们阻止了登录尝试,以防这是试图访问您帐户的劫持者。请查看登录尝试的详细信息:
2014 年 1 月 3 日星期五 13:56:08 点 UTC IP 地址:xxx.xx.xx.xxx (abcd.net.)
地点:Philadelphia PA,Philadelphia,PA,USA如果您无法识别此登录尝试,则其他人可能正在尝试访问您的帐户。您应该立即登录您的帐户并重置密码。
重设密码
如果这是您本人,并且您无法访问自己的帐户,请完成
http://support.google.com/mail?p=client_login中列出的故障排除步骤此致 Google 帐户小组敬上
Gmail错误:SMTP服务器需要安全连接,或者客户端未通过身份验证。服务器响应为:5.5.1需要身份验证
我正在使用以下代码发送电子邮件。该代码在我的本地计算机上正常工作。但是在生产服务器上,我收到错误消息
var fromAddress = new MailAddress("mymailid@gmail.com");
var fromPassword = "xxxxxx";
var toAddress = new MailAddress("yourmailid@yourdoamain.com");
string subject = "subject";
string body = "body";
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient
{
Host = "smtp.gmail.com",Port = 587,EnableSsl = true,DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network,UseDefaultCredentials = false,Credentials = new NetworkCredential(fromAddress.Address,fromPassword)
};
using (var message = new MailMessage(fromAddress,toAddress)
{
Subject = subject,Body = body
})
smtp.Send(message);
从生产服务器运行代码后,我在Gmail A / c上收到以下电子邮件
嗨,
最近有人使用您的密码尝试登录您的Google帐户mymailid@gmail.com。此人正在使用电子邮件,客户端或移动设备之类的应用程序。
万一这是一个劫机者试图访问您的帐户,我们阻止了登录尝试。请查看登录尝试的详细信息:
2014年1月3日,星期五,UTC时间:UTC IP地址:xxx.xx.xx.xxx(abcd.net。)位置:美国宾夕法尼亚州费城,宾夕法尼亚州费城
如果您不识别此登录尝试,则可能是其他人正在尝试访问您的帐户。您应该登录自己的帐户并立即重设密码。
重设密码
如果是您,并且您在访问帐户时遇到问题,请完成http://support.google.com/mail?p=client_login中列出的故障排除步骤
此致Google帐户小组敬上
Guardian - 排除需要身份验证的路由
如何解决Guardian - 排除需要身份验证的路由?
目前我已经使用以下配置设置了 Guardian 身份验证:
pipeline :api do
plug :accepts,["json"]
plug MyApp.AuthAccesspipeline
end
defmodule MyApp.AuthAccesspipeline do
use Guardian.Plug.Pipeline,otp_app: :my_app
plug Guardian.Plug.VerifySession,claims: %{"typ" => "access"}
plug Guardian.Plug.VerifyHeader,claims: %{"typ" => "access"}
plug Guardian.Plug.EnsureAuthenticated
plug Guardian.Plug.LoadResource,allow_blank: true
end
我的路线设置如下:
scope "/api/v1",MyAppWeb do
pipe_through :api
resources "/users",UserController,except: [:new,:edit]
post "/auth/sign_up",:sign_up
post "/auth/sign_in",:sign_in
post "/auth/forgot_password",:forgot_password
end
如何设置此管道以便无需身份验证即可访问 /auth/*
路由?
解决方法
我可以通过这样设置我的路线来解决这个问题:
pipeline :anonymous do
plug :accepts,["json"]
end
pipeline :protected do
plug :accepts,["json"]
plug MyApp.AuthAccessPipeline
end
scope "/api/v1/auth",MyAppWeb do
pipe_through :anonymous
post "/sign_up",UserController,:sign_up
post "/sign_in",:sign_in
post "/forgot_password",:forgot_password
end
scope "/api/v1",MyAppWeb do
pipe_through :protected
resources "/users",except: [:new,:edit]
end
java – Spring OAuth2“访问此资源需要完全身份验证”
我正在尝试将Spring OAuth2用于我的应用程序.
但看起来我犯了一个错误,我可以找到我做的地方.
流程应该是:
1.使用用户名和密码从/ oauth / token获取令牌
2.使用提供的令牌向/ security发出请求
MethodSecurityConfig:
@Configuration
@EnableGlobalMethodSecurity(prePostEnabled = true,proxyTargetClass = true)
public class MethodSecurityConfig extends GlobalMethodSecurityConfiguration {
@Autowired
private SecurityConfiguration securityConfig;
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
return new OAuth2MethodSecurityExpressionHandler();
}
}
OAuth2ServerConfig:
@Configuration
public class OAuth2ServerConfig {
private static final String RESOURCE_ID = "nessnity";
@Configuration
@Order(10)
protected static class UiResourceConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.requestMatchers().antMatchers("/security")
.and()
.authorizeRequests()
.antMatchers("/security").access("hasRole('USER')");
}
}
@Configuration
@EnableResourceServer
protected static class ResourceServerConfiguration extends ResourceServerConfigurerAdapter {
@Override
public void configure(ResourceServerSecurityConfigurer resources) {
resources.resourceId(RESOURCE_ID);
}
@Override
public void configure(HttpSecurity http) throws Exception {
http
.requestMatchers().antMatchers("/security/")
.and()
.authorizeRequests()
.antMatchers("/security").access("#oauth2.hasScope('read')");
}
}
@Configuration
@EnableAuthorizationServer
protected static class AuthorizationServerConfiguration extends AuthorizationServerConfigurerAdapter {
@Autowired
private TokenStore tokenStore;
@Autowired
private UserApprovalHandler userApprovalHandler;
@Autowired
private AuthenticationManager authenticationManager;
@Override
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
clients.inMemory()
.withClient("my-client")
.resourceIds(RESOURCE_ID)
.authorizedGrantTypes("client_credentials")
.authorities("ROLE_CLIENT")
.scopes("read")
.secret("password")
.accesstokenValiditySeconds(60);
}
@Bean
public TokenStore tokenStore() {
return new InMemoryTokenStore();
}
@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
endpoints
.tokenStore(tokenStore)
.userApprovalHandler(userApprovalHandler)
.authenticationManager(authenticationManager);
}
@Override
public void configure(AuthorizationServerSecurityConfigurer oauthServer) throws Exception {
oauthServer.realm("sparklr2/client");
}
}
protected static class Stuff {
@Autowired
private ClientDetailsService clientDetailsService;
@Autowired
private TokenStore tokenStore;
@Bean
public ApprovalStore approvalStore() throws Exception {
TokenApprovalStore store = new TokenApprovalStore();
store.setTokenStore(tokenStore);
return store;
}
@Bean
@Lazy
@Scope(proxyMode=ScopedProxyMode.TARGET_CLASS)
public SparklrUserApprovalHandler userApprovalHandler() throws Exception {
SparklrUserApprovalHandler handler = new SparklrUserApprovalHandler();
handler.setApprovalStore(approvalStore());
handler.setRequestFactory(new DefaultOAuth2RequestFactory(clientDetailsService));
handler.setClientDetailsService(clientDetailsService);
handler.setUseApprovalStore(true);
return handler;
}
}
}
SecurityConfiguration:
@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication()
.withUser("root")
.password("password")
.roles("USER");
}
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers("/oauth/uncache_approvals","/oauth/cache_approvals");
}
@Override
@Bean
public AuthenticationManager authenticationManagerBean() throws Exception {
return super.authenticationManagerBean();
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.anyRequest().hasRole("USER");
}
}
问题:当我试图获得令牌时
curl --user root:password --data "grant_type=client_credentials" http://localhost:8080/oauth/token
我得到了消息:
{“error”:”invalid_client”,”error_description”:”Bad client
credentials”}
第二个问题是如何在url params中传递用户名/密码,如/ oauth / token?username = root& password = password?
谢谢.
UPDATE
我决定从头开始使用xml配置.
以下配置完美:
ecurity/oauth2"
xsi:schemaLocation="http://www.springframework.org/schema/security/oauth2 http://www.springframework.org/schema/security/spring-security-oauth2-1.0.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
ecurity">
ecurity.oauth2.provider.client.ClientCredentialsTokenEndpointFilter">
ecurity">
ecurity.oauth2.provider.client.ClientDetailsUserDetailsService">
nessnity.api.security.OAuthClienDetailsService">
ecurity.oauth2.provider.error.OAuth2AuthenticationEntryPoint">
ecurity.oauth2.provider.error.OAuth2AccessDeniedHandler"/>
ecurity">
nessnity.api.security.OAuthUserAuthenticationProvider">
ecurity.oauth2.provider.token.DefaultTokenServices">
sstokenValiditySeconds" value="900000000"/>
ecurity.oauth2.provider.token.store.InMemoryTokenStore"/>
ecurity.oauth2.provider.error.OAuth2AuthenticationEntryPoint">
ecurity">
最佳答案
在进行以下更改之后,我遇到了类似的问题
在您的AuthorizationServerConfiguration类中替换
@Override
public void configure(AuthorizationServerSecurityConfigurer oauthServer) throws Exception {
oauthServer.realm("sparklr2/client");
}
使用以下代码
@Override
public void configure(AuthorizationServerSecurityConfigurer oauthServer) throws Exception {
//oauthServer.realm("sparklr2/client");
oauthServer.allowFormAuthenticationForClients();
}
和请求应该喜欢
/oauth/token?grant_type=password&scope=read+write&client_id=yourclientId&client_secret=secret&username=userName&password=pwd
我们今天的关于NOAUTH需要身份验证。Laravel + Redis和需要进行身份验证的分享就到这里,谢谢您的阅读,如果想了解更多关于Gmail 错误:SMTP 服务器需要安全连接或客户端未通过身份验证。服务器响应是:5.5.1 Authentication Required、Gmail错误:SMTP服务器需要安全连接,或者客户端未通过身份验证。服务器响应为:5.5.1需要身份验证、Guardian - 排除需要身份验证的路由、java – Spring OAuth2“访问此资源需要完全身份验证”的相关信息,可以在本站进行搜索。
本文标签: