Skip to content

Commit

Permalink
[FEAT] generate an activation for a specific subject
Browse files Browse the repository at this point in the history
  • Loading branch information
aricart committed May 1, 2024
1 parent 567b5f8 commit 1433c98
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion exports.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,22 @@ func (b *baseExportImpl) SetAdvertised(tf bool) error {
}

func (b *baseExportImpl) GenerateActivation(account string, issuer string) (string, error) {
return b.GenerateActivationForSubject(account, issuer, string(b.export.Subject))
}

func (b *baseExportImpl) GenerateActivationForSubject(account string, issuer string, subject string) (string, error) {
if !b.TokenRequired() {
return "", fmt.Errorf("export is public and doesn't require an activation")
}
if subject == "" {
return "", fmt.Errorf("subject cannot be empty")
}
key, err := KeyFrom(account, nkeys.PrefixByteAccount)
if err != nil {
return "", err
}
ac := jwt.NewActivationClaims(key.Public)
ac.ImportSubject = b.export.Subject
ac.ImportSubject = jwt.Subject(subject)
ac.ImportType = b.export.Type

k, signingKey, err := b.data.getKey(issuer)
Expand Down

0 comments on commit 1433c98

Please sign in to comment.