-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update dependencies and PostgreSQL image (#10)
* Remove vendor * Update all dependencies * Remove CustomKeyMeta from magiclink package * Update jwks.go * Update tests * Upgrade more magiclink files * Fix bug caught by tests * Upgrade a bit * Full reimplementation for upgrade * Upgrade test storage * Update setup * Fix refactor bug * Upgrade handlers * Upgrade some tests * More upgrades * Fix some tests * Tests pass again * Remove custom key meta * Remove generic custom create args * Add TODO * Edit TODO * Remove custom read response * Add TODO * Remove unused * Move claims to top level package * Remove nested package * Add semicolon to terminate statement * Change startup.sql path * Use correct path * Add default signing key test back * Remove unused test * Respect visited and expires for in memory implementation * Update PostgreSQL version * Update deps more * IDE keeps updating toolchain
- Loading branch information
1 parent
852776a
commit 9f0ecac
Showing
643 changed files
with
725 additions
and
275,666 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package magiclinksdev | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"time" | ||
|
||
"github.com/golang-jwt/jwt/v5" | ||
"github.com/tidwall/gjson" | ||
) | ||
|
||
const ( | ||
AttrIss = "iss" | ||
AttrSub = "sub" | ||
AttrAud = "aud" | ||
AttrExp = "exp" | ||
AttrNbf = "nbf" | ||
AttrIat = "iat" | ||
AttrJti = "jti" | ||
) | ||
|
||
// SigningBytesClaims is a JWT claims type that allows for signing claims represented in bytes. | ||
type SigningBytesClaims struct { | ||
Claims json.RawMessage | ||
} | ||
|
||
func (s SigningBytesClaims) GetExpirationTime() (*jwt.NumericDate, error) { | ||
return jwt.NewNumericDate(time.Unix(gjson.GetBytes(s.Claims, AttrExp).Int(), 0)), nil | ||
} | ||
func (s SigningBytesClaims) GetIssuedAt() (*jwt.NumericDate, error) { | ||
return jwt.NewNumericDate(time.Unix(gjson.GetBytes(s.Claims, AttrIat).Int(), 0)), nil | ||
} | ||
func (s SigningBytesClaims) GetNotBefore() (*jwt.NumericDate, error) { | ||
return jwt.NewNumericDate(time.Unix(gjson.GetBytes(s.Claims, AttrNbf).Int(), 0)), nil | ||
} | ||
func (s SigningBytesClaims) GetIssuer() (string, error) { | ||
return gjson.GetBytes(s.Claims, AttrIss).String(), nil | ||
} | ||
func (s SigningBytesClaims) GetSubject() (string, error) { | ||
return gjson.GetBytes(s.Claims, AttrSub).String(), nil | ||
} | ||
func (s SigningBytesClaims) GetAudience() (jwt.ClaimStrings, error) { | ||
var aud jwt.ClaimStrings | ||
err := json.Unmarshal([]byte(gjson.GetBytes(s.Claims, AttrAud).Raw), &aud) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to unmarshal audience: %w", err) | ||
} | ||
return aud, nil | ||
} | ||
|
||
// MarshalJSON helps implement the json.Marshaler interface. | ||
func (s SigningBytesClaims) MarshalJSON() ([]byte, error) { | ||
return s.Claims, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,34 @@ | ||
module github.com/MicahParks/magiclinksdev | ||
|
||
go 1.21.1 | ||
go 1.22.0 | ||
|
||
toolchain go1.23.2 | ||
|
||
require ( | ||
github.com/MicahParks/jsontype v0.5.0 | ||
github.com/MicahParks/jwkset v0.3.1 | ||
github.com/MicahParks/keyfunc v1.9.0 | ||
github.com/MicahParks/jsontype v0.6.1 | ||
github.com/MicahParks/jwkset v0.5.20 | ||
github.com/MicahParks/keyfunc/v3 v3.3.5 | ||
github.com/MicahParks/recaptcha v0.0.5 | ||
github.com/aws/aws-sdk-go v1.45.6 | ||
github.com/golang-jwt/jwt/v4 v4.5.0 | ||
github.com/google/uuid v1.3.1 | ||
github.com/jackc/pgx/v5 v5.4.3 | ||
github.com/sendgrid/sendgrid-go v3.13.0+incompatible | ||
github.com/tidwall/gjson v1.16.0 | ||
github.com/aws/aws-sdk-go v1.55.5 | ||
github.com/golang-jwt/jwt/v5 v5.2.1 | ||
github.com/google/uuid v1.6.0 | ||
github.com/jackc/pgx/v5 v5.7.1 | ||
github.com/sendgrid/sendgrid-go v3.16.0+incompatible | ||
github.com/tidwall/gjson v1.18.0 | ||
github.com/tidwall/sjson v1.2.5 | ||
golang.org/x/mod v0.12.0 | ||
golang.org/x/time v0.3.0 | ||
golang.org/x/mod v0.21.0 | ||
golang.org/x/time v0.6.0 | ||
) | ||
|
||
require ( | ||
github.com/jackc/pgpassfile v1.0.0 // indirect | ||
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect | ||
github.com/jackc/puddle/v2 v2.2.1 // indirect | ||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect | ||
github.com/jackc/puddle/v2 v2.2.2 // indirect | ||
github.com/jmespath/go-jmespath v0.4.0 // indirect | ||
github.com/sendgrid/rest v2.6.9+incompatible // indirect | ||
github.com/tidwall/match v1.1.1 // indirect | ||
github.com/tidwall/pretty v1.2.1 // indirect | ||
golang.org/x/crypto v0.13.0 // indirect | ||
golang.org/x/sync v0.3.0 // indirect | ||
golang.org/x/text v0.13.0 // indirect | ||
golang.org/x/crypto v0.27.0 // indirect | ||
golang.org/x/sync v0.8.0 // indirect | ||
golang.org/x/text v0.18.0 // indirect | ||
) |
Oops, something went wrong.