Commit fbf92700f4c7403d1086f3e97373a686081cfe34

Authored by Marko Tikvić
1 parent 2b62f61cc8
Exists in master

renamed package variables

Showing 1 changed file with 8 additions and 8 deletions   Show diff stats
... ... @@ -12,8 +12,8 @@ import (
12 12 "github.com/dgrijalva/jwt-go"
13 13 )
14 14  
15   -var appName = "webutility"
16   -var secret = "webutility"
  15 +var _issuer = "webutility"
  16 +var _secret = "webutility"
17 17  
18 18 // TokenClaims are JWT token claims.
19 19 type TokenClaims struct {
... ... @@ -29,9 +29,9 @@ type TokenClaims struct {
29 29 ExpiresIn int64 `json:"expires_in"`
30 30 }
31 31  
32   -func InitJWT(appName, secret string) {
33   - appName = appName
34   - secret = secret
  32 +func InitJWT(issuer, secret string) {
  33 + _issuer = issuer
  34 + _secret = secret
35 35 }
36 36  
37 37 // ValidateHash hashes pass and salt and returns comparison result with resultHash
... ... @@ -93,10 +93,10 @@ func CreateAuthToken(username string, roleName string, roleID int64) (TokenClaim
93 93 // initialize jwt.StandardClaims fields (anonymous struct)
94 94 claims.IssuedAt = t0
95 95 claims.ExpiresAt = t1
96   - claims.Issuer = appName
  96 + claims.Issuer = _issuer
97 97  
98 98 jwtToken := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
99   - token, err := jwtToken.SignedString([]byte(secret))
  99 + token, err := jwtToken.SignedString([]byte(_secret))
100 100 if err != nil {
101 101 return TokenClaims{}, err
102 102 }
... ... @@ -204,5 +204,5 @@ func randomSalt() (s string, err error) {
204 204  
205 205 // secretFunc returns byte slice of API secret keyword.
206 206 func secretFunc(token *jwt.Token) (interface{}, error) {
207   - return []byte(secret), nil
  207 + return []byte(_secret), nil
208 208 }
... ...