diff --git a/README.md b/README.md index 99942d8..f0a8f9d 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Parsing and verifying tokens is pretty straight forward. You pass in the token ```go // Create the token - token := jwt.New(jwt.GetSigningMethod("HS256")) + token := jwt.New(SigningMethodHS256) // Set some claims token.Claims["foo"] = "bar" token.Claims["exp"] = time.Now().Add(time.Hour * 72).Unix() diff --git a/jwt_test.go b/jwt_test.go index 557c850..a457c02 100644 --- a/jwt_test.go +++ b/jwt_test.go @@ -104,7 +104,7 @@ func makeSample(c map[string]interface{}) string { panic(e.Error()) } - token := New(GetSigningMethod("RS256")) + token := New(SigningMethodRS256) token.Claims = c s, e := token.SignedString(key) diff --git a/rsa_test.go b/rsa_test.go index 8d96fb6..a36dbd8 100644 --- a/rsa_test.go +++ b/rsa_test.go @@ -80,14 +80,13 @@ func TestRSASign(t *testing.T) { func TestRSAVerifyWithPreParsedPrivateKey(t *testing.T) { key, _ := ioutil.ReadFile("test/sample_key.pub") - method := GetSigningMethod("RS256").(*SigningMethodRSA) parsedKey, err := ParseRSAPublicKeyFromPEM(key) if err != nil { t.Fatal(err) } testData := rsaTestData[0] parts := strings.Split(testData.tokenString, ".") - err = method.Verify(strings.Join(parts[0:2], "."), parts[2], parsedKey) + err = SigningMethodRS256.Verify(strings.Join(parts[0:2], "."), parts[2], parsedKey) if err != nil { t.Errorf("[%v] Error while verifying key: %v", testData.name, err) } @@ -95,14 +94,13 @@ func TestRSAVerifyWithPreParsedPrivateKey(t *testing.T) { func TestRSAWithPreParsedPrivateKey(t *testing.T) { key, _ := ioutil.ReadFile("test/sample_key") - method := GetSigningMethod("RS256").(*SigningMethodRSA) parsedKey, err := ParseRSAPrivateKeyFromPEM(key) if err != nil { t.Fatal(err) } testData := rsaTestData[0] parts := strings.Split(testData.tokenString, ".") - sig, err := method.Sign(strings.Join(parts[0:2], "."), parsedKey) + sig, err := SigningMethodRS256.Sign(strings.Join(parts[0:2], "."), parsedKey) if err != nil { t.Errorf("[%v] Error signing token: %v", testData.name, err) }