|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
| 3 | +from typing import Iterable |
| 4 | + |
3 | 5 | from descope._auth_base import AuthBase |
4 | 6 | from descope.common import REFRESH_SESSION_COOKIE_NAME, EndpointsV1 |
5 | 7 | from descope.exceptions import ERROR_TYPE_INVALID_ARGUMENT, AuthException |
6 | 8 |
|
7 | 9 |
|
8 | 10 | class Password(AuthBase): |
9 | | - def sign_up(self, login_id: str, password: str, user: dict | None = None) -> dict: |
| 11 | + def sign_up( |
| 12 | + self, |
| 13 | + login_id: str, |
| 14 | + password: str, |
| 15 | + user: dict | None = None, |
| 16 | + audience: str | None | Iterable[str] = None, |
| 17 | + ) -> dict: |
10 | 18 | """ |
11 | 19 | Sign up (create) a new user using a login ID and password. |
12 | 20 | (optional) Include additional user metadata that you wish to save. |
@@ -42,14 +50,15 @@ def sign_up(self, login_id: str, password: str, user: dict | None = None) -> dic |
42 | 50 |
|
43 | 51 | resp = response.json() |
44 | 52 | jwt_response = self._auth.generate_jwt_response( |
45 | | - resp, response.cookies.get(REFRESH_SESSION_COOKIE_NAME, None), None |
| 53 | + resp, response.cookies.get(REFRESH_SESSION_COOKIE_NAME, None), audience |
46 | 54 | ) |
47 | 55 | return jwt_response |
48 | 56 |
|
49 | 57 | def sign_in( |
50 | 58 | self, |
51 | 59 | login_id: str, |
52 | 60 | password: str, |
| 61 | + audience: str | None | Iterable[str] = None, |
53 | 62 | ) -> dict: |
54 | 63 | """ |
55 | 64 | Sign in by verifying the validity of a password entered by an end user. |
@@ -82,7 +91,7 @@ def sign_in( |
82 | 91 |
|
83 | 92 | resp = response.json() |
84 | 93 | jwt_response = self._auth.generate_jwt_response( |
85 | | - resp, response.cookies.get(REFRESH_SESSION_COOKIE_NAME, None), None |
| 94 | + resp, response.cookies.get(REFRESH_SESSION_COOKIE_NAME, None), audience |
86 | 95 | ) |
87 | 96 | return jwt_response |
88 | 97 |
|
@@ -166,7 +175,13 @@ def update(self, login_id: str, new_password: str, refresh_token: str) -> None: |
166 | 175 | uri, {"loginId": login_id, "newPassword": new_password}, None, refresh_token |
167 | 176 | ) |
168 | 177 |
|
169 | | - def replace(self, login_id: str, old_password: str, new_password: str) -> dict: |
| 178 | + def replace( |
| 179 | + self, |
| 180 | + login_id: str, |
| 181 | + old_password: str, |
| 182 | + new_password: str, |
| 183 | + audience: str | None | Iterable[str] = None, |
| 184 | + ) -> dict: |
170 | 185 | """ |
171 | 186 | Replace a valid active password with a new one. The old_password is used to |
172 | 187 | authenticate the user. If the user cannot be authenticated, this operation |
@@ -213,7 +228,7 @@ def replace(self, login_id: str, old_password: str, new_password: str) -> dict: |
213 | 228 |
|
214 | 229 | resp = response.json() |
215 | 230 | jwt_response = self._auth.generate_jwt_response( |
216 | | - resp, response.cookies.get(REFRESH_SESSION_COOKIE_NAME, None), None |
| 231 | + resp, response.cookies.get(REFRESH_SESSION_COOKIE_NAME, None), audience |
217 | 232 | ) |
218 | 233 | return jwt_response |
219 | 234 |
|
|
0 commit comments