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

Enable referencing the current user when evaluating permission constraints #9074

Closed
jeremystretch opened this issue Apr 7, 2022 · 3 comments
Labels
status: accepted This issue has been accepted for implementation type: feature Introduction of new functionality to the application
Milestone

Comments

@jeremystretch
Copy link
Member

NetBox version

v3.2.0

Feature type

New functionality

Proposed functionality

When assigning user and group permissions in NetBox, an administrator can attach certain constraints to effect object-level permissions. These constraints can evaluate object attributes but are currently limited to referencing static values.

This FR proposes a mechanism to allow constraints to reference the current user when evaluating rules. For example, the following constraint might be used to permit a user to delete only his or her own journal entries:

{
  "created_by": "$USER"
}

(I'm open to ideas about the preferred variable structure; $USER seemed like a reasonable placeholder.)

I still need to look more into the implementation details, but it seems reasonable to assume that the current user will always be available in the context of permissions evaluation.

Use case

This would allow for more dynamic constraint definitions, and avoid the need to define unique rules per user.

Database changes

No response

External dependencies

No response

@jeremystretch jeremystretch added type: feature Introduction of new functionality to the application status: under review Further discussion is needed to determine this issue's scope and/or implementation labels Apr 7, 2022
@sdktr
Copy link
Contributor

sdktr commented Apr 8, 2022

Do you want to limit this to the static (referencing the database record) $user context, or allow the expansion to other 'session variables'? Like: $request.headers.x-rbac-tenant?

@jeremystretch
Copy link
Member Author

The request isn't available as context when evaluating the permissions.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 8, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide.

@github-actions github-actions bot added the pending closure Requires immediate attention to avoid being closed for inactivity label Jun 8, 2022
@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation and removed status: under review Further discussion is needed to determine this issue's scope and/or implementation pending closure Requires immediate attention to avoid being closed for inactivity labels Jun 28, 2022
@jeremystretch jeremystretch added this to the v3.3 milestone Jun 28, 2022
jeremystretch added a commit that referenced this issue Jul 1, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: feature Introduction of new functionality to the application
Projects
None yet
Development

No branches or pull requests

2 participants