mirror of
https://github.com/documize/community.git
synced 2025-07-29 10:09:43 +02:00
upgraded vendored jwt-go lib
This commit is contained in:
parent
b5f85637a7
commit
8aeb3eaec4
34 changed files with 1752 additions and 341 deletions
24
vendor/github.com/dgrijalva/jwt-go/request/request.go
generated
vendored
Normal file
24
vendor/github.com/dgrijalva/jwt-go/request/request.go
generated
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
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
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue