aircastdev / nats-jwt Goto Github PK
View Code? Open in Web Editor NEWJWT library for creating NATS JWTs in Rust
Home Page: https://crates.io/crates/nats-jwt
License: Apache License 2.0
JWT library for creating NATS JWTs in Rust
Home Page: https://crates.io/crates/nats-jwt
License: Apache License 2.0
This is perhaps more of a Rust question, but I'm trying to generate an account with a dynamic number of signing keys depending on some configuration. An example code snippet is as follows:
let account_kp = KeyPair::new_account();
let mut account_token = Token::new_account(account_kp.public_key()).name(account.name);
for workload in account.workloads {
let workload_kp = KeyPair::new_account();
account_token.add_signing_key(workload_kp.public_key());
}
Obviously this doesn't work, as we get the following error:
46 | let mut account_token = Token::new_account(account_kp.public_key())
| _________________-----------------___-
| | |
| | move occurs because `account_token` has type `Token<nats_jwt::Account>`, which does not implement the `Copy` trait
47 | | .name(account.name);
| |___________________________________- this reinitialization might get skipped
48 |
49 | for workload in account.workloads {
| --------------------------------- inside of this loop
50 | let workload_kp = KeyPair::new_account();
51 | account_token.add_signing_key(workload_kp.public_key());
| ^^^^^^^^^^^^^ value moved here, in previous iteration of loop
How would I go about doing this properly? Any help is greatly appreciated.
When you use a scoped user (with a signing key), the server rejects JWT if they have permissions or limits.
with this error:
User JWT is not valid: scoped users require no permissions or limits set
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.