mirror of https://github.com/golang-jwt/jwt.git
Allow `none` algorithm in jwt command (#121)
This commit is contained in:
parent
f4865cddea
commit
1275a5b909
|
@ -128,6 +128,9 @@ func verifyToken() error {
|
||||||
|
|
||||||
// Parse the token. Load the key from command line option
|
// Parse the token. Load the key from command line option
|
||||||
token, err := jwt.Parse(string(tokData), func(t *jwt.Token) (interface{}, error) {
|
token, err := jwt.Parse(string(tokData), func(t *jwt.Token) (interface{}, error) {
|
||||||
|
if isNone() {
|
||||||
|
return jwt.UnsafeAllowNoneSignatureType, nil
|
||||||
|
}
|
||||||
data, err := loadData(*flagKey)
|
data, err := loadData(*flagKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -192,9 +195,13 @@ func signToken() error {
|
||||||
|
|
||||||
// get the key
|
// get the key
|
||||||
var key interface{}
|
var key interface{}
|
||||||
key, err = loadData(*flagKey)
|
if isNone() {
|
||||||
if err != nil {
|
key = jwt.UnsafeAllowNoneSignatureType
|
||||||
return fmt.Errorf("couldn't read key: %w", err)
|
} else {
|
||||||
|
key, err = loadData(*flagKey)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("couldn't read key: %w", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the signing alg
|
// get the signing alg
|
||||||
|
@ -296,6 +303,10 @@ func isEd() bool {
|
||||||
return *flagAlg == "EdDSA"
|
return *flagAlg == "EdDSA"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isNone() bool {
|
||||||
|
return *flagAlg == "none"
|
||||||
|
}
|
||||||
|
|
||||||
type ArgList map[string]string
|
type ArgList map[string]string
|
||||||
|
|
||||||
func (l ArgList) String() string {
|
func (l ArgList) String() string {
|
||||||
|
|
Loading…
Reference in New Issue