-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
使用创建的用户注册到nacos时出现403 #3961
Comments
服务端开启了权限的情况下。注册服务需要保证登陆的用户要写写操作的权限,给你的这个gateway用户分配一下写操作的权限 |
我给这个用户分配过public和gateway的读写权限,还是不行: |
用户和角色挂钩没得 |
角色又读写权限,然后需要把这个用户设定为这个角色。 |
感觉这个应该不是权限配置的问题,因为在最开始能够读取到nacos远程配置的数据,这个‘hi,这是test 11111’就是配置在nacos的。 以下是日志: Whitelabel Error PageThis application has no explicit mapping for /error, so you are seeing this as a fallback. Mon Oct 12 11:07:41 CST 2020 There was an unexpected error (type=Forbidden, status=403). authorization failed! at com.alibaba.nacos.client.naming.net.NamingProxy.reqApi(NamingProxy.java:552) ~[nacos-client-1.3.2.jar:na] at com.alibaba.nacos.client.naming.net.NamingProxy.reqApi(NamingProxy.java:491) ~[nacos-client-1.3.2.jar:na] at com.alibaba.nacos.client.naming.net.NamingProxy.reqApi(NamingProxy.java:486) ~[nacos-client-1.3.2.jar:na] at com.alibaba.nacos.client.naming.net.NamingProxy.registerService(NamingProxy.java:239) ~[nacos-client-1.3.2.jar:na] at com.alibaba.nacos.client.naming.NacosNamingService.registerInstance(NacosNamingService.java:200) ~[nacos-client-1.3.2.jar:na] at com.alibaba.cloud.nacos.registry.NacosServiceRegistry.register(NacosServiceRegistry.java:70) ~[spring-cloud-starter-alibaba-nacos-discovery-2.2.2.RELEASE.jar:2.2.2.RELEASE] ... 20 common frames omitted |
看报错是配置中心使用了gateway用户,但是注册中心没有使用gateway用户,403错误都是服务发现模块抛出来的,给服务发现模块也配置一下用户名密码试试
|
我这里没有naming配置,只有discovery,配置了discovery的用户名和密码后也报同样错误。 The auth system to use, currently only 'nacos' is supported:nacos.core.auth.system.type=nacos |
这个是认证的类型。 |
@zbsBrave 看一下nacos的access_log,看下是哪个接口报的403, 如果你没有使用discovery,应该不启动discovery才对,从报错来看就是启动了discovery,但是discovery没有权限。 |
1,设置nacos.core.auth.enabled=true
2,使用nacos新创建一个用户gataway,密码gataway
3,使用这个账号和密码注册到nacos失败,Caused by: com.alibaba.nacos.api.exception.NacosException: failed to req API:/nacos/v1/ns/instance after all servers([ctos.cn:8848]) tried: ErrCode:403,
4,使用username=nacos时注册到nacos是正常的
bootstrap.yml是这样的:
spring:
cloud:
nacos:
server-addr: ctos.cn:8848
username: gateway
password: gateway
config:
namespace: 6f257580-f5cc-4f5a-aeb3-1194dfe793f4
file-extension: yml
The text was updated successfully, but these errors were encountered: