Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Claim creation issue in the example #38

Closed

Conversation

iamharvey
Copy link

In the example, the Claims is created using jwt.MapClaims. It should be jwtauth.Claims. Thus, the codes in init() should be as follows:

tokenAuth = jwtauth.New("HS256", []byte("secret"), nil)
...
_, tokenString, _ := tokenAuth.Encode(jwtauth.Claims{"user_id": 123})
fmt.Printf("DEBUG: a sample jwt is %s\n\n", tokenString)

In the example, the Claims is created using `jwt.MapClaims`. It should be `jwtauth.Claims`. Thus, the codes in `init()` should be as follows:
```
tokenAuth = jwtauth.New("HS256", []byte("secret"), nil)
```
_, tokenString, _ := tokenAuth.Encode(jwtauth.Claims{"user_id": 123})
fmt.Printf("DEBUG: a sample jwt is %s\n\n", tokenString)
```
@jc21
Copy link

jc21 commented Aug 21, 2019

Verified this works

@dnlo
Copy link

dnlo commented Sep 21, 2019

#41 #44 Triple punch!
Do the same in _example/main.go too before someone submits another pr

@qaisjp
Copy link

qaisjp commented Sep 22, 2019

@pkieltyka, any plans to maintain this?

@pkieltyka
Copy link
Member

hey guys, seems the issue is related a go modules config bug in the pkg. With jwtauth v4, we changed the signature of the Encode method. The example in master (v4) is correct and works fine. The issue is #42

Turns out the mod file I had written was incorrect and pointing at an older version. The go modules stuff really gets messy if a package decides to use anything besides v1.x.x -- moral of the story is to never break that scheme, and unfortunately for jwtauth we did that much before go modules was even a thing. I have a plan though, I'll open up a new ticket.

In the mean time, I've removed the invalid go.mod file from master, and you can use GO111MODULE=on go get -u github.com/go-chi/jwtauth to get the latest jwauth

@iamharvey
Copy link
Author

@pkieltyka Thanks Peter.

@qaisjp
Copy link

qaisjp commented Sep 23, 2019

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants