Skip to content
This repository has been archived by the owner on Apr 11, 2023. It is now read-only.

feat: #20 bootstrap data retrieve endpoint #46

Merged
merged 1 commit into from
Jul 30, 2020

Conversation

llorllale
Copy link
Contributor

@llorllale llorllale commented Jul 29, 2020

closes #20

This PR depends on PR #43 where the user's profile is stored to the transient store and the user is redirected to the UI with a handle in the up query parameter. This PR reuses that query parameter to fetch the same user bootstrap data.

Two new startup parameters were added: SDS URL and Key Server URL.

Signed-off-by: George Aristy [email protected]

@cla-bot cla-bot bot added the cla-signed label Jul 29, 2020
@codecov
Copy link

codecov bot commented Jul 29, 2020

Codecov Report

Merging #46 into master will increase coverage by 0.13%.
The diff coverage is 90.38%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #46      +/-   ##
==========================================
+ Coverage   87.56%   87.70%   +0.13%     
==========================================
  Files           6        6              
  Lines         386      431      +45     
==========================================
+ Hits          338      378      +40     
- Misses         31       34       +3     
- Partials       17       19       +2     
Impacted Files Coverage Δ
pkg/restapi/operation/operations.go 84.15% <81.48%> (-0.47%) ⬇️
cmd/auth-rest/startcmd/start.go 90.29% <100.00%> (+0.92%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 39dba44...7030bb1. Read the comment docs.


if err != nil {
handleAuthError(w, http.StatusInternalServerError,
fmt.Sprintf("failed to query transient store for handle : %s", err))
Copy link
Collaborator

@DRK3 DRK3 Jul 30, 2020

Choose a reason for hiding this comment

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

Found one! Extra space before colon

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@DRK3 fixed

// but edge-core store API doesn't have a Delete() operation: https://github.com/trustbloc/edge-core/issues/45
_, err = w.Write(response)
if err != nil {
logger.Errorf("failed to write bootstrap data to output : %s", err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Another one

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@DRK3 fixed

@@ -340,6 +346,48 @@ func (c *Operation) onboardUser(id string) (*user.Profile, error) {
return userProfile, nil
}

func (c *Operation) handleBootstrapDataRequest(w http.ResponseWriter, r *http.Request) {
handle := r.URL.Query().Get("up")
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is "up"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@DRK3 stands for "user profile", and is being added in #43

@@ -17,6 +17,8 @@ import (
"strings"
"testing"

"github.com/trustbloc/hub-auth/pkg/bootstrap/user"

Copy link
Collaborator

Choose a reason for hiding this comment

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

extra line break

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@DRK3 fixed

KeyStoreIDs: profile.KeyStoreIDs,
})
if err != nil {
handleAuthError(w, http.StatusInternalServerError, fmt.Sprintf("failed to marshal bootstrap data : %s", err))
Copy link
Collaborator

Choose a reason for hiding this comment

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

another one

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@DRK3 fixed

Comment on lines 20 to 22
"github.com/trustbloc/hub-auth/pkg/bootstrap/user"

"github.com/trustbloc/hub-auth/pkg/internal/common/mockoidc"
Copy link
Collaborator

Choose a reason for hiding this comment

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

These hub-auth imports should be grouped together with the other one

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@DRK3 fixed

}

// TODO We should delete the handle from the transient store after writing the response,
// but edge-core store API doesn't have a Delete() operation: https://github.com/trustbloc/edge-core/issues/45
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let me know if not having the Delete() operation is blocking you and I can work on it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@DRK3 it's not blocking for now but should be there if we are going to say this thing is "production-ready"

@llorllale llorllale merged commit 439e45a into trustbloc:master Jul 30, 2020
@llorllale llorllale deleted the 20 branch July 30, 2020 14:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bootstrap: Add "retrieve profile" endpoint
4 participants