-
Notifications
You must be signed in to change notification settings - Fork 316
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
Memo-based Pooled Account Support #1036
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 really like that this change was across multiple SEPs in a single PR. The broad nature of this change is easier realized applying it holistically. I reviewed SEP-6, 10, and 12. I did not review SEP-24 thoroughly given its similarity but I'll review it on my final pass. I left suggestions (💡) that I don't feel strongly about, questions (❓) that may result in changes but also may not, and concerns (❗) that I'd like to discuss further.
ecosystem/sep-0012.md
Outdated
Note that this scenario is not applicable to [SEP-31](sep-0031.md)'s use of this protocol. This is because the Stellar account used to authenticate in this case identifies the [Sending Anchor](sep-0031.md#abstract) itself, not a particular customer, and therefore the scope of the authenticated session should include all customers registered and transactions initiated by the Sending Anchor. | ||
|
||
To facilitate this, SEP-31 Sending Anchors should use the `memo` and `memo_type` request parameters described for the endpoints below to represent unique customers instead of using SEP-10 memos. | ||
|
||
SEP-12 implementations should expect SEP-10 memos, if present in the decoded JWT, to match the memo request parameters and should return an error response if they do not. |
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 don't think we should say that rules apply to some SEPs and not others. SEP-12 needs to stand on its own with a single set of rules that can be applied uniformly without conditions on the SEP it is being used with, otherwise I think it is confusing to implement. I think we can tweak the language below to get the same result without presenting it as SEP-31 gets an exception to a rule.
Note that this scenario is not applicable to [SEP-31](sep-0031.md)'s use of this protocol. This is because the Stellar account used to authenticate in this case identifies the [Sending Anchor](sep-0031.md#abstract) itself, not a particular customer, and therefore the scope of the authenticated session should include all customers registered and transactions initiated by the Sending Anchor. | |
To facilitate this, SEP-31 Sending Anchors should use the `memo` and `memo_type` request parameters described for the endpoints below to represent unique customers instead of using SEP-10 memos. | |
SEP-12 implementations should expect SEP-10 memos, if present in the decoded JWT, to match the memo request parameters and should return an error response if they do not. | |
SEP-12 implementations should expect memo claims in the SEP-10 JWT to match the memo request parameters and should return an error response if they do not. If the JWT does not contain memo claims then the memo request parameters may contain any value. This behavior allows shared account owners, such as [SEP-31 sending anchors](sep-0031.md#abstract), to submit user information about their users using the memos assigned to their users. |
Thoughts?
Note that this section appears to answer my earlier question of what it means if no memo is provided: authentication with a parent account should provide access to all data of sub-accounts identified by memos. It may be worth calling this out explicitly in SEP-10, or at least specifying in SEP-10 that it is undefined behavior and clients cannot rely on the outcome in SEPs that use SEP-10.
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.
authentication with a parent account should provide access to all data of sub-accounts identified by memos.
I have concerns about this approach, both from a security and application-logic perspective.
If a client application authenticates with an account that was previously used with memos, the session should be treated as disjoint from other sessions using memos with the same account.
This ensures the service never exposes transaction or KYC information that was not explicitly requested by the client using the composite primary key of (account, memo, memo_type).
This simplified application logic as well. Services can always use the three claims to retrieve user and transaction records instead of sometimes using memos and sometimes not.
# .get() either returns the value or None
def create_user(jwt):
User.objects.create(account=jwt.get("account"), memo=jwt.get("memo"), memo_type=jwt.get("memo_type"))
def get_user(jwt):
User.objects.get(account=jwt.get("account"), memo=jwt.get("memo"), memo_type=jwt.get("memo_type"))
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 agree with the text in the suggested change though, so I'll commit it but leave this thread unresolved.
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 have concerns about this approach, both from a security and application-logic perspective.
If a client application authenticates with an account that was previously used with memos, the session should be treated as disjoint from other sessions using memos with the same account.
This is my preference and I share the same concern, but it sounds like the way it works with SEP-31 is that it isn't disjoint. I think we should endeavor to have our SEPs use SEP-10's scoping in the same way. How the scoping occurs is really out of scope of SEP-10 itself, but some consistency would have value.
Maybe we say in SEP-10 that it is not recommended, but then SEP-31/12 does it anyway?
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'm not sure I understand how SEP-31's use of SEP-10 does not make sessions using the same account disjoint. In SEP-31's use of SEP-10, Sending Anchors will never request memos to be in their challenge transactions and downstream JWTs, so the Sending Anchor's session will always be disjoint from transactions and KYC data created in sessions authenticated by JWTs including memos. Let me know if you think I'm missing something.
Co-authored-by: Leigh McCulloch <[email protected]>
Co-authored-by: Leigh McCulloch <[email protected]>
Co-authored-by: Leigh McCulloch <[email protected]>
Co-authored-by: Leigh McCulloch <[email protected]>
Co-authored-by: Leigh McCulloch <[email protected]>
Co-authored-by: Leigh McCulloch <[email protected]>
If I understood correctly, these are the issues being discussed regarding the addition of
Sometimes I feel that SEPs need some kind of versioning and dependency setup. The SEPs have been through changes and they depend on each other, it can be difficult to always be backward compatible and want changes at the same time.
Polaris and other SEP-dependant software could then be compatible to a set of versions, instead of trying to have all versions compatible with all SEP versions, which restricts space for non-breaking real-time improvement. About the numbered points above, this is what I suggest:
SEPs have API-like behavior. I've yet to see a complex API system without versioning work well. |
Co-authored-by: Leigh McCulloch <[email protected]>
Co-authored-by: Leigh McCulloch <[email protected]>
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 looks good. I've left a few suggestions (💡), but they are only suggestions.
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.
This looks good to me. There are a few details that I'd like to get ironed out before fully approving (see my comments below), but I think overall this is the right direction and set of changes.
Co-authored-by: Alex Cordeiro <[email protected]>
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 reviewed the changes since my last review when I approved, and I re-reviewed all the changes to SEP-10.
I've left one suggestion (💡) and one word change (🔠) but both are minor details.
This is great work and I think we've landed in the best place we can given the legacy constraints.
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.
Looks great from my perspective, thank you @JakeUrban!
Co-authored-by: Leigh McCulloch <[email protected]>
b1f892f
Co-authored-by: Leigh McCulloch <[email protected]>
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.
🎉
resolves #727
Changes
SEP-10
memo
request parameters to theGET WEB_AUTH_ENDPOINT
requestaccount
parameter to also accept muxed accounts (M...
)GET WEB_AUTH_ENDPOINT
sub
value format to include the memo or be the muxed account used as theaccount
parameterSEP-6
GET /deposit
'smemo
andmemo_type
request parameters strictly as the memo on the transaction submitted by the anchor to deliver on-chain fundsmemo
andmemo_type
request parameters of theGET /withdraw
endpoint should only be used when the anchor does not support SEP-10 authenticationGET /transaction(s)
endpoints to only be those created by requests containing the samesub
value as the request for transactionsSEP-24
The changes described here are identical to those made for SEP-6, with one exception:
memo
andmemo_type
request parameters of theGET /withdraw
endpoint, since SEP-10 is requiredSEP-12
The changes made for this protocol are more nuanced because it is used by both SEP-6 and SEP-31. In SEP-6, authenticated sessions are scoped to a single user's (or customer's) transactions. In SEP-31, authenticated sessions are scoped to a Sending Anchor's transactions and customers.
This means that a client interacting with a SEP-12 implementation may be a Wallet acting on behalf of a single user, in which case the memo may be present in the SEP-10 JWT's
sub
value and therefore thememo
andmemo_type
request parameters are no longer necessary, but for the sake of avoiding more changes to existing implementations should still be specified.It also means that a client interactive with a SEP-12 implementation may be a SEP-31 Sending Anchor initiating the transfer of funds between two users, in which case the SEP-10 JWT shouldn't have memo or muxed account in the
sub
value. Instead, the SEP-31 anchor should use thememo
request parameter to identify users.SEP-12 implementors therefore must support both types of identifying users unless the protocol is only used for SEP-31 transactions.
account
request parameter in all applicable endpointsmemo_type
request parameter -- memos should always be of typeid
memo
request parameter must match the memo portion of the JWT'ssub
value if present.memo
request parameter should not be accepted if the JWT'ssub
value is a muxed account.