LuckPerms

LuckPerms

41.4k Downloads

[Sponge] Issue with permission checks on User object upon repeated login

dualspiral opened this issue ยท 5 comments

commented
Minecraft Version: 1.10.2
Sponge Version: SpongeForge 1.10.2-2171-5.1.0-BETA-2008
Sponge API Version: SpongeAPI 5.1.0-SNAPSHOT-323db46
LuckPerms v2.16.60.

There is a strange issue occuring where a permission check on a Player object and the same check on their corresponding User object can return different results. This happens on second and subsequent player logins.

To reproduce what happens, I gave myself the permission test.test and wrote a plugin that does a permission check on the Player object, then the User object. I then restarted my server, logged in, ran /test, noted the console output, logged out, logged in again and ran /test. In both cases, the check on the player object (Player#hasPermission(String)) returned correctly, but the check on the user object (User#hasPermission(String)) only returns correctly the first time. I would expect that the call to User#hasPermission(S) returns the same result as Player#hasPermission(S) every time.

Performing the check later will return the correct result, so I'd guess there is some weird caching thing going on, but you know the code better than me!

The code and results are in the following gist: https://gist.github.com/dualspiral/08bf3244fc04e7402f2d2feb1968d374

commented

Would you mind testing with Sponge PEX? Sounds more like an issue with the way Sponge caches it here: https://github.com/SpongePowered/SpongeCommon/blob/bleeding/src/main/java/org/spongepowered/common/mixin/core/command/MixinSubject.java

commented

Just looking into it, you're probably right that it's a Sponge thing, but then, I'm not sure why PEX works and LP doesn't. I'll probably test it with PermissionManager at some point tomorrow (I need to test something with that anyway), I'll keep you in the loop as to what I find, if anything.

I've worked around the issue in Nucleus for now - just forced the check on Player if it exists, and I plan to get that update out tomorrow, so don't feel you need to rush this (if this is indeed a problem you can fix) for my sake!

commented

Just to add to that, I tried PermissionManager too using my test, and it works fine.

https://gist.github.com/dualspiral/1bc7ed812f0a714a27d559cf31f0c408

commented

@lucko @dualspiral I just experienced this myself testing GP with latest LP as I'm trying to cache some perm checks for performance sake. Upon logging in, the user subject always returns false. However, the odd part is, if I add a hasPermission check during player login then the user subject seems to always work. This tells me that the user subject's data is not properly initialized unless an actual player logs in and runs a permission check.

Here is a log during event ServerAboutToStart when a user permission is requested

[04:18:16] [Server thread/INFO] [STDOUT/]: [me.ryanhamshire.griefprevention.PlayerData:refreshPlayerOptions:230]: playerSubject = e035f345-cd86-32c4-b341-cb1c91fe2c9d, id = e035f345-cd86-32c4-b341-cb1c91fe2c9d, canManageAdminClaims = false, basic = false

Both checks should be returning true. If I login with a player, it will still be false until I add a permission check during login then it magically fixes it.

I performed the EXACT same test with PEX and got the following on startup

[04:29:11] [Server thread/INFO] [STDOUT]: [me.ryanhamshire.griefprevention.PlayerData:refreshPlayerOptions:230]: playerSubject = e035f345-cd86-32c4-b341-cb1c91fe2c9d, id = e035f345-cd86-32c4-b341-cb1c91fe2c9d, canManageAdminClaims = true, basic = true

So I don't understand how this is a sponge issue when it works fine in PEX?

@zml2008 can you chime in?