-
Notifications
You must be signed in to change notification settings - Fork 232
Description
Proposed change
Please refer to the example: NATS by Example - Programmatic NKeys and JWTs
Authorization, Account Limits, and such are managed by Claims in Nats.io. The golang library nats-io/jwt provides methods to fetch and modify these Claims but there is no such provision in the python client. I believe the management of these Claims and subsequently the users, accounts, limits, etc. encompasses an integral part of the system and must have support in all the client libraries, including python.
Use case
Nats.io claims management, and control over users, accounts, limits, permissions, etc.
Sample Code
operatorKP = from_seed(b'SOALU7LPGJK2BDF7IHD7UZT6ZM23UMKYLGJLNN35QJSUI5BNR4DJRFH4R4')
accountKP = from_seed(b'SAALXUEDN2QR5KZDDSH5S4RIWAZDM7CVDG5HNJI2HS5LBVYFTLAQCOXZAU')
userKP = from_seed(b'SUALJTG5JNRQCQKFE652DV4XID522ALOHJNQVHKKDJNVGWHCLHOEXEROEM')
account_claims = Claims(
name="my-account",
jti="PBFES33GGIFZM6UGC7NY5ARHRBFVFU4UD7FS2WNLZH3KPGWFVEFQ",
iat=1678973945,
iss=operatorKP.public_key.decode(),
sub=accountKP.public_key.decode(),
nats=Account(
limits=OperatorLimits(
nats_limits=NatsLimits(data = -1, payload = -1, subs = -1),
account_limits=AccountLimits(exports = -1, imports = -1, wildcards = True, conn = -1, leaf = -1),
jetstream_limits=JetStreamLimits(disk_storage=-1, mem_storage=-1)
),
default_permissions=Permissions(),
generic_fields=GenericFields(version=2, type=Types.Account)
)
)Contribution
Note: I dont have much of a clear understanding of how exactly the
Operator,AccountandUserworks with each other and why anAccountdefines anOperatorLimit, but following the methods in nats-io/jwt has lead me to creating this PR.