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

feat: Add JWT token type #100

Merged
merged 1 commit into from
Feb 20, 2024
Merged

Conversation

pi-kei
Copy link
Contributor

@pi-kei pi-kei commented Feb 20, 2024

Fix: #99 (comment)

Add TokenType field to casdoorsdk.Claims.
Add IsRefreshToken func to casdoorsdk.Claims.
This feature will let you find out if you are dealing with refresh token or access token.

@casbin-bot
Copy link

@tangyang9464 @imp2002 please review

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

casdoorsdk/jwt.go Show resolved Hide resolved
@hsluoyz hsluoyz merged commit de7a122 into casdoor:master Feb 20, 2024
3 of 4 checks passed
Copy link

🎉 This PR is included in version 0.36.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@pi-kei
Copy link
Contributor Author

pi-kei commented Feb 20, 2024

@hsluoyz I'm sorry but I've not tested this properly. So, it is not working as expected. Now casdoorsdk.Claims.TokenType is always equals to access-token because of how json decoder works.

Here's the quote from docs:

To unmarshal JSON into a struct, Unmarshal matches incoming object keys to the keys used by Marshal (either the struct field name or its tag), preferring an exact match but also accepting a case-insensitive match.

Right now it's treating tokenType and TokenType as the same field. To fix that there must be both of them in struct. I can do a fix PR for that.

@hsluoyz
Copy link
Member

hsluoyz commented Feb 20, 2024

@pi-kei I told you to test your code locally before submitting it. Now this PR will be reverted. And I have to see your demo video to show the test case running well (but don't submit it) before merging your PR again

hsluoyz pushed a commit that referenced this pull request Feb 20, 2024
* feat: Add JWT token type (#100)

* fix: Fix JWT token type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refresh token and access token are interchangeable
4 participants