Mixed Authentication/Authorization Setup

Mixing both nkeys static config and decentralized JWT Authentication/Authorization is possible but needs some preparation in order to be able to do it.

The way this can be done is by first preparing a basic trusted operator setup that could be used in the future, and then base from that configuration to create the NKEYS static config using the same shared public nkeys for the accounts and then use clustering routes to bridge the two different auth setups during the transition.

For example, creating the following initial setup using NSC:

        nsc add account --name SYS
        nsc add user    --name sys
        nsc add account --name A
        nsc add user -a A --name test
        nsc add account --name B
        nsc add user -a B --name test

This will then generate something like the following:

 nsc list accounts
╭─────────────────────────────────────────────────────────────────╮
                            Accounts                             
├──────┬──────────────────────────────────────────────────────────┤
 Name  Public Key                                               
├──────┼──────────────────────────────────────────────────────────┤
 A     ADFB2JXYTXOJEL6LNAXDREUGRX35BOLZI3B4PFFAC7IRPR3OA4QNKBN2 
 B     ACWOMQA7PZTKJSBTR7BF6TBK3D776734PWHWDKO7HFMQOM5BIOYPSYZZ 
 SYS   ABKOWIYVTHNEK5HELPWLAT2CF2CUPELIK4SZH2VCJHLFU22B5U2IIZUO 
╰──────┴──────────────────────────────────────────────────────────╯

 nsc list users -a A
╭─────────────────────────────────────────────────────────────────╮
                              Users                              
├──────┬──────────────────────────────────────────────────────────┤
 Name  Public Key                                               
├──────┼──────────────────────────────────────────────────────────┤
 test  UAPOK2P7EN3UFBL7SBJPQK3M3JMLALYRYKX5XWSVMVYK63ZMBHTOHVJR 
╰──────┴──────────────────────────────────────────────────────────╯

We could use this configuration as the initial starting configuration for an nkeys config now, where all the NKEYS users public nkeys are explicitly listed (centralized auth model).

By using nsc it is possible to create a mem based resolver for the trusted operator setup:

An example configuration from the second node with the trusted operator setup could then be:

Even though they have different authorization mechanisms, these two servers are able to route account messages because they share the same NKEY.

We have created at least one user, in this case with creds:

And this same user is able to connect to either one of the servers (bound to 4222 and 4223 respectively):

Subscriber Service:

Requestor:

最后更新于

这有帮助吗?