Skip to content

Conversation

kartik-579
Copy link
Member

Description

Auth is not present for fetching user list api. Added RBAC for the same api with only superadmins and manager to have access to the user list.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test case A
  • Test case B

Checklist:

  • The title of the PR states what changed and the related issues number (used for the release note).
  • Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have tested it for all user roles
  • I have added all the required unit/api test cases

@kartik-579 kartik-579 self-assigned this Aug 12, 2022
@kartik-579 kartik-579 requested a review from pghildiyal August 12, 2022 12:15
@kartik-579 kartik-579 linked an issue Aug 12, 2022 that may be closed by this pull request
token := r.Header.Get("token")
isAuthorised := false
//checking for superadmin access
if ok := handler.enforcer.Enforce(token, casbin.ResourceGlobal, casbin.ActionGet, "*"); ok {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use userAuthService.IsSuperAdmin to check superadmin

}
for _, team := range teams {
//checking if user has manager access to atleast one team, if yes then the user is authorised
if ok := handler.enforcer.Enforce(token, casbin.ResourceUser, casbin.ActionDelete, strings.ToLower(team.Name)); ok {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use handler.enforcer.Enforce(token, casbin.ResourceUser, casbin.ActionGet, strings.ToLower(filter.Team))

@pghildiyal pghildiyal merged commit 41722cb into main Aug 12, 2022
@pghildiyal pghildiyal deleted the user-list-auth-change branch August 12, 2022 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FEATURE: Block users list display for non Manager/Superadmin access
2 participants