Skip to content

Commit

Permalink
Avoids directly using the session token as a salt
Browse files Browse the repository at this point in the history
  • Loading branch information
Daverball committed Feb 11, 2025
1 parent 58b8030 commit aa9c2f0
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/onegov/pay/models/payment_providers/worldline_saferpay.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,13 +702,14 @@ def get_token(self, request: CoreRequest) -> str | None:
if not (signed_nonce := request.GET.get('saferpay_nonce')):
return None
app = request.app
nonce = app.unsign(signed_nonce, request.browser_session._token)
salt = app.sign(request.browser_session._token, 'saferpay_salt')
nonce = app.unsign(signed_nonce, salt)
if not nonce or not (signed_token := app.cache.get(nonce)):
return None

Check warning on line 708 in src/onegov/pay/models/payment_providers/worldline_saferpay.py

View check run for this annotation

Codecov / codecov/patch

src/onegov/pay/models/payment_providers/worldline_saferpay.py#L702-L708

Added lines #L702 - L708 were not covered by tests

# make sure the nonce can't be reused
app.cache.delete(nonce)
return app.unsign(signed_token, request.browser_session._token)
return app.unsign(signed_token, salt)

Check warning on line 712 in src/onegov/pay/models/payment_providers/worldline_saferpay.py

View check run for this annotation

Codecov / codecov/patch

src/onegov/pay/models/payment_providers/worldline_saferpay.py#L711-L712

Added lines #L711 - L712 were not covered by tests

def checkout_button(
self,
Expand All @@ -730,7 +731,7 @@ def checkout_button(
# append a saferpay nonce to the complete url
app = request.app
nonce = random_token()
salt = request.browser_session._token
salt = app.sign(request.browser_session._token, 'saferpay_salt')
signed_nonce = app.sign(nonce, salt)
complete_url = append_query_param(

Check warning on line 736 in src/onegov/pay/models/payment_providers/worldline_saferpay.py

View check run for this annotation

Codecov / codecov/patch

src/onegov/pay/models/payment_providers/worldline_saferpay.py#L732-L736

Added lines #L732 - L736 were not covered by tests
complete_url,
Expand Down

0 comments on commit aa9c2f0

Please sign in to comment.