Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a field to the user JWT that disables nonce verification when set. #62

Merged
merged 2 commits into from
Jan 14, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion account_claims_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ func TestAccountImports(t *testing.T) {
func TestNewNilAccountClaim(t *testing.T) {
v := NewAccountClaims("")
if v != nil {
t.Fatal(fmt.Sprintf("expected nil account claim"))
t.Fatal("expected nil account claim")
}
}

Expand Down
2 changes: 1 addition & 1 deletion activation_claims_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func TestPublicIsNotValid(t *testing.T) {
func TestNilActivationClaim(t *testing.T) {
v := NewActivationClaims("")
if v != nil {
t.Fatal(fmt.Sprintf("expected nil user claim"))
t.Fatal("expected nil user claim")
}
}

Expand Down
2 changes: 1 addition & 1 deletion cluster_claims_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func TestClusterSubjects(t *testing.T) {
func TestNewNilClusterClaims(t *testing.T) {
v := NewClusterClaims("")
if v != nil {
t.Fatal(fmt.Sprintf("expected nil user claim"))
t.Fatal("expected nil user claim")
}
}

Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module github.com/nats-io/jwt

require github.com/nats-io/nkeys v0.1.3

go 1.13
2 changes: 1 addition & 1 deletion operator_claims_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func TestInvalidOperatorClaimIssuer(t *testing.T) {
func TestNewNilOperatorClaims(t *testing.T) {
v := NewOperatorClaims("")
if v != nil {
t.Fatal(fmt.Sprintf("expected nil user claim"))
t.Fatal("expected nil user claim")
}
}

Expand Down
2 changes: 1 addition & 1 deletion server_claims_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func TestServerSubjects(t *testing.T) {
func TestNewNilServerClaims(t *testing.T) {
v := NewServerClaims("")
if v != nil {
t.Fatal(fmt.Sprintf("expected nil user claim"))
t.Fatal("expected nil user claim")
}
}

Expand Down
7 changes: 7 additions & 0 deletions user_claims.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ type UserClaims struct {
// IssuerAccount stores the public key for the account the issuer represents.
// When set, the claim was issued by a signing key.
IssuerAccount string `json:"issuer_account,omitempty"`
// When BearerToken is true server will ignore any nonce-signing verification
BearerToken bool `json:"bearer_token,omitempty"`
}

// NewUserClaims creates a user JWT with the specific subject/public key
Expand Down Expand Up @@ -97,3 +99,8 @@ func (u *UserClaims) Payload() interface{} {
func (u *UserClaims) String() string {
return u.ClaimsData.String(u)
}

// IsBearerToken returns true if nonce-signing requirements should be skipped
func (u *UserClaims) IsBearerToken() bool {
return u.BearerToken
}
2 changes: 1 addition & 1 deletion user_claims_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func TestUserSubjects(t *testing.T) {
func TestNewNilUserClaim(t *testing.T) {
v := NewUserClaims("")
if v != nil {
t.Fatal(fmt.Sprintf("expected nil user claim"))
t.Fatal("expected nil user claim")
}
}

Expand Down