Skip to content
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

[Anchor-418] Support auth with SEP10 in SEP38 #1130

Merged
merged 6 commits into from
Oct 3, 2023

Conversation

JiahuiWho
Copy link
Contributor

@JiahuiWho JiahuiWho commented Sep 27, 2023

Description

Add sep38.requires_sep10 configuration with default value to FALSE

Context

Currently, according to the SEP-38 spec, some of the SEP38 endpoints have SEP-10 as optional. This task seeks ensure we support this optionality by add configurability to these endpoints' SEP-10 requirements.

Testing

Tests were added to verify url pattern was added to filter if auth is required

@JiahuiWho JiahuiWho marked this pull request as ready for review September 29, 2023 17:45
fun testAll() {
println("Performing SEP38 tests...")
`test sep38 info, price and prices endpoints`()
`test selling over asset limit throws an exception`()
`test endpoints does not required valid token when auth is disabled`()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also add tests for when authentication is enabled?

@@ -451,6 +451,8 @@ sep38:
# Whether to enable SEP-38
#
enabled: false
# Whether to require SEP-10 authentication for SEP-38 requests.
requires_sep10: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SEP-38 has other endpoints that require authentication such as POST /quote. Should we change the name of this flag or schema (nesting it under sep38.endpoints.info.authentication_required, for example) so that this is clear?

Copy link
Collaborator

@lijamie98 lijamie98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please feel free to merge after the comments are resolved.

@@ -451,6 +451,8 @@ sep38:
# Whether to enable SEP-38
#
enabled: false
# Whether to require SEP-10 authentication for SEP-38 requests.
requires_sep10: false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel requires_sep10 is vague because some of the endpoints already requires sep10.

How about:

Suggested change
requires_sep10: false
enforce_sep10: false

sep38.endpoints.info.authentication_required seems a bit over engineering.


init {
sep38Client = Sep38Client(toml.getString("ANCHOR_QUOTE_SERVER"), jwt)
sep38ClientWithoutJwt = Sep38Client(toml.getString("ANCHOR_QUOTE_SERVER"), "Invalid Token")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only used in test endpoints does not required valid token when auth is disabled(). It's better to use local var.

@JiahuiWho JiahuiWho merged commit 84811bd into stellar:develop Oct 3, 2023
5 checks passed
@JiahuiWho JiahuiWho deleted the anchor-418 branch October 9, 2023 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants