diff --git a/auth.go b/auth.go index ec049c1..3783a2e 100644 --- a/auth.go +++ b/auth.go @@ -12,8 +12,8 @@ import ( "github.com/dgrijalva/jwt-go" ) -var appName = "webutility" -var secret = "webutility" +var _issuer = "webutility" +var _secret = "webutility" // TokenClaims are JWT token claims. type TokenClaims struct { @@ -29,9 +29,9 @@ type TokenClaims struct { ExpiresIn int64 `json:"expires_in"` } -func InitJWT(appName, secret string) { - appName = appName - secret = secret +func InitJWT(issuer, secret string) { + _issuer = issuer + _secret = secret } // ValidateHash hashes pass and salt and returns comparison result with resultHash @@ -93,10 +93,10 @@ func CreateAuthToken(username string, roleName string, roleID int64) (TokenClaim // initialize jwt.StandardClaims fields (anonymous struct) claims.IssuedAt = t0 claims.ExpiresAt = t1 - claims.Issuer = appName + claims.Issuer = _issuer jwtToken := jwt.NewWithClaims(jwt.SigningMethodHS256, claims) - token, err := jwtToken.SignedString([]byte(secret)) + token, err := jwtToken.SignedString([]byte(_secret)) if err != nil { return TokenClaims{}, err } @@ -204,5 +204,5 @@ func randomSalt() (s string, err error) { // secretFunc returns byte slice of API secret keyword. func secretFunc(token *jwt.Token) (interface{}, error) { - return []byte(secret), nil + return []byte(_secret), nil }