Skip to content
This repository has been archived by the owner on May 21, 2022. It is now read-only.

added doc for time type standard claim migration guide from v3 to v4 #402

Open
wants to merge 1 commit into
base: release_4_0_0
Choose a base branch
from
Open
Changes from all commits
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
30 changes: 29 additions & 1 deletion MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
## Migration Guide from v3 -> v4

TODO: write this
Version 4 is the first non-backward-compatible version in a long time. There are a few changes that all users will notice, such as the new types introduced in members of StandardClaims. This guide explains the breaking changes and how you can quickly update your code.

### `Time` is a now new type

Time is how Version 4 represents time values. This makes it possible to represent nil values.

`StandardClaims` fields `ExpiresAt`, `IssuedAt`, `NotBeforenow`, is now of type `*Time`.

The old example for adding a `ExpiresAt` to `StandardClaims` looked like this..

```go
// expire token after 5 min
expirationTime := time.Now().Add(5 * time.Minute)

claims := &jwt.StandardClaims{
ExpiresAt: expirationTime.Unix(),
}
```

will now look like this...

```go
// expire token after 5 min
expirationTime := time.Now().Add(5 * time.Minute)

claims := &jwt.StandardClaims{
ExpiresAt: jwt.At(expirationTime),
}
```

## Migration Guide from v2 -> v3

Expand Down