casdoor / casdoor-go-sdk

Go client SDK for Casdoor
https://github.com/casdoor/casdoor
Apache License 2.0
86 stars 70 forks source link

feat: Add JWT token type #100

Closed pi-kei closed 7 months ago

pi-kei commented 7 months ago

Fix: https://github.com/casdoor/casdoor-go-sdk/issues/99#issuecomment-1954464072

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 commented 7 months ago

@tangyang9464 @imp2002 please review

CLAassistant commented 7 months ago

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.

github-actions[bot] commented 7 months ago

:tada: This PR is included in version 0.36.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

pi-kei commented 7 months ago

@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 commented 7 months ago

@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