ansible / awx

AWX provides a web-based user interface, REST API, and task engine built on top of Ansible. It is one of the upstream projects for Red Hat Ansible Automation Platform.
Other
13.5k stars 3.34k forks source link

AWX oauth2 provider /user/:pk/personal_tokens/ always returns tokens for the current user regardless of the specified PK #15159

Open relrod opened 2 weeks ago

relrod commented 2 weeks ago

Please confirm the following

Bug Summary

Found this while reading the code working on the DAB oauth implementation.

AWX version

devel

Select the relevant components

Installation method

N/A

Modifications

no

Ansible version

No response

Operating system

No response

Web browser

No response

Steps to reproduce

Expected results

The user with the given PK's tokens (if I have permission to see them)

Actual results

My own tokens

Additional information

No response

relrod commented 2 weeks ago
class UserPersonalTokenList(SubListCreateAPIView):
    # [...]

    def get_queryset(self):
        return get_access_token_model().objects.filter(application__isnull=True, user=self.request.user)

We filter on the request user always, even though the route allows for a PK.

TheRealHaoLiu commented 3 days ago

assigned to @relrod

relrod commented 3 days ago

assigned to @TheRealHaoLiu :rofl: