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

Non-admin users don't have permission to ContentType API endpoint #3407

Closed
joewesch opened this issue Mar 9, 2023 · 0 comments · Fixed by #3409
Closed

Non-admin users don't have permission to ContentType API endpoint #3407

joewesch opened this issue Mar 9, 2023 · 0 comments · Fixed by #3409
Assignees
Labels
type: bug Something isn't working as expected

Comments

@joewesch
Copy link
Contributor

joewesch commented Mar 9, 2023

Environment

  • Nautobot version (Docker tag too if applicable): 1.5.7
  • Python version: 3.7.16
  • Database platform, version: Docker
  • Middleware(s): N/A

Steps to Reproduce

  1. Create a model that uses a ManyToManyField to ContentType
class MyModel(PrimaryModel):
    content_types = models.ManyToManyField(to=ContentType)
  1. Create a form for that Model
class MyModelForm(BootstrapMixin, forms.ModelForm):
    content_types = DynamicModelMultipleChoiceField(
        queryset=ContentType.objects.all(),
        label="Object Types",
        widget=APISelectMultiple(
            api_url="/api/extras/content-types/",
        ),
    )
  1. Create a non-admin user with applicable/all permissions
  2. Try and create the object with the non-admin user

Expected Behavior

The non-admin user should be able to select a content type

Observed Behavior

After clicking the dropdown for "Object Types" you get the following error:

The results could not be loaded.

In the Nautobot logs, you see the following:

Forbidden: /api/extras/content-types/
"GET /api/extras/content-types/?q=&limit=50&offset=0&brief=true HTTP/1.1" 403 63

Analysis

I was able to reproduce the issue with the demo user on demo.nautobot.com.

  1. Go to the Change Logs at https://demo.nautobot.com/extras/changelog/
  2. Click on the "Filter" button
  3. Try and select an "Object Type" filter

You can also see this by going to https://demo.nautobot.com/api/extras/content-types/ and getting this error:

{
    "detail": "You do not have permission to perform this action."
}
@glennmatthews glennmatthews added the type: bug Something isn't working as expected label Mar 9, 2023
@HanlinMiao HanlinMiao self-assigned this Mar 9, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug Something isn't working as expected
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants