rb-commons 0.1.16__tar.gz → 0.1.17__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. {rb_commons-0.1.16 → rb_commons-0.1.17}/PKG-INFO +1 -1
  2. rb_commons-0.1.17/rb_commons/permissions/__init__.py +2 -0
  3. rb_commons-0.1.17/rb_commons/permissions/http_exceptions.py +41 -0
  4. {rb_commons-0.1.16 → rb_commons-0.1.17}/rb_commons/permissions/role_permissions.py +3 -2
  5. {rb_commons-0.1.16 → rb_commons-0.1.17}/rb_commons.egg-info/PKG-INFO +1 -1
  6. {rb_commons-0.1.16 → rb_commons-0.1.17}/rb_commons.egg-info/SOURCES.txt +1 -0
  7. {rb_commons-0.1.16 → rb_commons-0.1.17}/setup.py +1 -1
  8. rb_commons-0.1.16/rb_commons/permissions/__init__.py +0 -1
  9. {rb_commons-0.1.16 → rb_commons-0.1.17}/README.md +0 -0
  10. {rb_commons-0.1.16 → rb_commons-0.1.17}/rb_commons/__init__.py +0 -0
  11. {rb_commons-0.1.16 → rb_commons-0.1.17}/rb_commons/configs/__init__.py +0 -0
  12. {rb_commons-0.1.16 → rb_commons-0.1.17}/rb_commons/configs/config.py +0 -0
  13. {rb_commons-0.1.16 → rb_commons-0.1.17}/rb_commons/configs/injections.py +0 -0
  14. {rb_commons-0.1.16 → rb_commons-0.1.17}/rb_commons/orm/__init__.py +0 -0
  15. {rb_commons-0.1.16 → rb_commons-0.1.17}/rb_commons/orm/exceptions.py +0 -0
  16. {rb_commons-0.1.16 → rb_commons-0.1.17}/rb_commons/orm/managers.py +0 -0
  17. {rb_commons-0.1.16 → rb_commons-0.1.17}/rb_commons/schemes/__init__.py +0 -0
  18. {rb_commons-0.1.16 → rb_commons-0.1.17}/rb_commons/schemes/jwt.py +0 -0
  19. {rb_commons-0.1.16 → rb_commons-0.1.17}/rb_commons.egg-info/dependency_links.txt +0 -0
  20. {rb_commons-0.1.16 → rb_commons-0.1.17}/rb_commons.egg-info/requires.txt +0 -0
  21. {rb_commons-0.1.16 → rb_commons-0.1.17}/rb_commons.egg-info/top_level.txt +0 -0
  22. {rb_commons-0.1.16 → rb_commons-0.1.17}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: rb-commons
3
- Version: 0.1.16
3
+ Version: 0.1.17
4
4
  Summary: Commons of project and simplified orm based on sqlalchemy.
5
5
  Home-page: https://github.com/RoboSell-organization/rb-commons
6
6
  Author: Abdulvoris
@@ -0,0 +1,2 @@
1
+ from role_permissions import *
2
+ from http_exceptions import *
@@ -0,0 +1,41 @@
1
+ from fastapi import HTTPException, status
2
+
3
+
4
+ class CustomHTTPException(HTTPException):
5
+ def __init__(self, message: str, status: int, code: str = None, additional_info: dict = None):
6
+ super().__init__(status_code=status, detail=message)
7
+
8
+ self.code = code
9
+ self.message = message
10
+ self.status = status
11
+ self.additional_info = additional_info
12
+
13
+
14
+ class NotAuthorizedException(CustomHTTPException):
15
+ def __init__(self, message: str = "You are not authorized", status: int = 401, code: str = None,
16
+ additional_info: dict = None):
17
+ super().__init__(message=message, status=status, code=code, additional_info=additional_info)
18
+
19
+
20
+ class ForbiddenException(CustomHTTPException):
21
+ def __init__(self, message: str = "Permission denied", status: int = 403, code: str = None,
22
+ additional_info: dict = None):
23
+ super().__init__(message=message, status=status, code=code, additional_info=additional_info)
24
+
25
+
26
+ class BadRequestException(CustomHTTPException):
27
+ def __init__(self, message: str = "Bad request", status: int = 400, code: str = None,
28
+ additional_info: dict = None):
29
+ super().__init__(message=message, status=status, code=code, additional_info=additional_info)
30
+
31
+
32
+ class NotFoundException(CustomHTTPException):
33
+ def __init__(self, message: str = "Not found", status: int = 404, code: str = None,
34
+ additional_info: dict = None):
35
+ super().__init__(message=message, status=status, code=code, additional_info=additional_info)
36
+
37
+
38
+ class InternalException(CustomHTTPException):
39
+ def __init__(self, message: str = "Internal exception", status: int = 500, code: str = None,
40
+ additional_info: dict = None):
41
+ super().__init__(message=message, status=status, code=code, additional_info=additional_info)
@@ -1,13 +1,14 @@
1
- from fastapi import Depends, HTTPException
1
+ from fastapi import Depends
2
2
 
3
3
  from rb_commons.configs.injections import get_claims
4
+ from rb_commons.permissions.http_exceptions import ForbiddenException
4
5
  from rb_commons.schemes.jwt import Claims, UserRole
5
6
 
6
7
 
7
8
  class BasePermission:
8
9
  def __call__(self, claims: Claims = Depends(get_claims)):
9
10
  if not self.has_permission(claims):
10
- raise HTTPException(status_code=403, detail="Permission Denied")
11
+ raise ForbiddenException(message=f"Access denied", status=401, code="0000")
11
12
 
12
13
  def has_permission(self, claims: Claims) -> bool:
13
14
  return False
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: rb-commons
3
- Version: 0.1.16
3
+ Version: 0.1.17
4
4
  Summary: Commons of project and simplified orm based on sqlalchemy.
5
5
  Home-page: https://github.com/RoboSell-organization/rb-commons
6
6
  Author: Abdulvoris
@@ -13,6 +13,7 @@ rb_commons/orm/__init__.py
13
13
  rb_commons/orm/exceptions.py
14
14
  rb_commons/orm/managers.py
15
15
  rb_commons/permissions/__init__.py
16
+ rb_commons/permissions/http_exceptions.py
16
17
  rb_commons/permissions/role_permissions.py
17
18
  rb_commons/schemes/__init__.py
18
19
  rb_commons/schemes/jwt.py
@@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
5
5
 
6
6
  setup(
7
7
  name="rb-commons",
8
- version="0.1.16",
8
+ version="0.1.17",
9
9
  author="Abdulvoris",
10
10
  author_email="erkinovabdulvoris101@gmail.com",
11
11
  description="Commons of project and simplified orm based on sqlalchemy.",
@@ -1 +0,0 @@
1
- from role_permissions import *
File without changes
File without changes