-
Notifications
You must be signed in to change notification settings - Fork 303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SEP24] Don't recommend adding jwt to interactive url #459
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is good, it reduces the auth component of the SEP to just what's relevant. I love how the concepts of using a token or JWT are still mentioned as a suggestion though.
I agree, the Anchor should deal with the security of the URL. from datetime import timezone, timedelta
from datetime import datetime as dt
deposit_id = new_deposit_uuid() # unique ID for the deposit
current_time = dt.now(timezone.utc).timestamp()
jwt_dict = {
"iat": current_time,
"exp": current_time + timedelta(minutes=10).total_seconds(),
"jti": deposit_id,
}
one_time_jwt = jwt.encode(jwt_dict, settings.SERVER_JWT_SECRET, algorithm='RS256').decode("utf-8")
return JsonResponse({
"type": "interactive_customer_info_needed",
"url" : "https://website.anchor.example.com/deposit-form?token=" + one_time_jwt,
"id": deposit_id
}) This allows confirming the token authenticity and retrieving all the deposit info based on the jwt_dict = jwt.decode(token, settings.SERVER_JWT_PUBKEY, algorithm='RS256')
current_time = dt.now(timezone.utc).timestamp()
if current_time < jwt_dict["iat"] or current_time > jwt_dict["exp"]:
raise Exception("invalid token")
# ... check if token was already used ...
deposit_id = jwt_dict["jti"]
# handle deposit |
I like the approach @yuriescl outlined. However I want to point out that since the new JWT has an expiration, we need to provide wallets the ability to retrieve a new JWT if their original one expires before it is able to start the interactive flow. I'll file a new PR for SEP-24 that adds a |
@JakeUrban That new JWT I suggested would be used in the interactive URL:
That URL will be accessed by the user. It can be used any number of times (never mind the "one-time token" idea). But in an usual scenario, it will be only used once by the popup window. Once the user finishes the KYC interactive flow, |
Fixes #457
Having wallets add JWTs to interactive URLs seems like a fishy practice. If the anchor expects a JWT in the interactive url it can put it there itself. We should leave the specific security of interactive webapps to the anchors discretion. Instead we add a small hint as to how to keep continuity from authenticated API calls to fresh interactive flow requests.