summaryrefslogtreecommitdiff
path: root/vendor/github.com/golang-jwt/jwt/map_claims.go
diff options
context:
space:
mode:
authorLibravatar kim <grufwub@gmail.com>2025-06-06 15:14:37 +0200
committerLibravatar kim <gruf@noreply.codeberg.org>2025-06-06 15:14:37 +0200
commit77eddea3aff27ffebf53d2341609221d4c1924e7 (patch)
tree27ca0c930f93c12d2e36ea083c6dbf1eef8521b1 /vendor/github.com/golang-jwt/jwt/map_claims.go
parent[chore] blocklist -> allowlist config typo fix (#4242) (diff)
downloadgotosocial-77eddea3aff27ffebf53d2341609221d4c1924e7.tar.xz
[chore] updates code.superseriousbusiness.org/oauth2/v4 to ssb-v4.5.3-1 (#4245)
A brief note on the above change: Go does not seem to like version tagging outside of `v?[0-9\.]` formatting, so it translates `ssb-v4.5.3-1` to `v4.5.4-0.20250606121655-9d54ef189d42` and as such sees it as a "downgrade" compared to the previous `v4.9.0`. which functionally isn't a problem, everything still behaves as it should, but it means people can't just run `go get repo@latest` for this particular dependency. Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4245 Co-authored-by: kim <grufwub@gmail.com> Co-committed-by: kim <grufwub@gmail.com>
Diffstat (limited to 'vendor/github.com/golang-jwt/jwt/map_claims.go')
-rw-r--r--vendor/github.com/golang-jwt/jwt/map_claims.go120
1 files changed, 0 insertions, 120 deletions
diff --git a/vendor/github.com/golang-jwt/jwt/map_claims.go b/vendor/github.com/golang-jwt/jwt/map_claims.go
deleted file mode 100644
index 72c79f92e..000000000
--- a/vendor/github.com/golang-jwt/jwt/map_claims.go
+++ /dev/null
@@ -1,120 +0,0 @@
-package jwt
-
-import (
- "encoding/json"
- "errors"
- // "fmt"
-)
-
-// Claims type that uses the map[string]interface{} for JSON decoding
-// This is the default claims type if you don't supply one
-type MapClaims map[string]interface{}
-
-// VerifyAudience Compares the aud claim against cmp.
-// If required is false, this method will return true if the value matches or is unset
-func (m MapClaims) VerifyAudience(cmp string, req bool) bool {
- var aud []string
- switch v := m["aud"].(type) {
- case string:
- aud = append(aud, v)
- case []string:
- aud = v
- case []interface{}:
- for _, a := range v {
- vs, ok := a.(string)
- if !ok {
- return false
- }
- aud = append(aud, vs)
- }
- }
- return verifyAud(aud, cmp, req)
-}
-
-// Compares the exp claim against cmp.
-// If required is false, this method will return true if the value matches or is unset
-func (m MapClaims) VerifyExpiresAt(cmp int64, req bool) bool {
- exp, ok := m["exp"]
- if !ok {
- return !req
- }
- switch expType := exp.(type) {
- case float64:
- return verifyExp(int64(expType), cmp, req)
- case json.Number:
- v, _ := expType.Int64()
- return verifyExp(v, cmp, req)
- }
- return false
-}
-
-// Compares the iat claim against cmp.
-// If required is false, this method will return true if the value matches or is unset
-func (m MapClaims) VerifyIssuedAt(cmp int64, req bool) bool {
- iat, ok := m["iat"]
- if !ok {
- return !req
- }
- switch iatType := iat.(type) {
- case float64:
- return verifyIat(int64(iatType), cmp, req)
- case json.Number:
- v, _ := iatType.Int64()
- return verifyIat(v, cmp, req)
- }
- return false
-}
-
-// Compares the iss claim against cmp.
-// If required is false, this method will return true if the value matches or is unset
-func (m MapClaims) VerifyIssuer(cmp string, req bool) bool {
- iss, _ := m["iss"].(string)
- return verifyIss(iss, cmp, req)
-}
-
-// Compares the nbf claim against cmp.
-// If required is false, this method will return true if the value matches or is unset
-func (m MapClaims) VerifyNotBefore(cmp int64, req bool) bool {
- nbf, ok := m["nbf"]
- if !ok {
- return !req
- }
- switch nbfType := nbf.(type) {
- case float64:
- return verifyNbf(int64(nbfType), cmp, req)
- case json.Number:
- v, _ := nbfType.Int64()
- return verifyNbf(v, cmp, req)
- }
- return false
-}
-
-// Validates time based claims "exp, iat, nbf".
-// There is no accounting for clock skew.
-// As well, if any of the above claims are not in the token, it will still
-// be considered a valid claim.
-func (m MapClaims) Valid() error {
- vErr := new(ValidationError)
- now := TimeFunc().Unix()
-
- if !m.VerifyExpiresAt(now, false) {
- vErr.Inner = errors.New("Token is expired")
- vErr.Errors |= ValidationErrorExpired
- }
-
- if !m.VerifyIssuedAt(now, false) {
- vErr.Inner = errors.New("Token used before issued")
- vErr.Errors |= ValidationErrorIssuedAt
- }
-
- if !m.VerifyNotBefore(now, false) {
- vErr.Inner = errors.New("Token is not valid yet")
- vErr.Errors |= ValidationErrorNotValidYet
- }
-
- if vErr.valid() {
- return nil
- }
-
- return vErr
-}