Skip to content

Commit

Permalink
Bugfix in CreateCustom (#17)
Browse files Browse the repository at this point in the history
* Bugfix in CreateCustom

Fixed a bug in create custom where when no expiresAt is specified,
the default expiresAt creation had two issues:

* It used a go1.17 API time.UnixMicro, wihch breaks backward
  compatibility

* The function was used wrongly as the 2nd param of time.Unix()

As a result of this, we have to issue this fix to ensure that the
1.4 stream still works with old version of the Go language. And we
also have to retract the v1.4.0 release.
  • Loading branch information
qqiao committed Mar 28, 2022
1 parent c9a2815 commit d25c6be
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
container:
image: qqiao/dev-env:latest
options: --user root
permissions:
actions: read
contents: read
Expand Down Expand Up @@ -53,8 +56,8 @@ jobs:

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# - name: Autobuild
# uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -63,9 +66,7 @@ jobs:
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release
- run: go build .

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
6 changes: 4 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module github.com/qqiao/webapp

go 1.12
go 1.16

require github.com/golang-jwt/jwt/v4 v4.4.0
retract v1.4.0

require github.com/golang-jwt/jwt/v4 v4.4.1
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
github.com/golang-jwt/jwt/v4 v4.4.0 h1:EmVIxB5jzbllGIjiCV5JG4VylbK3KE400tLGLI1cdfU=
github.com/golang-jwt/jwt/v4 v4.4.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg=
github.com/golang-jwt/jwt/v4 v4.4.1 h1:pC5DB52sCeK48Wlb9oPcdhnjkz1TKt1D/P7WKJ0kUcQ=
github.com/golang-jwt/jwt/v4 v4.4.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
2 changes: 1 addition & 1 deletion jwt/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (m Manager) CreateCustom(dat interface{},
expiresAt *time.Time) (<-chan string, <-chan error) {
_expiresAt := time.Now().Add(365 * 24 * time.Hour)
if expiresAt != nil {
_expiresAt = time.Unix(expiresAt.Unix(), expiresAt.UnixMicro())
_expiresAt = time.Unix(expiresAt.Unix(), 0)
}

claims := NewClaims().WithDat(dat).WithExpiry(_expiresAt)
Expand Down

0 comments on commit d25c6be

Please sign in to comment.