Skip to content

Commit a790e20

Browse files
authored
Merge pull request #1291 from ripienaar/account_sk
Support signing keys for accounts
2 parents 890257f + 46cde83 commit a790e20

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

cli/auth_account_command.go

+17
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ type authAccountCommand struct {
101101
prefix string
102102
tags []string
103103
rmTags []string
104+
signingKey string
104105
}
105106

106107
func configureAuthAccountCommand(auth commandHost) {
@@ -135,6 +136,7 @@ func configureAuthAccountCommand(auth commandHost) {
135136
add := acct.Command("add", "Adds a new Account").Alias("create").Alias("new").Action(c.addAction)
136137
add.Arg("name", "Unique name for this Account").StringVar(&c.accountName)
137138
add.Flag("operator", "Operator to add the account to").StringVar(&c.operatorName)
139+
add.Flag("key", "The public key to use when signing the user").StringVar(&c.signingKey)
138140
addCreateFlags(add, false)
139141
add.Flag("defaults", "Accept default values without prompting").UnNegatableBoolVar(&c.defaults)
140142

@@ -912,6 +914,21 @@ func (c *authAccountCommand) addAction(_ *fisk.ParseContext) error {
912914
return err
913915
}
914916

917+
if c.signingKey != "" {
918+
sk, err := au.SelectSigningKey(acct, c.signingKey)
919+
if err != nil {
920+
return err
921+
}
922+
c.signingKey = sk.Key()
923+
}
924+
925+
if c.signingKey != "" {
926+
err = acct.SetIssuer(c.signingKey)
927+
if err != nil {
928+
return err
929+
}
930+
}
931+
915932
err = au.UpdateTags(acct.Tags(), c.tags, c.rmTags)
916933
if err != nil {
917934
return err

cli/consumer_command.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ func configureConsumerCommand(app commandHost) {
261261
consNext.Flag("wait", "Wait up to this period to acknowledge messages").DurationVar(&c.ackWait)
262262
consNext.Flag("count", "Number of messages to try to fetch from the pull consumer").Default("1").IntVar(&c.pullCount)
263263

264-
consSub := cons.Command("sub", "Retrieves messages from Consumers").Action(c.subAction)
264+
consSub := cons.Command("sub", "Retrieves messages from Consumers").Action(c.subAction).Hidden()
265265
consSub.Arg("stream", "Stream name").StringVar(&c.stream)
266266
consSub.Arg("consumer", "Consumer name").StringVar(&c.consumer)
267267
consSub.Flag("ack", "Acknowledge received message").Default("true").BoolVar(&c.ack)

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ require (
2626
github.com/nats-io/nuid v1.0.1
2727
github.com/prometheus/client_golang v1.21.1
2828
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1
29-
github.com/synadia-io/jwt-auth-builder.go v0.0.6
29+
github.com/synadia-io/jwt-auth-builder.go v0.0.7-0.20250307212657-0e3f1ee00864
3030
github.com/tylertreat/hdrhistogram-writer v0.0.0-20210816161836-2e440612a39f
3131
golang.org/x/crypto v0.36.0
3232
golang.org/x/term v0.30.0

go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf
154154
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
155155
github.com/synadia-io/jwt-auth-builder.go v0.0.6 h1:F3bTGWlKzWHwRqtTt35fRmhrxXLgkI8qz8QvvzxKSko=
156156
github.com/synadia-io/jwt-auth-builder.go v0.0.6/go.mod h1:8WYR7+nLQcDMBpocuPgdFJ5/2UOr+HPll3qv+KNdGvs=
157+
github.com/synadia-io/jwt-auth-builder.go v0.0.7-0.20250307212657-0e3f1ee00864 h1:itO+DjIffRn+nN3jHxHNcCiJIsL1BMZF7p3wYeTN7xs=
158+
github.com/synadia-io/jwt-auth-builder.go v0.0.7-0.20250307212657-0e3f1ee00864/go.mod h1:8WYR7+nLQcDMBpocuPgdFJ5/2UOr+HPll3qv+KNdGvs=
157159
github.com/tylertreat/hdrhistogram-writer v0.0.0-20210816161836-2e440612a39f h1:SGznmvCovewbaSgBsHgdThtWsLj5aCLX/3ZXMLd1UD0=
158160
github.com/tylertreat/hdrhistogram-writer v0.0.0-20210816161836-2e440612a39f/go.mod h1:IY84XkhrEJTdHYLNy/zObs8mXuUAp9I65VyarbPSCCY=
159161
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=

0 commit comments

Comments
 (0)