NATS 认证是多层级的。所有的安全模式都有一个 账户 级别,用户 隶属于这些账户。去中心化的 JWT 认证还有一个 运营商,账户隶属于运营商。
每个账户都有自己独立的主题命名空间:在一个账户中发布到主题 'foo' 的消息不会被其他账户中订阅 'foo' 的订阅者看到。但是,账户可以定义主题流的导出和导入,以及在账户之间公开 请求-回复 服务。账户内的用户将共享相同的主题命名空间,但可以限制为只能发布/订阅特定主题。
NATS 服务器提供了多种认证客户端的方式:
认证处理允许 NATS 客户端连接到服务器。除了 JWT 认证外,认证和授权都在配置的 authorization 部分中配置。使用 JWT 认证时,账户和用户信息存储在 解析器 中,而不是服务器配置文件中。
authorization 块提供 认证 配置以及 授权:
| Property | Description |
|---|---|
token |
Specifies a global token that can be used to authenticate to the server (exclusive of user and password) |
user |
Specifies a single global user name for clients to the server (exclusive of token) |
password |
Specifies a single global password for clients to the server (exclusive of token) |
users |
A list of user configuration maps. For multiple username and password credentials, specify a users list. |
timeout |
Maximum number of seconds to wait for client authentication |
auth_callout |
Enables the auth callout extension |
user 配置映射为单个用户指定凭据和权限选项:
| Property | Description |
|---|---|
user |
username for client authentication. (Can also be a user for tls authentication) |
password |
password for the user entry |
nkey |
public nkey identifying an user |
permissions |
permissions map configuring subjects accessible to the user |