认证

NATS 认证是多层级的。所有的安全模式都有一个 账户 级别,用户 隶属于这些账户。去中心化的 JWT 认证还有一个 运营商,账户隶属于运营商。

每个账户都有自己独立的主题命名空间:在一个账户中发布到主题 'foo' 的消息不会被其他账户中订阅 'foo' 的订阅者看到。但是,账户可以定义主题流的导出和导入,以及在账户之间公开 请求-回复 服务。账户内的用户将共享相同的主题命名空间,但可以限制为只能发布/订阅特定主题。

认证方法

NATS 服务器提供了多种认证客户端的方式:

认证处理允许 NATS 客户端连接到服务器。除了 JWT 认证外,认证和授权都在配置的 authorization 部分中配置。使用 JWT 认证时,账户和用户信息存储在 解析器 中,而不是服务器配置文件中。

Authorization Map

authorization 块提供 认证 配置以及 授权

PropertyDescription
tokenSpecifies a global token that can be used to authenticate to the server (exclusive of user and password)
userSpecifies a single global user name for clients to the server (exclusive of token)
passwordSpecifies a single global password for clients to the server (exclusive of token)
usersA list of user configuration maps. For multiple username and password credentials, specify a users list.
timeoutMaximum number of seconds to wait for client authentication
auth_calloutEnables the auth callout extension

User Configuration Map

user 配置映射为单个用户指定凭据和权限选项:

PropertyDescription
userusername for client authentication. (Can also be a user for tls authentication)
passwordpassword for the user entry
nkeypublic nkey identifying an user
permissionspermissions map configuring subjects accessible to the user