Skip to content

Commit 895749e

Browse files
committed
Starting v5 development
This commit serves as the basis for further `v5` developments. It will introduce some API-breaking changes, especially to the way tokens are validated. This will allow us to provide some long-wanted features with regards to the validation API. We are aiming to do this as smoothly as possible, however, with any major version. please expect that you might need to adapt your code. The actual development will be done in the course of the next week, if time permits. It will be done in seperate PRs that will use this PR as a base. Afterwards, we will probably merge this and release an initial 5.0.0-alpha1 or similar.
1 parent bfea432 commit 895749e

20 files changed

+39
-43
lines changed

MIGRATION_GUIDE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22

33
Starting from [v4.0.0](https://github.com/golang-jwt/jwt/releases/tag/v4.0.0), the import path will be:
44

5-
"github.com/golang-jwt/jwt/v4"
5+
"github.com/golang-jwt/jwt/v5"
66

77
The `/v4` version will be backwards compatible with existing `v3.x.y` tags in this repo, as well as
88
`github.com/dgrijalva/jwt-go`. For most users this should be a drop-in replacement, if you're having
99
troubles migrating, please open an issue.
1010

11-
You can replace all occurrences of `github.com/dgrijalva/jwt-go` or `github.com/golang-jwt/jwt` with `github.com/golang-jwt/jwt/v4`, either manually or by using tools such as `sed` or `gofmt`.
11+
You can replace all occurrences of `github.com/dgrijalva/jwt-go` or `github.com/golang-jwt/jwt` with `github.com/golang-jwt/jwt/v5`, either manually or by using tools such as `sed` or `gofmt`.
1212

1313
And then you'd typically run:
1414

1515
```
16-
go get github.com/golang-jwt/jwt/v4
16+
go get github.com/golang-jwt/jwt/v5
1717
go mod tidy
1818
```
1919

README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# jwt-go
22

33
[![build](https://github.com/golang-jwt/jwt/actions/workflows/build.yml/badge.svg)](https://github.com/golang-jwt/jwt/actions/workflows/build.yml)
4-
[![Go Reference](https://pkg.go.dev/badge/github.com/golang-jwt/jwt/v4.svg)](https://pkg.go.dev/github.com/golang-jwt/jwt/v4)
4+
[![Go Reference](https://pkg.go.dev/badge/github.com/golang-jwt/jwt/v5.svg)](https://pkg.go.dev/github.com/golang-jwt/jwt/v5)
55

66
A [go](http://www.golang.org) (or 'golang' for search engine friendliness) implementation of [JSON Web Tokens](https://datatracker.ietf.org/doc/html/rfc7519).
77

88
Starting with [v4.0.0](https://github.com/golang-jwt/jwt/releases/tag/v4.0.0) this project adds Go module support, but maintains backwards compatibility with older `v3.x.y` tags and upstream `github.com/dgrijalva/jwt-go`.
9-
See the [`MIGRATION_GUIDE.md`](./MIGRATION_GUIDE.md) for more information.
9+
See the [`MIGRATION_GUIDE.md`](./MIGRATION_GUIDE.md) for more information. Version v5.0.0 introduces major improvements to the validation of tokens, but is not entirely backwards compatible.
1010

1111
> After the original author of the library suggested migrating the maintenance of `jwt-go`, a dedicated team of open source maintainers decided to clone the existing library into this repository. See [dgrijalva/jwt-go#462](https://github.com/dgrijalva/jwt-go/issues/462) for a detailed discussion on this topic.
1212
@@ -41,22 +41,22 @@ This library supports the parsing and verification as well as the generation and
4141
1. To install the jwt package, you first need to have [Go](https://go.dev/doc/install) installed, then you can use the command below to add `jwt-go` as a dependency in your Go program.
4242

4343
```sh
44-
go get -u github.com/golang-jwt/jwt/v4
44+
go get -u github.com/golang-jwt/jwt/v5
4545
```
4646

4747
2. Import it in your code:
4848

4949
```go
50-
import "github.com/golang-jwt/jwt/v4"
50+
import "github.com/golang-jwt/jwt/v5"
5151
```
5252

5353
## Examples
5454

55-
See [the project documentation](https://pkg.go.dev/github.com/golang-jwt/jwt/v4) for examples of usage:
55+
See [the project documentation](https://pkg.go.dev/github.com/golang-jwt/jwt/v5) for examples of usage:
5656

57-
* [Simple example of parsing and validating a token](https://pkg.go.dev/github.com/golang-jwt/jwt/v4#example-Parse-Hmac)
58-
* [Simple example of building and signing a token](https://pkg.go.dev/github.com/golang-jwt/jwt/v4#example-New-Hmac)
59-
* [Directory of Examples](https://pkg.go.dev/github.com/golang-jwt/jwt/v4#pkg-examples)
57+
* [Simple example of parsing and validating a token](https://pkg.go.dev/github.com/golang-jwt/jwt/v5#example-Parse-Hmac)
58+
* [Simple example of building and signing a token](https://pkg.go.dev/github.com/golang-jwt/jwt/v5#example-New-Hmac)
59+
* [Directory of Examples](https://pkg.go.dev/github.com/golang-jwt/jwt/v5#pkg-examples)
6060

6161
## Extensions
6262

@@ -68,7 +68,7 @@ A common use case would be integrating with different 3rd party signature provid
6868
| --------- | -------------------------------------------------------------------------------------------------------- | ------------------------------------------ |
6969
| GCP | Integrates with multiple Google Cloud Platform signing tools (AppEngine, IAM API, Cloud KMS) | https://github.com/someone1/gcp-jwt-go |
7070
| AWS | Integrates with AWS Key Management Service, KMS | https://github.com/matelang/jwt-go-aws-kms |
71-
| JWKS | Provides support for JWKS ([RFC 7517](https://datatracker.ietf.org/doc/html/rfc7517)) as a `jwt.Keyfunc` | https://github.com/MicahParks/keyfunc |
71+
| JWKS | Provides support for JWKS ([RFC 7517](https://datatracker.ietf.org/doc/html/rfc7517)) as a `jwt.Keyfunc` | https://github.com/MicahParks/keyfunc |
7272

7373
*Disclaimer*: Unless otherwise specified, these integrations are maintained by third parties and should not be considered as a primary offer by any of the mentioned cloud providers
7474

@@ -110,10 +110,10 @@ Asymmetric signing methods, such as RSA, use different keys for signing and veri
110110

111111
Each signing method expects a different object type for its signing keys. See the package documentation for details. Here are the most common ones:
112112

113-
* The [HMAC signing method](https://pkg.go.dev/github.com/golang-jwt/jwt/v4#SigningMethodHMAC) (`HS256`,`HS384`,`HS512`) expect `[]byte` values for signing and validation
114-
* The [RSA signing method](https://pkg.go.dev/github.com/golang-jwt/jwt/v4#SigningMethodRSA) (`RS256`,`RS384`,`RS512`) expect `*rsa.PrivateKey` for signing and `*rsa.PublicKey` for validation
115-
* The [ECDSA signing method](https://pkg.go.dev/github.com/golang-jwt/jwt/v4#SigningMethodECDSA) (`ES256`,`ES384`,`ES512`) expect `*ecdsa.PrivateKey` for signing and `*ecdsa.PublicKey` for validation
116-
* The [EdDSA signing method](https://pkg.go.dev/github.com/golang-jwt/jwt/v4#SigningMethodEd25519) (`Ed25519`) expect `ed25519.PrivateKey` for signing and `ed25519.PublicKey` for validation
113+
* The [HMAC signing method](https://pkg.go.dev/github.com/golang-jwt/jwt/v5#SigningMethodHMAC) (`HS256`,`HS384`,`HS512`) expect `[]byte` values for signing and validation
114+
* The [RSA signing method](https://pkg.go.dev/github.com/golang-jwt/jwt/v5#SigningMethodRSA) (`RS256`,`RS384`,`RS512`) expect `*rsa.PrivateKey` for signing and `*rsa.PublicKey` for validation
115+
* The [ECDSA signing method](https://pkg.go.dev/github.com/golang-jwt/jwt/v5#SigningMethodECDSA) (`ES256`,`ES384`,`ES512`) expect `*ecdsa.PrivateKey` for signing and `*ecdsa.PublicKey` for validation
116+
* The [EdDSA signing method](https://pkg.go.dev/github.com/golang-jwt/jwt/v5#SigningMethodEd25519) (`Ed25519`) expect `ed25519.PrivateKey` for signing and `ed25519.PublicKey` for validation
117117

118118
### JWT and OAuth
119119

@@ -131,7 +131,7 @@ This library uses descriptive error messages whenever possible. If you are not g
131131

132132
## More
133133

134-
Documentation can be found [on pkg.go.dev](https://pkg.go.dev/github.com/golang-jwt/jwt/v4).
134+
Documentation can be found [on pkg.go.dev](https://pkg.go.dev/github.com/golang-jwt/jwt/v5).
135135

136136
The command line utility included in this project (cmd/jwt) provides a straightforward example of token creation and parsing as well as a useful tool for debugging your own integration. You'll also find several implementation examples in the documentation.
137137

cmd/jwt/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ To simply display a token, use:
1616

1717
You can install this tool with the following command:
1818

19-
go install github.com/golang-jwt/jwt/v4/cmd/jwt
19+
go install github.com/golang-jwt/jwt/v5/cmd/jwt

cmd/jwt/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
"sort"
1818
"strings"
1919

20-
"github.com/golang-jwt/jwt/v4"
20+
"github.com/golang-jwt/jwt/v5"
2121
)
2222

2323
var (

ecdsa_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"strings"
77
"testing"
88

9-
"github.com/golang-jwt/jwt/v4"
9+
"github.com/golang-jwt/jwt/v5"
1010
)
1111

1212
var ecdsaTestData = []struct {

ed25519_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"strings"
66
"testing"
77

8-
"github.com/golang-jwt/jwt/v4"
8+
"github.com/golang-jwt/jwt/v5"
99
)
1010

1111
var ed25519TestData = []struct {

example_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"fmt"
66
"time"
77

8-
"github.com/golang-jwt/jwt/v4"
8+
"github.com/golang-jwt/jwt/v5"
99
)
1010

1111
// Example (atypical) using the RegisteredClaims type by itself to parse a token.

go.mod

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
module github.com/golang-jwt/jwt/v4
1+
module github.com/golang-jwt/jwt/v5
22

33
go 1.16
4-
5-
retract (
6-
v4.4.0 // Contains a backwards incompatible change to the Claims interface.
7-
)

hmac_example_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"os"
66
"time"
77

8-
"github.com/golang-jwt/jwt/v4"
8+
"github.com/golang-jwt/jwt/v5"
99
)
1010

1111
// For HMAC signing method, the key can be any []byte. It is recommended to generate

hmac_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"strings"
66
"testing"
77

8-
"github.com/golang-jwt/jwt/v4"
8+
"github.com/golang-jwt/jwt/v5"
99
)
1010

1111
var hmacTestData = []struct {

http_example_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import (
1616
"strings"
1717
"time"
1818

19-
"github.com/golang-jwt/jwt/v4"
20-
"github.com/golang-jwt/jwt/v4/request"
19+
"github.com/golang-jwt/jwt/v5"
20+
"github.com/golang-jwt/jwt/v5/request"
2121
)
2222

2323
// location of the files used for signing and verification

none_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"strings"
55
"testing"
66

7-
"github.com/golang-jwt/jwt/v4"
7+
"github.com/golang-jwt/jwt/v5"
88
)
99

1010
var noneTestData = []struct {

parser_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import (
1010
"testing"
1111
"time"
1212

13-
"github.com/golang-jwt/jwt/v4"
14-
"github.com/golang-jwt/jwt/v4/test"
13+
"github.com/golang-jwt/jwt/v5"
14+
"github.com/golang-jwt/jwt/v5/test"
1515
)
1616

1717
var errKeyFuncError error = fmt.Errorf("error loading key")

request/request.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package request
33
import (
44
"net/http"
55

6-
"github.com/golang-jwt/jwt/v4"
6+
"github.com/golang-jwt/jwt/v5"
77
)
88

99
// ParseFromRequest extracts and parses a JWT token from an HTTP request.

request/request_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88
"strings"
99
"testing"
1010

11-
"github.com/golang-jwt/jwt/v4"
12-
"github.com/golang-jwt/jwt/v4/test"
11+
"github.com/golang-jwt/jwt/v5"
12+
"github.com/golang-jwt/jwt/v5/test"
1313
)
1414

1515
var requestTestData = []struct {

rsa_pss_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import (
1010
"testing"
1111
"time"
1212

13-
"github.com/golang-jwt/jwt/v4"
14-
"github.com/golang-jwt/jwt/v4/test"
13+
"github.com/golang-jwt/jwt/v5"
14+
"github.com/golang-jwt/jwt/v5/test"
1515
)
1616

1717
var rsaPSSTestData = []struct {

rsa_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"strings"
66
"testing"
77

8-
"github.com/golang-jwt/jwt/v4"
8+
"github.com/golang-jwt/jwt/v5"
99
)
1010

1111
var rsaTestData = []struct {

test/helpers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"crypto/rsa"
66
"os"
77

8-
"github.com/golang-jwt/jwt/v4"
8+
"github.com/golang-jwt/jwt/v5"
99
)
1010

1111
func LoadRSAPrivateKeyFromDisk(location string) *rsa.PrivateKey {

token_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package jwt_test
33
import (
44
"testing"
55

6-
"github.com/golang-jwt/jwt/v4"
6+
"github.com/golang-jwt/jwt/v5"
77
)
88

99
func TestToken_SigningString(t1 *testing.T) {

types_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"testing"
77
"time"
88

9-
"github.com/golang-jwt/jwt/v4"
9+
"github.com/golang-jwt/jwt/v5"
1010
)
1111

1212
func TestNumericDate(t *testing.T) {

0 commit comments

Comments
 (0)