summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/dgrijalva
diff options
context:
space:
mode:
authorWim <wim@42.be>2018-08-06 21:47:05 +0200
committerWim <wim@42.be>2018-08-06 21:47:05 +0200
commit51062863a5c34d81e296cf15c61140911037cf3b (patch)
tree9b5e044672486326c7a0ca8fb26430f37bf4d83c /vendor/github.com/dgrijalva
parent4fb4b7aa6c02a54db8ad8dd98e4d321396926c0d (diff)
downloadmatterbridge-msglm-51062863a5c34d81e296cf15c61140911037cf3b.tar.gz
matterbridge-msglm-51062863a5c34d81e296cf15c61140911037cf3b.tar.bz2
matterbridge-msglm-51062863a5c34d81e296cf15c61140911037cf3b.zip
Use mod vendor for vendored directory (backwards compatible)
Diffstat (limited to 'vendor/github.com/dgrijalva')
-rw-r--r--vendor/github.com/dgrijalva/jwt-go/.gitignore4
-rw-r--r--vendor/github.com/dgrijalva/jwt-go/.travis.yml13
-rw-r--r--vendor/github.com/dgrijalva/jwt-go/MIGRATION_GUIDE.md97
-rw-r--r--vendor/github.com/dgrijalva/jwt-go/README.md85
-rw-r--r--vendor/github.com/dgrijalva/jwt-go/VERSION_HISTORY.md105
-rw-r--r--vendor/github.com/dgrijalva/jwt-go/cmd/jwt/app.go282
-rw-r--r--vendor/github.com/dgrijalva/jwt-go/cmd/jwt/args.go23
-rw-r--r--vendor/github.com/dgrijalva/jwt-go/request/doc.go7
-rw-r--r--vendor/github.com/dgrijalva/jwt-go/request/extractor.go81
-rw-r--r--vendor/github.com/dgrijalva/jwt-go/request/oauth2.go28
-rw-r--r--vendor/github.com/dgrijalva/jwt-go/request/request.go24
-rw-r--r--vendor/github.com/dgrijalva/jwt-go/test/helpers.go42
12 files changed, 304 insertions, 487 deletions
diff --git a/vendor/github.com/dgrijalva/jwt-go/.gitignore b/vendor/github.com/dgrijalva/jwt-go/.gitignore
new file mode 100644
index 00000000..80bed650
--- /dev/null
+++ b/vendor/github.com/dgrijalva/jwt-go/.gitignore
@@ -0,0 +1,4 @@
+.DS_Store
+bin
+
+
diff --git a/vendor/github.com/dgrijalva/jwt-go/.travis.yml b/vendor/github.com/dgrijalva/jwt-go/.travis.yml
new file mode 100644
index 00000000..1027f56c
--- /dev/null
+++ b/vendor/github.com/dgrijalva/jwt-go/.travis.yml
@@ -0,0 +1,13 @@
+language: go
+
+script:
+ - go vet ./...
+ - go test -v ./...
+
+go:
+ - 1.3
+ - 1.4
+ - 1.5
+ - 1.6
+ - 1.7
+ - tip
diff --git a/vendor/github.com/dgrijalva/jwt-go/MIGRATION_GUIDE.md b/vendor/github.com/dgrijalva/jwt-go/MIGRATION_GUIDE.md
new file mode 100644
index 00000000..7fc1f793
--- /dev/null
+++ b/vendor/github.com/dgrijalva/jwt-go/MIGRATION_GUIDE.md
@@ -0,0 +1,97 @@
+## Migration Guide from v2 -> v3
+
+Version 3 adds several new, frequently requested features. To do so, it introduces a few breaking changes. We've worked to keep these as minimal as possible. This guide explains the breaking changes and how you can quickly update your code.
+
+### `Token.Claims` is now an interface type
+
+The most requested feature from the 2.0 verison of this library was the ability to provide a custom type to the JSON parser for claims. This was implemented by introducing a new interface, `Claims`, to replace `map[string]interface{}`. We also included two concrete implementations of `Claims`: `MapClaims` and `StandardClaims`.
+
+`MapClaims` is an alias for `map[string]interface{}` with built in validation behavior. It is the default claims type when using `Parse`. The usage is unchanged except you must type cast the claims property.
+
+The old example for parsing a token looked like this..
+
+```go
+ if token, err := jwt.Parse(tokenString, keyLookupFunc); err == nil {
+ fmt.Printf("Token for user %v expires %v", token.Claims["user"], token.Claims["exp"])
+ }
+```
+
+is now directly mapped to...
+
+```go
+ if token, err := jwt.Parse(tokenString, keyLookupFunc); err == nil {
+ claims := token.Claims.(jwt.MapClaims)
+ fmt.Printf("Token for user %v expires %v", claims["user"], claims["exp"])
+ }
+```
+
+`StandardClaims` is designed to be embedded in your custom type. You can supply a custom claims type with the new `ParseWithClaims` function. Here's an example of using a custom claims type.
+
+```go
+ type MyCustomClaims struct {
+ User string
+ *StandardClaims
+ }
+
+ if token, err := jwt.ParseWithClaims(tokenString, &MyCustomClaims{}, keyLookupFunc); err == nil {
+ claims := token.Claims.(*MyCustomClaims)
+ fmt.Printf("Token for user %v expires %v", claims.User, claims.StandardClaims.ExpiresAt)
+ }
+```
+
+### `ParseFromRequest` has been moved
+
+To keep this library focused on the tokens without becoming overburdened with complex request processing logic, `ParseFromRequest` and its new companion `ParseFromRequestWithClaims` have been moved to a subpackage, `request`. The method signatues have also been augmented to receive a new argument: `Extractor`.
+
+`Extractors` do the work of picking the token string out of a request. The interface is simple and composable.
+
+This simple parsing example:
+
+```go
+ if token, err := jwt.ParseFromRequest(tokenString, req, keyLookupFunc); err == nil {
+ fmt.Printf("Token for user %v expires %v", token.Claims["user"], token.Claims["exp"])
+ }
+```
+
+is directly mapped to:
+
+```go
+ if token, err := request.ParseFromRequest(req, request.OAuth2Extractor, keyLookupFunc); err == nil {
+ claims := token.Claims.(jwt.MapClaims)
+ fmt.Printf("Token for user %v expires %v", claims["user"], claims["exp"])
+ }
+```
+
+There are several concrete `Extractor` types provided for your convenience:
+
+* `HeaderExtractor` will search a list of headers until one contains content.
+* `ArgumentExtractor` will search a list of keys in request query and form arguments until one contains content.
+* `MultiExtractor` will try a list of `Extractors` in order until one returns content.
+* `AuthorizationHeaderExtractor` will look in the `Authorization` header for a `Bearer` token.
+* `OAuth2Extractor` searches the places an OAuth2 token would be specified (per the spec): `Authorization` header and `access_token` argument
+* `PostExtractionFilter` wraps an `Extractor`, allowing you to process the content before it's parsed. A simple example is stripping the `Bearer ` text from a header
+
+
+### RSA signing methods no longer accept `[]byte` keys
+
+Due to a [critical vulnerability](https://auth0.com/blog/2015/03/31/critical-vulnerabilities-in-json-web-token-libraries/), we've decided the convenience of accepting `[]byte` instead of `rsa.PublicKey` or `rsa.PrivateKey` isn't worth the risk of misuse.
+
+To replace this behavior, we've added two helper methods: `ParseRSAPrivateKeyFromPEM(key []byte) (*rsa.PrivateKey, error)` and `ParseRSAPublicKeyFromPEM(key []byte) (*rsa.PublicKey, error)`. These are just simple helpers for unpacking PEM encoded PKCS1 and PKCS8 keys. If your keys are encoded any other way, all you need to do is convert them to the `crypto/rsa` package's types.
+
+```go
+ func keyLookupFunc(*Token) (interface{}, error) {
+ // Don't forget to validate the alg is what you expect:
+ if _, ok := token.Method.(*jwt.SigningMethodRSA); !ok {
+ return nil, fmt.Errorf("Unexpected signing method: %v", token.Header["alg"])
+ }
+
+ // Look up key
+ key, err := lookupPublicKey(token.Header["kid"])
+ if err != nil {
+ return nil, err
+ }
+
+ // Unpack key from PEM encoded PKCS8
+ return jwt.ParseRSAPublicKeyFromPEM(key)
+ }
+```
diff --git a/vendor/github.com/dgrijalva/jwt-go/README.md b/vendor/github.com/dgrijalva/jwt-go/README.md
new file mode 100644
index 00000000..70bae69e
--- /dev/null
+++ b/vendor/github.com/dgrijalva/jwt-go/README.md
@@ -0,0 +1,85 @@
+A [go](http://www.golang.org) (or 'golang' for search engine friendliness) implementation of [JSON Web Tokens](http://self-issued.info/docs/draft-ietf-oauth-json-web-token.html)
+
+[![Build Status](https://travis-ci.org/dgrijalva/jwt-go.svg?branch=master)](https://travis-ci.org/dgrijalva/jwt-go)
+
+**BREAKING CHANGES:*** Version 3.0.0 is here. It includes _a lot_ of changes including a few that break the API. We've tried to break as few things as possible, so there should just be a few type signature changes. A full list of breaking changes is available in `VERSION_HISTORY.md`. See `MIGRATION_GUIDE.md` for more information on updating your code.
+
+**NOTICE:** It's important that you [validate the `alg` presented is what you expect](https://auth0.com/blog/2015/03/31/critical-vulnerabilities-in-json-web-token-libraries/). This library attempts to make it easy to do the right thing by requiring key types match the expected alg, but you should take the extra step to verify it in your usage. See the examples provided.
+
+
+## What the heck is a JWT?
+
+JWT.io has [a great introduction](https://jwt.io/introduction) to JSON Web Tokens.
+
+In short, it's a signed JSON object that does something useful (for example, authentication). It's commonly used for `Bearer` tokens in Oauth 2. A token is made of three parts, separated by `.`'s. The first two parts are JSON objects, that have been [base64url](http://tools.ietf.org/html/rfc4648) encoded. The last part is the signature, encoded the same way.
+
+The first part is called the header. It contains the necessary information for verifying the last part, the signature. For example, which encryption method was used for signing and what key was used.
+
+The part in the middle is the interesting bit. It's called the Claims and contains the actual stuff you care about. Refer to [the RFC](http://self-issued.info/docs/draft-jones-json-web-token.html) for information about reserved keys and the proper way to add your own.
+
+## What's in the box?
+
+This library supports the parsing and verification as well as the generation and signing of JWTs. Current supported signing algorithms are HMAC SHA, RSA, RSA-PSS, and ECDSA, though hooks are present for adding your own.
+
+## Examples
+
+See [the project documentation](https://godoc.org/github.com/dgrijalva/jwt-go) for examples of usage:
+
+* [Simple example of parsing and validating a token](https://godoc.org/github.com/dgrijalva/jwt-go#example-Parse--Hmac)
+* [Simple example of building and signing a token](https://godoc.org/github.com/dgrijalva/jwt-go#example-New--Hmac)
+* [Directory of Examples](https://godoc.org/github.com/dgrijalva/jwt-go#pkg-examples)
+
+## Extensions
+
+This library publishes all the necessary components for adding your own signing methods. Simply implement the `SigningMethod` interface and register a factory method using `RegisterSigningMethod`.
+
+Here's an example of an extension that integrates with the Google App Engine signing tools: https://github.com/someone1/gcp-jwt-go
+
+## Compliance
+
+This library was last reviewed to comply with [RTF 7519](http://www.rfc-editor.org/info/rfc7519) dated May 2015 with a few notable differences:
+
+* In order to protect against accidental use of [Unsecured JWTs](http://self-issued.info/docs/draft-ietf-oauth-json-web-token.html#UnsecuredJWT), tokens using `alg=none` will only be accepted if the constant `jwt.UnsafeAllowNoneSignatureType` is provided as the key.
+
+## Project Status & Versioning
+
+This library is considered production ready. Feedback and feature requests are appreciated. The API should be considered stable. There should be very few backwards-incompatible changes outside of major version updates (and only with good reason).
+
+This project uses [Semantic Versioning 2.0.0](http://semver.org). Accepted pull requests will land on `master`. Periodically, versions will be tagged from `master`. You can find all the releases on [the project releases page](https://github.com/dgrijalva/jwt-go/releases).
+
+While we try to make it obvious when we make breaking changes, there isn't a great mechanism for pushing announcements out to users. You may want to use this alternative package include: `gopkg.in/dgrijalva/jwt-go.v2`. It will do the right thing WRT semantic versioning.
+
+## Usage Tips
+
+### Signing vs Encryption
+
+A token is simply a JSON object that is signed by its author. this tells you exactly two things about the data:
+
+* The author of the token was in the possession of the signing secret
+* The data has not been modified since it was signed
+
+It's important to know that JWT does not provide encryption, which means anyone who has access to the token can read its contents. If you need to protect (encrypt) the data, there is a companion spec, `JWE`, that provides this functionality. JWE is currently outside the scope of this library.
+
+### Choosing a Signing Method
+
+There are several signing methods available, and you should probably take the time to learn about the various options before choosing one. The principal design decision is most likely going to be symmetric vs asymmetric.
+
+Symmetric signing methods, such as HSA, use only a single secret. This is probably the simplest signing method to use since any `[]byte` can be used as a valid secret. They are also slightly computationally faster to use, though this rarely is enough to matter. Symmetric signing methods work the best when both producers and consumers of tokens are trusted, or even the same system. Since the same secret is used to both sign and validate tokens, you can't easily distribute the key for validation.
+
+Asymmetric signing methods, such as RSA, use different keys for signing and verifying tokens. This makes it possible to produce tokens with a private key, and allow any consumer to access the public key for verification.
+
+### JWT and OAuth
+
+It's worth mentioning that OAuth and JWT are not the same thing. A JWT token is simply a signed JSON object. It can be used anywhere such a thing is useful. There is some confusion, though, as JWT is the most common type of bearer token used in OAuth2 authentication.
+
+Without going too far down the rabbit hole, here's a description of the interaction of these technologies:
+
+* OAuth is a protocol for allowing an identity provider to be separate from the service a user is logging in to. For example, whenever you use Facebook to log into a different service (Yelp, Spotify, etc), you are using OAuth.
+* OAuth defines several options for passing around authentication data. One popular method is called a "bearer token". A bearer token is simply a string that _should_ only be held by an authenticated user. Thus, simply presenting this token proves your identity. You can probably derive from here why a JWT might make a good bearer token.
+* Because bearer tokens are used for authentication, it's important they're kept secret. This is why transactions that use bearer tokens typically happen over SSL.
+
+## More
+
+Documentation can be found [on godoc.org](http://godoc.org/github.com/dgrijalva/jwt-go).
+
+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 to documentation.
diff --git a/vendor/github.com/dgrijalva/jwt-go/VERSION_HISTORY.md b/vendor/github.com/dgrijalva/jwt-go/VERSION_HISTORY.md
new file mode 100644
index 00000000..b605b450
--- /dev/null
+++ b/vendor/github.com/dgrijalva/jwt-go/VERSION_HISTORY.md
@@ -0,0 +1,105 @@
+## `jwt-go` Version History
+
+#### 3.0.0
+
+* **Compatibility Breaking Changes**: See MIGRATION_GUIDE.md for tips on updating your code
+ * Dropped support for `[]byte` keys when using RSA signing methods. This convenience feature could contribute to security vulnerabilities involving mismatched key types with signing methods.
+ * `ParseFromRequest` has been moved to `request` subpackage and usage has changed
+ * The `Claims` property on `Token` is now type `Claims` instead of `map[string]interface{}`. The default value is type `MapClaims`, which is an alias to `map[string]interface{}`. This makes it possible to use a custom type when decoding claims.
+* Other Additions and Changes
+ * Added `Claims` interface type to allow users to decode the claims into a custom type
+ * Added `ParseWithClaims`, which takes a third argument of type `Claims`. Use this function instead of `Parse` if you have a custom type you'd like to decode into.
+ * Dramatically improved the functionality and flexibility of `ParseFromRequest`, which is now in the `request` subpackage
+ * Added `ParseFromRequestWithClaims` which is the `FromRequest` equivalent of `ParseWithClaims`
+ * Added new interface type `Extractor`, which is used for extracting JWT strings from http requests. Used with `ParseFromRequest` and `ParseFromRequestWithClaims`.
+ * Added several new, more specific, validation errors to error type bitmask
+ * Moved examples from README to executable example files
+ * Signing method registry is now thread safe
+ * Added new property to `ValidationError`, which contains the raw error returned by calls made by parse/verify (such as those returned by keyfunc or json parser)
+
+#### 2.7.0
+
+This will likely be the last backwards compatible release before 3.0.0, excluding essential bug fixes.
+
+* Added new option `-show` to the `jwt` command that will just output the decoded token without verifying
+* Error text for expired tokens includes how long it's been expired
+* Fixed incorrect error returned from `ParseRSAPublicKeyFromPEM`
+* Documentation updates
+
+#### 2.6.0
+
+* Exposed inner error within ValidationError
+* Fixed validation errors when using UseJSONNumber flag
+* Added several unit tests
+
+#### 2.5.0
+
+* Added support for signing method none. You shouldn't use this. The API tries to make this clear.
+* Updated/fixed some documentation
+* Added more helpful error message when trying to parse tokens that begin with `BEARER `
+
+#### 2.4.0
+
+* Added new type, Parser, to allow for configuration of various parsing parameters
+ * You can now specify a list of valid signing methods. Anything outside this set will be rejected.
+ * You can now opt to use the `json.Number` type instead of `float64` when parsing token JSON
+* Added support for [Travis CI](https://travis-ci.org/dgrijalva/jwt-go)
+* Fixed some bugs with ECDSA parsing
+
+#### 2.3.0
+
+* Added support for ECDSA signing methods
+* Added support for RSA PSS signing methods (requires go v1.4)
+
+#### 2.2.0
+
+* Gracefully handle a `nil` `Keyfunc` being passed to `Parse`. Result will now be the parsed token and an error, instead of a panic.
+
+#### 2.1.0
+
+Backwards compatible API change that was missed in 2.0.0.
+
+* The `SignedString` method on `Token` now takes `interface{}` instead of `[]byte`
+
+#### 2.0.0
+
+There were two major reasons for breaking backwards compatibility with this update. The first was a refactor required to expand the width of the RSA and HMAC-SHA signing implementations. There will likely be no required code changes to support this change.
+
+The second update, while unfortunately requiring a small change in integration, is required to open up this library to other signing methods. Not all keys used for all signing methods have a single standard on-disk representation. Requiring `[]byte` as the type for all keys proved too limiting. Additionally, this implementation allows for pre-parsed tokens to be reused, which might matter in an application that parses a high volume of tokens with a small set of keys. Backwards compatibilty has been maintained for passing `[]byte` to the RSA signing methods, but they will also accept `*rsa.PublicKey` and `*rsa.PrivateKey`.
+
+It is likely the only integration change required here will be to change `func(t *jwt.Token) ([]byte, error)` to `func(t *jwt.Token) (interface{}, error)` when calling `Parse`.
+
+* **Compatibility Breaking Changes**
+ * `SigningMethodHS256` is now `*SigningMethodHMAC` instead of `type struct`
+ * `SigningMethodRS256` is now `*SigningMethodRSA` instead of `type struct`
+ * `KeyFunc` now returns `interface{}` instead of `[]byte`
+ * `SigningMethod.Sign` now takes `interface{}` instead of `[]byte` for the key
+ * `SigningMethod.Verify` now takes `interface{}` instead of `[]byte` for the key
+* Renamed type `SigningMethodHS256` to `SigningMethodHMAC`. Specific sizes are now just instances of this type.
+ * Added public package global `SigningMethodHS256`
+ * Added public package global `SigningMethodHS384`
+ * Added public package global `SigningMethodHS512`
+* Renamed type `SigningMethodRS256` to `SigningMethodRSA`. Specific sizes are now just instances of this type.
+ * Added public package global `SigningMethodRS256`
+ * Added public package global `SigningMethodRS384`
+ * Added public package global `SigningMethodRS512`
+* Moved sample private key for HMAC tests from an inline value to a file on disk. Value is unchanged.
+* Refactored the RSA implementation to be easier to read
+* Exposed helper methods `ParseRSAPrivateKeyFromPEM` and `ParseRSAPublicKeyFromPEM`
+
+#### 1.0.2
+
+* Fixed bug in parsing public keys from certificates
+* Added more tests around the parsing of keys for RS256
+* Code refactoring in RS256 implementation. No functional changes
+
+#### 1.0.1
+
+* Fixed panic if RS256 signing method was passed an invalid key
+
+#### 1.0.0
+
+* First versioned release
+* API stabilized
+* Supports creating, signing, parsing, and validating JWT tokens
+* Supports RS256 and HS256 signing methods \ No newline at end of file
diff --git a/vendor/github.com/dgrijalva/jwt-go/cmd/jwt/app.go b/vendor/github.com/dgrijalva/jwt-go/cmd/jwt/app.go
deleted file mode 100644
index 727182a9..00000000
--- a/vendor/github.com/dgrijalva/jwt-go/cmd/jwt/app.go
+++ /dev/null
@@ -1,282 +0,0 @@
-// A useful example app. You can use this to debug your tokens on the command line.
-// This is also a great place to look at how you might use this library.
-//
-// Example usage:
-// The following will create and sign a token, then verify it and output the original claims.
-// echo {\"foo\":\"bar\"} | bin/jwt -key test/sample_key -alg RS256 -sign - | bin/jwt -key test/sample_key.pub -verify -
-package main
-
-import (
- "encoding/json"
- "flag"
- "fmt"
- "io"
- "io/ioutil"
- "os"
- "regexp"
- "strings"
-
- jwt "github.com/dgrijalva/jwt-go"
-)
-
-var (
- // Options
- flagAlg = flag.String("alg", "", "signing algorithm identifier")
- flagKey = flag.String("key", "", "path to key file or '-' to read from stdin")
- flagCompact = flag.Bool("compact", false, "output compact JSON")
- flagDebug = flag.Bool("debug", false, "print out all kinds of debug data")
- flagClaims = make(ArgList)
- flagHead = make(ArgList)
-
- // Modes - exactly one of these is required
- flagSign = flag.String("sign", "", "path to claims object to sign, '-' to read from stdin, or '+' to use only -claim args")
- flagVerify = flag.String("verify", "", "path to JWT token to verify or '-' to read from stdin")
- flagShow = flag.String("show", "", "path to JWT file or '-' to read from stdin")
-)
-
-func main() {
- // Plug in Var flags
- flag.Var(flagClaims, "claim", "add additional claims. may be used more than once")
- flag.Var(flagHead, "header", "add additional header params. may be used more than once")
-
- // Usage message if you ask for -help or if you mess up inputs.
- flag.Usage = func() {
- fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0])
- fmt.Fprintf(os.Stderr, " One of the following flags is required: sign, verify\n")
- flag.PrintDefaults()
- }
-
- // Parse command line options
- flag.Parse()
-
- // Do the thing. If something goes wrong, print error to stderr
- // and exit with a non-zero status code
- if err := start(); err != nil {
- fmt.Fprintf(os.Stderr, "Error: %v\n", err)
- os.Exit(1)
- }
-}
-
-// Figure out which thing to do and then do that
-func start() error {
- if *flagSign != "" {
- return signToken()
- } else if *flagVerify != "" {
- return verifyToken()
- } else if *flagShow != "" {
- return showToken()
- } else {
- flag.Usage()
- return fmt.Errorf("None of the required flags are present. What do you want me to do?")
- }
-}
-
-// Helper func: Read input from specified file or stdin
-func loadData(p string) ([]byte, error) {
- if p == "" {
- return nil, fmt.Errorf("No path specified")
- }
-
- var rdr io.Reader
- if p == "-" {
- rdr = os.Stdin
- } else if p == "+" {
- return []byte("{}"), nil
- } else {
- if f, err := os.Open(p); err == nil {
- rdr = f
- defer f.Close()
- } else {
- return nil, err
- }
- }
- return ioutil.ReadAll(rdr)
-}
-
-// Print a json object in accordance with the prophecy (or the command line options)
-func printJSON(j interface{}) error {
- var out []byte
- var err error
-
- if *flagCompact == false {
- out, err = json.MarshalIndent(j, "", " ")
- } else {
- out, err = json.Marshal(j)
- }
-
- if err == nil {
- fmt.Println(string(out))
- }
-
- return err
-}
-
-// Verify a token and output the claims. This is a great example
-// of how to verify and view a token.
-func verifyToken() error {
- // get the token
- tokData, err := loadData(*flagVerify)
- if err != nil {
- return fmt.Errorf("Couldn't read token: %v", err)
- }
-
- // trim possible whitespace from token
- tokData = regexp.MustCompile(`\s*$`).ReplaceAll(tokData, []byte{})
- if *flagDebug {
- fmt.Fprintf(os.Stderr, "Token len: %v bytes\n", len(tokData))
- }
-
- // Parse the token. Load the key from command line option
- token, err := jwt.Parse(string(tokData), func(t *jwt.Token) (interface{}, error) {
- data, err := loadData(*flagKey)
- if err != nil {
- return nil, err
- }
- if isEs() {
- return jwt.ParseECPublicKeyFromPEM(data)
- } else if isRs() {
- return jwt.ParseRSAPublicKeyFromPEM(data)
- }
- return data, nil
- })
-
- // Print some debug data
- if *flagDebug && token != nil {
- fmt.Fprintf(os.Stderr, "Header:\n%v\n", token.Header)
- fmt.Fprintf(os.Stderr, "Claims:\n%v\n", token.Claims)
- }
-
- // Print an error if we can't parse for some reason
- if err != nil {
- return fmt.Errorf("Couldn't parse token: %v", err)
- }
-
- // Is token invalid?
- if !token.Valid {
- return fmt.Errorf("Token is invalid")
- }
-
- // Print the token details
- if err := printJSON(token.Claims); err != nil {
- return fmt.Errorf("Failed to output claims: %v", err)
- }
-
- return nil
-}
-
-// Create, sign, and output a token. This is a great, simple example of
-// how to use this library to create and sign a token.
-func signToken() error {
- // get the token data from command line arguments
- tokData, err := loadData(*flagSign)
- if err != nil {
- return fmt.Errorf("Couldn't read token: %v", err)
- } else if *flagDebug {
- fmt.Fprintf(os.Stderr, "Token: %v bytes", len(tokData))
- }
-
- // parse the JSON of the claims
- var claims jwt.MapClaims
- if err := json.Unmarshal(tokData, &claims); err != nil {
- return fmt.Errorf("Couldn't parse claims JSON: %v", err)
- }
-
- // add command line claims
- if len(flagClaims) > 0 {
- for k, v := range flagClaims {
- claims[k] = v
- }
- }
-
- // get the key
- var key interface{}
- key, err = loadData(*flagKey)
- if err != nil {
- return fmt.Errorf("Couldn't read key: %v", err)
- }
-
- // get the signing alg
- alg := jwt.GetSigningMethod(*flagAlg)
- if alg == nil {
- return fmt.Errorf("Couldn't find signing method: %v", *flagAlg)
- }
-
- // create a new token
- token := jwt.NewWithClaims(alg, claims)
-
- // add command line headers
- if len(flagHead) > 0 {
- for k, v := range flagHead {
- token.Header[k] = v
- }
- }
-
- if isEs() {
- if k, ok := key.([]byte); !ok {
- return fmt.Errorf("Couldn't convert key data to key")
- } else {
- key, err = jwt.ParseECPrivateKeyFromPEM(k)
- if err != nil {
- return err
- }
- }
- } else if isRs() {
- if k, ok := key.([]byte); !ok {
- return fmt.Errorf("Couldn't convert key data to key")
- } else {
- key, err = jwt.ParseRSAPrivateKeyFromPEM(k)
- if err != nil {
- return err
- }
- }
- }
-
- if out, err := token.SignedString(key); err == nil {
- fmt.Println(out)
- } else {
- return fmt.Errorf("Error signing token: %v", err)
- }
-
- return nil
-}
-
-// showToken pretty-prints the token on the command line.
-func showToken() error {
- // get the token
- tokData, err := loadData(*flagShow)
- if err != nil {
- return fmt.Errorf("Couldn't read token: %v", err)
- }
-
- // trim possible whitespace from token
- tokData = regexp.MustCompile(`\s*$`).ReplaceAll(tokData, []byte{})
- if *flagDebug {
- fmt.Fprintf(os.Stderr, "Token len: %v bytes\n", len(tokData))
- }
-
- token, err := jwt.Parse(string(tokData), nil)
- if token == nil {
- return fmt.Errorf("malformed token: %v", err)
- }
-
- // Print the token details
- fmt.Println("Header:")
- if err := printJSON(token.Header); err != nil {
- return fmt.Errorf("Failed to output header: %v", err)
- }
-
- fmt.Println("Claims:")
- if err := printJSON(token.Claims); err != nil {
- return fmt.Errorf("Failed to output claims: %v", err)
- }
-
- return nil
-}
-
-func isEs() bool {
- return strings.HasPrefix(*flagAlg, "ES")
-}
-
-func isRs() bool {
- return strings.HasPrefix(*flagAlg, "RS")
-}
diff --git a/vendor/github.com/dgrijalva/jwt-go/cmd/jwt/args.go b/vendor/github.com/dgrijalva/jwt-go/cmd/jwt/args.go
deleted file mode 100644
index a5bba5b1..00000000
--- a/vendor/github.com/dgrijalva/jwt-go/cmd/jwt/args.go
+++ /dev/null
@@ -1,23 +0,0 @@
-package main
-
-import (
- "encoding/json"
- "fmt"
- "strings"
-)
-
-type ArgList map[string]string
-
-func (l ArgList) String() string {
- data, _ := json.Marshal(l)
- return string(data)
-}
-
-func (l ArgList) Set(arg string) error {
- parts := strings.SplitN(arg, "=", 2)
- if len(parts) != 2 {
- return fmt.Errorf("Invalid argument '%v'. Must use format 'key=value'. %v", arg, parts)
- }
- l[parts[0]] = parts[1]
- return nil
-}
diff --git a/vendor/github.com/dgrijalva/jwt-go/request/doc.go b/vendor/github.com/dgrijalva/jwt-go/request/doc.go
deleted file mode 100644
index c01069c9..00000000
--- a/vendor/github.com/dgrijalva/jwt-go/request/doc.go
+++ /dev/null
@@ -1,7 +0,0 @@
-// Utility package for extracting JWT tokens from
-// HTTP requests.
-//
-// The main function is ParseFromRequest and it's WithClaims variant.
-// See examples for how to use the various Extractor implementations
-// or roll your own.
-package request
diff --git a/vendor/github.com/dgrijalva/jwt-go/request/extractor.go b/vendor/github.com/dgrijalva/jwt-go/request/extractor.go
deleted file mode 100644
index 14414fe2..00000000
--- a/vendor/github.com/dgrijalva/jwt-go/request/extractor.go
+++ /dev/null
@@ -1,81 +0,0 @@
-package request
-
-import (
- "errors"
- "net/http"
-)
-
-// Errors
-var (
- ErrNoTokenInRequest = errors.New("no token present in request")
-)
-
-// Interface for extracting a token from an HTTP request.
-// The ExtractToken method should return a token string or an error.
-// If no token is present, you must return ErrNoTokenInRequest.
-type Extractor interface {
- ExtractToken(*http.Request) (string, error)
-}
-
-// Extractor for finding a token in a header. Looks at each specified
-// header in order until there's a match
-type HeaderExtractor []string
-
-func (e HeaderExtractor) ExtractToken(req *http.Request) (string, error) {
- // loop over header names and return the first one that contains data
- for _, header := range e {
- if ah := req.Header.Get(header); ah != "" {
- return ah, nil
- }
- }
- return "", ErrNoTokenInRequest
-}
-
-// Extract token from request arguments. This includes a POSTed form or
-// GET URL arguments. Argument names are tried in order until there's a match.
-// This extractor calls `ParseMultipartForm` on the request
-type ArgumentExtractor []string
-
-func (e ArgumentExtractor) ExtractToken(req *http.Request) (string, error) {
- // Make sure form is parsed
- req.ParseMultipartForm(10e6)
-
- // loop over arg names and return the first one that contains data
- for _, arg := range e {
- if ah := req.Form.Get(arg); ah != "" {
- return ah, nil
- }
- }
-
- return "", ErrNoTokenInRequest
-}
-
-// Tries Extractors in order until one returns a token string or an error occurs
-type MultiExtractor []Extractor
-
-func (e MultiExtractor) ExtractToken(req *http.Request) (string, error) {
- // loop over header names and return the first one that contains data
- for _, extractor := range e {
- if tok, err := extractor.ExtractToken(req); tok != "" {
- return tok, nil
- } else if err != ErrNoTokenInRequest {
- return "", err
- }
- }
- return "", ErrNoTokenInRequest
-}
-
-// Wrap an Extractor in this to post-process the value before it's handed off.
-// See AuthorizationHeaderExtractor for an example
-type PostExtractionFilter struct {
- Extractor
- Filter func(string) (string, error)
-}
-
-func (e *PostExtractionFilter) ExtractToken(req *http.Request) (string, error) {
- if tok, err := e.Extractor.ExtractToken(req); tok != "" {
- return e.Filter(tok)
- } else {
- return "", err
- }
-}
diff --git a/vendor/github.com/dgrijalva/jwt-go/request/oauth2.go b/vendor/github.com/dgrijalva/jwt-go/request/oauth2.go
deleted file mode 100644
index 5948694a..00000000
--- a/vendor/github.com/dgrijalva/jwt-go/request/oauth2.go
+++ /dev/null
@@ -1,28 +0,0 @@
-package request
-
-import (
- "strings"
-)
-
-// Strips 'Bearer ' prefix from bearer token string
-func stripBearerPrefixFromTokenString(tok string) (string, error) {
- // Should be a bearer token
- if len(tok) > 6 && strings.ToUpper(tok[0:7]) == "BEARER " {
- return tok[7:], nil
- }
- return tok, nil
-}
-
-// Extract bearer token from Authorization header
-// Uses PostExtractionFilter to strip "Bearer " prefix from header
-var AuthorizationHeaderExtractor = &PostExtractionFilter{
- HeaderExtractor{"Authorization"},
- stripBearerPrefixFromTokenString,
-}
-
-// Extractor for OAuth2 access tokens. Looks in 'Authorization'
-// header then 'access_token' argument for a token.
-var OAuth2Extractor = &MultiExtractor{
- AuthorizationHeaderExtractor,
- ArgumentExtractor{"access_token"},
-}
diff --git a/vendor/github.com/dgrijalva/jwt-go/request/request.go b/vendor/github.com/dgrijalva/jwt-go/request/request.go
deleted file mode 100644
index 1807b396..00000000
--- a/vendor/github.com/dgrijalva/jwt-go/request/request.go
+++ /dev/null
@@ -1,24 +0,0 @@
-package request
-
-import (
- "github.com/dgrijalva/jwt-go"
- "net/http"
-)
-
-// Extract and parse a JWT token from an HTTP request.
-// This behaves the same as Parse, but accepts a request and an extractor
-// instead of a token string. The Extractor interface allows you to define
-// the logic for extracting a token. Several useful implementations are provided.
-func ParseFromRequest(req *http.Request, extractor Extractor, keyFunc jwt.Keyfunc) (token *jwt.Token, err error) {
- return ParseFromRequestWithClaims(req, extractor, jwt.MapClaims{}, keyFunc)
-}
-
-// ParseFromRequest but with custom Claims type
-func ParseFromRequestWithClaims(req *http.Request, extractor Extractor, claims jwt.Claims, keyFunc jwt.Keyfunc) (token *jwt.Token, err error) {
- // Extract token from request
- if tokStr, err := extractor.ExtractToken(req); err == nil {
- return jwt.ParseWithClaims(tokStr, claims, keyFunc)
- } else {
- return nil, err
- }
-}
diff --git a/vendor/github.com/dgrijalva/jwt-go/test/helpers.go b/vendor/github.com/dgrijalva/jwt-go/test/helpers.go
deleted file mode 100644
index f84c3ef6..00000000
--- a/vendor/github.com/dgrijalva/jwt-go/test/helpers.go
+++ /dev/null
@@ -1,42 +0,0 @@
-package test
-
-import (
- "crypto/rsa"
- "github.com/dgrijalva/jwt-go"
- "io/ioutil"
-)
-
-func LoadRSAPrivateKeyFromDisk(location string) *rsa.PrivateKey {
- keyData, e := ioutil.ReadFile(location)
- if e != nil {
- panic(e.Error())
- }
- key, e := jwt.ParseRSAPrivateKeyFromPEM(keyData)
- if e != nil {
- panic(e.Error())
- }
- return key
-}
-
-func LoadRSAPublicKeyFromDisk(location string) *rsa.PublicKey {
- keyData, e := ioutil.ReadFile(location)
- if e != nil {
- panic(e.Error())
- }
- key, e := jwt.ParseRSAPublicKeyFromPEM(keyData)
- if e != nil {
- panic(e.Error())
- }
- return key
-}
-
-func MakeSampleToken(c jwt.Claims, key interface{}) string {
- token := jwt.NewWithClaims(jwt.SigningMethodRS256, c)
- s, e := token.SignedString(key)
-
- if e != nil {
- panic(e.Error())
- }
-
- return s
-}