Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$amp_default_role appears to override $amp_role_assignment #34

Closed
oskapt opened this issue Jun 15, 2021 · 2 comments
Closed

$amp_default_role appears to override $amp_role_assignment #34

oskapt opened this issue Jun 15, 2021 · 2 comments
Labels

Comments

@oskapt
Copy link

oskapt commented Jun 15, 2021

I've spent several hours with this, and it's possible I'm misunderstanding something.

I run YOURLS as a container under Kubernetes, with configuration handled via env vars or Secrets stored as JSON and then parsed with json_decode in config.php. That all works fine, but it's the reason I'm including JSON here.

I have this:

{
    "administrator": [
        "oskapt",
    ],
    "editor": [
        "weasel"
    ],
    "contributor": [
    ]
}

I also have $amp_default_role set to Contributor.

The "oskapt" user is correctly assigned as an administrator. The "weasel" user is assigned as an Editor. All is good.

If I switch it to this:

{
   "administrator": [
       "oskapt",
   ],
   "editor": [
   ],
   "contributor": [
       "weasel"
   ]
}

and set $amp_default_role to Editor then the "weasel" user can see entries made by other people as an Editor.

If I remove support for $amp_default_role entirely, then "weasel" is correctly assigned the Contributor or Editor role according to roles.json.

It looks a lot like $amp_default_role is not being limited to non-configured users but is instead acting as a floor, beneath which all users receive elevated privileges.

@joshp23 joshp23 added the bug label Dec 28, 2021
@joshp23
Copy link
Owner

joshp23 commented Dec 28, 2021

the issue would be in this logic

if( !$return ) {
if ( isset( $amp_default_role ) && in_array ($amp_default_role, array_keys( $amp_role_capabilities ) ) ) {
$default_caps = $amp_role_capabilities [ $amp_default_role ];
$return = in_array( $capability, $default_caps );
}
}

and reading it over, it is clearly in error. I would just comment this section out for now unless you are capable of fixing the error.

@joshp23
Copy link
Owner

joshp23 commented Dec 29, 2021

latest commit should fix this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants