Skip to content

Commit 685e725

Browse files
committed
fix: Updates after manual testing
1 parent 0ee1a53 commit 685e725

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88

99
## [unreleased]
1010

11+
### Added
12+
13+
- The Dashboard recipe now accepts a new `admins` property which can be used to give Dashboard Users write privileges for the user dashboard.
14+
15+
### Changes
1116

17+
- Dashboard APIs now return a status code `403` for all non-GET requests if the currently logged in Dashboard User is not listed in the `admins` array
1218

1319
## [0.15.3] - 2023-09-24
1420

supertokens_python/recipe/dashboard/api/validate_key.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ async def handle_validate_key_api(
3535
user_context: Dict[str, Any],
3636
):
3737

38-
is_valid_key = validate_api_key(
38+
is_valid_key = await validate_api_key(
3939
api_options.request, api_options.config, user_context
4040
)
4141

supertokens_python/recipe/dashboard/recipe_implementation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ async def should_allow_access(
4141
user_context: Dict[str, Any],
4242
) -> bool:
4343
# For cases where we're not using the API key, the JWT is being used; we allow their access by default
44-
if config.api_key is not None:
44+
if config.api_key is None:
4545
auth_header_value = request.get_header("authorization")
4646
if not auth_header_value:
4747
return False
@@ -60,7 +60,7 @@ async def should_allow_access(
6060
# user is allowed to perform this operation
6161
if normalise_http_method(request.method()) != "get":
6262
# We dont want to block the analytics API
63-
if request.get_original_url().startswith(DASHBOARD_ANALYTICS_API):
63+
if request.get_original_url().endswith(DASHBOARD_ANALYTICS_API):
6464
return True
6565

6666
# We do not want to block the sign out request
@@ -77,7 +77,7 @@ async def should_allow_access(
7777

7878
if email_in_headers is None:
7979
log_debug_message(
80-
"User Dashboard: Returniing OPERATION_NOT_ALLOWED because no email was provided in headers"
80+
"User Dashboard: Returning UNAUTHORISED_ERROR because no email was provided in headers"
8181
)
8282
return False
8383

@@ -89,4 +89,4 @@ async def should_allow_access(
8989

9090
return True
9191

92-
return validate_api_key(request, config, user_context)
92+
return await validate_api_key(request, config, user_context)

supertokens_python/recipe/dashboard/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ def is_recipe_initialised(recipeId: str) -> bool:
424424
return isRecipeInitialised
425425

426426

427-
def validate_api_key(
427+
async def validate_api_key(
428428
req: BaseRequest, config: DashboardConfig, _user_context: Dict[str, Any]
429429
) -> bool:
430430
api_key_header_value = req.get_header("authorization")

0 commit comments

Comments
 (0)