Casbin Forum runs on Casnode, the open-source Discourse-style forum. Try the Casnode demo →
Casbin Forum

Hello, guys! It seems that I have found some unexpected behavior when using the casdoor-go-sdk: when parsing the accessToken JWT, I get a casdoorsdk.User{} structure with the Id attribute, which is set by casdoor itself. Then, I want to call the casdoorsdk.UpdateUser method, passing a reference to the new casdoorsdk.User structure with the Id and Groups attributes set. However, the method returns an error "The user: / doesn't exist" because it uses its own Id generated from the combination of the Owner and Name attributes (https://github.com/casdoor/casdoor-go-sdk/blob/348c6d99dc24fd6f66e39ced23e41137715c7765/casdoorsdk/user.go#L442). It seems that is not ok, and I can make a PR to fix it.

P.s.
Checked in other SDKs, the situation is the same there.

3views
2users
1 minread

it's not bug. User struct's owner and name must be set

In casdoor, in most times, "id" means "owner/name" instead of the id field. The id field means more like "UUID"

Yes, but it would be correct to also write the same Id in AccessToken's User claims so that the Id attribute of casdoorsdk.User structure for in/out operations is the same, isn't it? To resolve this inconsistency, it is better to separate the two structures: one for writing to JWT Claims (with an Id assigned by casdoor), and the other for user modify operations, which will not have the Id field since it is immutable.

1 / 4
Jan 2024