Skip to content

Commit

Permalink
Refactor user_profile to use bluprints
Browse files Browse the repository at this point in the history
fixes #1981, fixes #2059

This migrates the code for the user profile resource to use blueprints.

It also fixes an issue where the PUT operation allowed malicious
injection attacks on our database.
  • Loading branch information
EC2 Default User committed Dec 23, 2024
1 parent 89f516b commit 4ce2135
Show file tree
Hide file tree
Showing 7 changed files with 223 additions and 249 deletions.
6 changes: 6 additions & 0 deletions changelog_entry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- bump: patch
changes:
changed:
- updated the user_profile endpoints to use blueprints instead of endpoints.
fixed:
- updated the user profile endpoint to resist injection attacks on update.
10 changes: 2 additions & 8 deletions policyengine_api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
)
from policyengine_api.routes.tracer_analysis_routes import tracer_analysis_bp
from policyengine_api.routes.metadata_routes import metadata_bp
from policyengine_api.routes.user_profile_routes import user_profile_bp

from .endpoints import (
get_home,
Expand All @@ -32,9 +33,6 @@
set_user_policy,
get_user_policy,
update_user_policy,
set_user_profile,
get_user_profile,
update_user_profile,
get_simulations,
)

Expand Down Expand Up @@ -100,11 +98,7 @@
get_user_policy
)

app.route("/<country_id>/user-profile", methods=["POST"])(set_user_profile)

app.route("/<country_id>/user-profile", methods=["GET"])(get_user_profile)

app.route("/<country_id>/user-profile", methods=["PUT"])(update_user_profile)
app.register_blueprint(user_profile_bp)

app.route("/simulations", methods=["GET"])(get_simulations)

Expand Down
5 changes: 0 additions & 5 deletions policyengine_api/endpoints/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,4 @@
update_user_policy,
)

from .user_profile import (
set_user_profile,
get_user_profile,
update_user_profile,
)
from .simulation import get_simulations
231 changes: 0 additions & 231 deletions policyengine_api/endpoints/user_profile.py

This file was deleted.

Loading

0 comments on commit 4ce2135

Please sign in to comment.