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

All other Source.Python topics and issues.
User avatar
khaimovmr
Member
Posts: 52
Joined: Fri Aug 25, 2017 3:15 am
Contact:

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

Postby khaimovmr » Fri Jun 07, 2019 11:40 pm

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"
        ]
    }
}
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

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

Postby Ayuto » Sat Jun 08, 2019 5:08 am

Yes, it's intended. If you want to see all permissions, you need to call player.permissions.flatten().
User avatar
khaimovmr
Member
Posts: 52
Joined: Fri Aug 25, 2017 3:15 am
Contact:

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

Postby khaimovmr » Sat Jun 08, 2019 5:28 pm

Great, thanks!
User avatar
khaimovmr
Member
Posts: 52
Joined: Fri Aug 25, 2017 3:15 am
Contact:

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

Postby khaimovmr » Sat Jun 08, 2019 5:35 pm

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
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

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

Postby Ayuto » Sun Jun 09, 2019 6:54 am

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.
User avatar
khaimovmr
Member
Posts: 52
Joined: Fri Aug 25, 2017 3:15 am
Contact:

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

Postby khaimovmr » Sun Jun 09, 2019 1:21 pm

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!

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 19 guests