Page 1 of 1

[CSGO] parent-inherited permissions doesn't show in Player.permissions property

Posted: Fri Jun 07, 2019 11:40 pm
by khaimovmr
Hey, guys.

I'm using a flatfiles to assign a permissions to players:
players.json - for the players and parents.json for the parents (aka group of some permissions)

When I'm getting the permissions property of this Player object (steamid `76561197983153964`) it's returning an empty dictionary.
Command, created with this decorator is reading the player permissions well though, allowing him to perform a comand:

Code: Select all

@TypedClientCommand('some_command', 'some_permissions.my')


Is it a bug/unfinised feature or there's just another way to get all the parent-inherited permissions of this player?


The content of my flatfiles
players.json:

Code: Select all

{
    "76561197983153964": {
        "parents": [
            "someparent"
        ]
    }
}

parents.json

Code: Select all

{
    "someparent": {
        "permissions": [
            "some_permissions.my"
        ]
    }
}

Re: [CSGO] parent-inherited permissions doesn't show in Player.permissions property

Posted: Sat Jun 08, 2019 5:08 am
by Ayuto
Yes, it's intended. If you want to see all permissions, you need to call player.permissions.flatten().

Re: [CSGO] parent-inherited permissions doesn't show in Player.permissions property

Posted: Sat Jun 08, 2019 5:28 pm
by khaimovmr
Great, thanks!

Re: [CSGO] parent-inherited permissions doesn't show in Player.permissions property

Posted: Sat Jun 08, 2019 5:35 pm
by khaimovmr
By the way - is there some kind of method that checks for the permissions by the mask (like "some_permissions.*")?
The _AuthManager.is_player_authorized doesn't check for the mask/regex - it's just checking for a strict equality (occurrence of the permission string in the list of the player permissions).

Code: Select all

    def is_player_authorized(self, index, permission):
        """Return True if the player has been granted the given permission.

        :rtype: bool
        """
        permissions = self.get_player_permissions(index)                                                               
        if permissions is None:
            return False

        return permission in permissions

Re: [CSGO] parent-inherited permissions doesn't show in Player.permissions property

Posted: Sun Jun 09, 2019 6:54 am
by Ayuto
We have overloaded the ___contains__ method:
https://github.com/Source-Python-Dev-Te ... er.py#L149

So, you can grant a player the permission something.*. If you then check if he has something.x or something.y it will return True for both checks.

Re: [CSGO] parent-inherited permissions doesn't show in Player.permissions property

Posted: Sun Jun 09, 2019 1:21 pm
by khaimovmr
Ayuto wrote:We have overloaded the ___contains__ method:
https://github.com/Source-Python-Dev-Te ... er.py#L149

So, you can grant a player the permission something.*. If you then check if he has something.x or something.y it will return True for both checks.

Oh, I got it. My bad. Should've known that there could be a __contains__ implementation.
Thanks, Ayuto!