Skip to content

Creating dynamic permissions within an account JWT in Go #5798

Discussion options

You must be logged in to vote

I found a test which helped me debug this issue:

nats-server/server/jwt_test.go

Lines 4388 to 4398 in 60589da

kp, _ := nkeys.CreateAccount()
aPub, _ := kp.PublicKey()
claim := jwt.NewAccountClaims(aPub)
aSignScopedKp, aSignScopedPub := createKey(t)
signer := jwt.NewUserScope()
signer.Key = aSignScopedPub
signer.Template.Pub.Deny.Add("denied")
signer.Template.Pub.Allow.Add("foo.{{name()}}")
signer.Template.Sub.Allow.Add("foo.{{name()}}")
claim.SigningKeys.AddScopedSigner(signer)
aJwt, err := claim.Encode(oKp)

I found some limitations with the templating that I'll document here.

The culprit of my issue was having a template…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by brettinternet
Comment options

You must be logged in to vote
1 reply
@brettinternet
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants