Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Add support for simple auth + account generation #7

Merged
merged 12 commits into from
Feb 10, 2020
Merged

Conversation

nkramer44
Copy link
Contributor

This PR aims to provide developers with an easier way to interact with Xpring's ILP infrastructure.

Developers can now create an account through Hermes, which will generate both an account id as well as a AuthType.SIMPLE auth token, and pass the unencrypted auth token back after the account has been created on the connector. Developers can simply send a POST request to Hermes /accounts and will no longer have to create an account through Hermes using a JWT.

Developers also have the ability to specify their own simple auth token, which allows for a greater breadth of auth providers at the application level.

All account-related endpoints will also now return a payment pointer, based on the SPSP url of the receiver that is currently wired up.

These changes shouldn't break any existing ILP wallet functionality, as Hermes still supports JWT passthrough, and all response object modifications were additive.

@nkramer44 nkramer44 requested a review from sappenin February 9, 2020 23:20
@theotherian theotherian self-assigned this Feb 10, 2020
Copy link
Contributor

@sappenin sappenin left a comment

Choose a reason for hiding this comment

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

LGTM -- some minor questions and suggestions, but nothing that should block a merge. Feel free to create issues for any of my comments, or fix them and I can re-approve.

/**
* Jackson deserializer for {@link PaymentPointer}.
*/
public class PaymentPointerDeserializer extends StdDeserializer<PaymentPointer> {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is fine to be located here for now, but we should put this into Quilt since payment pointer lives there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See #9

Optional<String> credentials = maybeAuthToken.toString().isEmpty() ?
Optional.empty() : Optional.of(maybeAuthToken.toString());

AccountSettings accountSettings = newAccountService.createAccount(credentials, createAccountRequest);
Copy link
Contributor

@theotherian theotherian Feb 10, 2020

Choose a reason for hiding this comment

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

This and the lines above it could be rewritten a bit more concisely as:

newAccountService.createAccount(authToken.map(t -> t.substring(t.indexOf(" ") + 1), createAccountRequest)

The authToken.map should return what you want or an empty optional.


// Create account on the connector
AccountSettings returnedAccountSettings = newAccountService.createAccount(request);
AccountSettings returnedAccountSettings = newAccountService.createAccount(credentials, request);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here as with the last optional. It may be helpful to encapsulate this behavior in a class somewhere.

Copy link
Contributor

@theotherian theotherian left a comment

Choose a reason for hiding this comment

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

Looks snazzy 👍

Just the opportunity to refactor the auth token logic and make it a little more concise, but looks great overall. Really nice job!

@nkramer44 nkramer44 merged commit 521a8b7 into master Feb 10, 2020
@nkramer44 nkramer44 deleted the simple-auth branch February 10, 2020 18:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants