the37lab-authlib 0.1.1762438606__py3-none-any.whl → 0.1.1768813136__py3-none-any.whl

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.
the37lab_authlib/db.py CHANGED
@@ -60,6 +60,31 @@ class Database:
60
60
  expires_at TIMESTAMP,
61
61
  last_used_at TIMESTAMP
62
62
  );
63
+
64
+ CREATE TABLE IF NOT EXISTS groups (
65
+ id {self._get_id_type()} PRIMARY KEY,
66
+ name VARCHAR(255) UNIQUE NOT NULL,
67
+ description TEXT,
68
+ created_at TIMESTAMP NOT NULL
69
+ );
70
+
71
+ CREATE TABLE IF NOT EXISTS group_users (
72
+ group_id {self._get_id_type()} REFERENCES groups(id),
73
+ user_id {self._get_id_type()} REFERENCES users(id),
74
+ PRIMARY KEY (group_id, user_id)
75
+ );
76
+
77
+ CREATE TABLE IF NOT EXISTS group_groups (
78
+ group_id {self._get_id_type()} REFERENCES groups(id),
79
+ child_group_id {self._get_id_type()} REFERENCES groups(id),
80
+ PRIMARY KEY (group_id, child_group_id)
81
+ );
82
+
83
+ CREATE TABLE IF NOT EXISTS group_roles (
84
+ group_id {self._get_id_type()} REFERENCES groups(id),
85
+ role_id {self._get_id_type()} REFERENCES roles(id),
86
+ PRIMARY KEY (group_id, role_id)
87
+ );
63
88
  """)
64
89
 
65
90
  def _get_id_type(self):
@@ -88,4 +113,4 @@ class Database:
88
113
 
89
114
  def close(self):
90
115
  if self._pool:
91
- self._pool.closeall()
116
+ self._pool.closeall()
@@ -20,8 +20,12 @@ def require_auth(roles=None):
20
20
  decorated_func = auth_decorator(f)
21
21
 
22
22
  # Check roles if specified
23
- if roles and not any(role in user['roles'] for role in roles):
24
- raise AuthError('Insufficient permissions', 403)
23
+ if roles:
24
+ user_roles = set(user.get('roles', []))
25
+ expanded_user_roles = current_app.auth_manager._expand_roles(user_roles)
26
+ required_roles = set(roles)
27
+ if not expanded_user_roles.intersection(required_roles):
28
+ raise AuthError('Insufficient permissions', 403)
25
29
 
26
30
  # Now execute the function
27
31
  return decorated_func(*args, **kwargs)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: the37lab_authlib
3
- Version: 0.1.1762438606
3
+ Version: 0.1.1768813136
4
4
  Summary: Python SDK for the Authlib
5
5
  Author-email: the37lab <info@the37lab.com>
6
6
  Classifier: Programming Language :: Python :: 3
@@ -15,3 +15,5 @@ Requires-Dist: requests
15
15
  Requires-Dist: authlib
16
16
  Requires-Dist: bcrypt
17
17
  Requires-Dist: msal
18
+ Requires-Dist: slack-sdk
19
+ Requires-Dist: cachetools
@@ -0,0 +1,11 @@
1
+ the37lab_authlib/__init__.py,sha256=cFVTWL-0YIMqwOMVy1P8mOt_bQODJp-L9bfp2QQ8CTo,132
2
+ the37lab_authlib/_git_version.txt,sha256=CrWzycLKyBIHzUIn0w-HoMZUmfbnfTWW7M19s8MxG_8,103
3
+ the37lab_authlib/auth.py,sha256=q0bL86C8dL5eFTqyvhjPjHoANZgE_-L5mp5UWuHkB50,90655
4
+ the37lab_authlib/db.py,sha256=-supyzQGL7ej-Vhl3ViFMIlBUVkvZe_-Wg4RuIh9ijU,4359
5
+ the37lab_authlib/decorators.py,sha256=9tfAPP7eMCPXUEDpiLOs1Fya_bstX6cYM2cn35tCNio,1534
6
+ the37lab_authlib/exceptions.py,sha256=mdplK5sKNtagPAzSGq5NGsrQ4r-k03DKJBKx6myWwZc,317
7
+ the37lab_authlib/models.py,sha256=-PlvQlHGIsSdrH0H9Cdh_vTPlltGV8G1Z1mmGQvAg9Y,3422
8
+ the37lab_authlib-0.1.1768813136.dist-info/METADATA,sha256=d9eWR-MisU1GICD_5bJ9SjcXwljI5SzeZqWC27wfhpI,548
9
+ the37lab_authlib-0.1.1768813136.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
10
+ the37lab_authlib-0.1.1768813136.dist-info/top_level.txt,sha256=6Jmxw4UeLrhfJXgRKbXWY4OhxRSaMs0dKKhNCGWWSwc,17
11
+ the37lab_authlib-0.1.1768813136.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- the37lab_authlib/__init__.py,sha256=cFVTWL-0YIMqwOMVy1P8mOt_bQODJp-L9bfp2QQ8CTo,132
2
- the37lab_authlib/auth.py,sha256=X-CVMIvSk3q03ccAjB1A0KGlKSVc1PI33flOdq5T0lQ,78219
3
- the37lab_authlib/db.py,sha256=cmnmykKvq6V5e-D0HGiRN4DjFBOGB-SL1HpFjR5uyCw,3162
4
- the37lab_authlib/decorators.py,sha256=L-gJUUwDUT2JXTptQ6XEey1LkI5RprbqzEfArWI7F8Y,1305
5
- the37lab_authlib/exceptions.py,sha256=mdplK5sKNtagPAzSGq5NGsrQ4r-k03DKJBKx6myWwZc,317
6
- the37lab_authlib/models.py,sha256=-PlvQlHGIsSdrH0H9Cdh_vTPlltGV8G1Z1mmGQvAg9Y,3422
7
- the37lab_authlib-0.1.1762438606.dist-info/METADATA,sha256=zgzkQjfoi6cg5TVXEAJHU9Ui_-bh70rY1ieww7wodDQ,497
8
- the37lab_authlib-0.1.1762438606.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
- the37lab_authlib-0.1.1762438606.dist-info/top_level.txt,sha256=6Jmxw4UeLrhfJXgRKbXWY4OhxRSaMs0dKKhNCGWWSwc,17
10
- the37lab_authlib-0.1.1762438606.dist-info/RECORD,,