Permalink
Browse files

Lint fix, rename JwtAuth to JWTAuth

  • Loading branch information...
1 parent 34cf10b commit ace6ea2799e5dfd6a4da59621179213c44ebd814 Peter Kieltyka committed Nov 26, 2017
Showing with 15 additions and 15 deletions.
  1. +1 −1 README.md
  2. +1 −1 _example/main.go
  3. +11 −11 jwtauth.go
  4. +2 −2 jwtauth_test.go
View
@@ -59,7 +59,7 @@ import (
"github.com/go-chi/jwtauth"
)
-var tokenAuth *jwtauth.JwtAuth
+var tokenAuth *jwtauth.JWTAuth
func init() {
tokenAuth = jwtauth.New("HS256", []byte("secret"), nil)
View
@@ -66,7 +66,7 @@ import (
"github.com/go-chi/jwtauth"
)
-var tokenAuth *jwtauth.JwtAuth
+var tokenAuth *jwtauth.JWTAuth
func init() {
tokenAuth = jwtauth.New("HS256", []byte("secret"), nil)
View
@@ -49,16 +49,16 @@ var (
}
)
-type JwtAuth struct {
+type JWTAuth struct {
signKey interface{}
verifyKey interface{}
signer jwt.SigningMethod
parser *jwt.Parser
}
-// New creates a JwtAuth authenticator instance that provides middleware handlers
+// New creates a JWTAuth authenticator instance that provides middleware handlers
// and encoding/decoding functions for JWT signing.
-func New(alg string, signKey interface{}, verifyKey interface{}) *JwtAuth {
+func New(alg string, signKey interface{}, verifyKey interface{}) *JWTAuth {
return NewWithParser(alg, &jwt.Parser{}, signKey, verifyKey)
}
@@ -68,9 +68,9 @@ func New(alg string, signKey interface{}, verifyKey interface{}) *JwtAuth {
// We explicitly toggle `SkipClaimsValidation` in the `jwt-go` parser so that
// we can control when the claims are validated - in our case, by the Verifier
// http middleware handler.
-func NewWithParser(alg string, parser *jwt.Parser, signKey interface{}, verifyKey interface{}) *JwtAuth {
+func NewWithParser(alg string, parser *jwt.Parser, signKey interface{}, verifyKey interface{}) *JWTAuth {
parser.SkipClaimsValidation = true
- return &JwtAuth{
+ return &JWTAuth{
signKey: signKey,
verifyKey: verifyKey,
signer: jwt.GetSigningMethod(alg),
@@ -94,13 +94,13 @@ func NewWithParser(alg string, parser *jwt.Parser, signKey interface{}, verifyKe
// be the generic `jwtauth.Authenticator` middleware or your own custom handler
// which checks the request context jwt token and error to prepare a custom
// http response.
-func Verifier(ja *JwtAuth) func(http.Handler) http.Handler {
+func Verifier(ja *JWTAuth) func(http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return Verify(ja, TokenFromQuery, TokenFromHeader, TokenFromCookie)(next)
}
}
-func Verify(ja *JwtAuth, findTokenFns ...func(r *http.Request) string) func(http.Handler) http.Handler {
+func Verify(ja *JWTAuth, findTokenFns ...func(r *http.Request) string) func(http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
hfn := func(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
@@ -112,7 +112,7 @@ func Verify(ja *JwtAuth, findTokenFns ...func(r *http.Request) string) func(http
}
}
-func VerifyRequest(ja *JwtAuth, r *http.Request, findTokenFns ...func(r *http.Request) string) (*jwt.Token, error) {
+func VerifyRequest(ja *JWTAuth, r *http.Request, findTokenFns ...func(r *http.Request) string) (*jwt.Token, error) {
var tokenStr string
var err error
@@ -153,15 +153,15 @@ func VerifyRequest(ja *JwtAuth, r *http.Request, findTokenFns ...func(r *http.Re
return token, nil
}
-func (ja *JwtAuth) Encode(claims Claims) (t *jwt.Token, tokenString string, err error) {
+func (ja *JWTAuth) Encode(claims Claims) (t *jwt.Token, tokenString string, err error) {
t = jwt.New(ja.signer)
t.Claims = claims
tokenString, err = t.SignedString(ja.signKey)
t.Raw = tokenString
return
}
-func (ja *JwtAuth) Decode(tokenString string) (t *jwt.Token, err error) {
+func (ja *JWTAuth) Decode(tokenString string) (t *jwt.Token, err error) {
// Decode the tokenString, but avoid using custom Claims via jwt-go's
// ParseWithClaims as the jwt-go types will cause some glitches, so easier
// to decode as MapClaims then wrap the underlying map[string]interface{}
@@ -173,7 +173,7 @@ func (ja *JwtAuth) Decode(tokenString string) (t *jwt.Token, err error) {
return
}
-func (ja *JwtAuth) keyFunc(t *jwt.Token) (interface{}, error) {
+func (ja *JWTAuth) keyFunc(t *jwt.Token) (interface{}, error) {
if ja.verifyKey != nil {
return ja.verifyKey, nil
} else {
View
@@ -19,10 +19,10 @@ import (
)
var (
- TokenAuthHS256 *jwtauth.JwtAuth
+ TokenAuthHS256 *jwtauth.JWTAuth
TokenSecret = []byte("secretpass")
- TokenAuthRS256 *jwtauth.JwtAuth
+ TokenAuthRS256 *jwtauth.JWTAuth
PrivateKeyRS256String = `-----BEGIN RSA PRIVATE KEY-----
MIIBOwIBAAJBALxo3PCjFw4QjgOX06QCJIJBnXXNiEYwDLxxa5/7QyH6y77nCRQy

3 comments on commit ace6ea2

That was a breaking change, not a patch-version bump... 👎

Owner

pkieltyka replied Nov 29, 2017

@lootek use something else than if you're unhappy to do a simple search+replace

Contributor

VojtechVitek replied Nov 29, 2017

We should bump to v3.2.0 at least, or revert and save this for v4.0.0. These breaking changes don't play well with golang/dep.

Please sign in to comment.