Skip to content

Commit 6bd1215

Browse files
committed
refactor: remove redundant HasScope permission class
Signed-off-by: Michal Fiedorowicz <[email protected]>
1 parent 612c991 commit 6bd1215

File tree

1 file changed

+0
-21
lines changed

1 file changed

+0
-21
lines changed

netbox_diode_plugin/api/permissions.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,6 @@ def has_permission(self, request, view):
1616
return bool(getattr(request.user, "is_authenticated", False))
1717

1818

19-
class HasScope(BasePermission):
20-
"""
21-
Require one or more OAuth2 token scopes to access a view.
22-
23-
Example usage:
24-
permission_classes = [IsAuthenticated, require_scopes(SCOPE_NETBOX_WRITE)]
25-
"""
26-
27-
def __init__(self, *required_scopes):
28-
"""Initialize the permission."""
29-
self.required_scopes = required_scopes
30-
31-
def has_permission(self, request, view):
32-
"""Check if the request has the required scopes."""
33-
token_scopes = getattr(request, "token_scopes", [])
34-
if not token_scopes:
35-
return False
36-
37-
return all(scope in token_scopes for scope in self.required_scopes)
38-
39-
4019
def require_scopes(*required_scopes):
4120
"""Require one or more OAuth2 token scopes to access a view."""
4221

0 commit comments

Comments
 (0)