apexauthlib 0.1.6__tar.gz → 0.1.8__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: apexauthlib
3
- Version: 0.1.6
3
+ Version: 0.1.8
4
4
  Summary: Apex authorization library for services
5
5
  Author: Apex Dev
6
6
  Author-email: dev@apex.ge
@@ -83,6 +83,21 @@ def get_user_with_full_metadata(
83
83
  )
84
84
 
85
85
 
86
+ def get_user_and_service_users(
87
+ token: TokenDependable,
88
+ auth: AuthApiProviderDependable,
89
+ ) -> tuple[ServiceUserInfo[Any], list[ServiceUserInfo[Any]]]:
90
+ try:
91
+ api = auth.for_token(token)
92
+ return api.full_metadata_for(api.user().id), list(api.users_for_service())
93
+ except Exception as e:
94
+ raise HTTPException(
95
+ status_code=status.HTTP_401_UNAUTHORIZED,
96
+ detail=str(e),
97
+ headers={"WWW-Authenticate": "Bearer"},
98
+ )
99
+
100
+
86
101
  @dataclass
87
102
  class TokenResponse:
88
103
  access_token: str
@@ -96,17 +96,19 @@ class AuthApi(Generic[ItemT]):
96
96
  )
97
97
 
98
98
  def users_for_service(self) -> Iterable[ServiceUserInfo[ItemT]]:
99
- result = JsonDict(
100
- (
101
- self.http.with_header("Authorization", f"Bearer {self.token}")
102
- .get()
103
- .on_endpoint(f"/services/{self.service_name}/users")
104
- .on_failure(raises=RuntimeError)
105
- .json()
106
- )
107
- )["data"]["users"]
99
+ result = list(
100
+ JsonDict(
101
+ (
102
+ self.http.with_header("Authorization", f"Bearer {self.token}")
103
+ .get()
104
+ .on_endpoint(f"/services/{self.service_name}/users")
105
+ .on_failure(raises=RuntimeError)
106
+ .json()
107
+ )
108
+ )["data"]["users"]
109
+ )
108
110
 
109
- for raw_user in result["users"]:
111
+ for raw_user in result:
110
112
  user = dict(raw_user["user"])
111
113
  user["hashed_password"] = "unknown"
112
114
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "apexauthlib"
3
- version = "0.1.6"
3
+ version = "0.1.8"
4
4
  description = "Apex authorization library for services"
5
5
  authors = [{ name = "Apex Dev", email = "dev@apex.ge" }]
6
6
  readme = "README.md"
File without changes
File without changes