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

add endpoint for retrieving a user's info by ID #268

Merged
merged 1 commit into from
Mar 7, 2024

Conversation

mikemrm
Copy link
Contributor

@mikemrm mikemrm commented Mar 7, 2024

This adds an http endpoint /api/v1/users/{userID} for retrieving a users information by the user's ID.

Permission is checked by checking the user issuer's owner ID for iam_user_get action.

internal/api/httpsrv/handle_user.go Dismissed Show dismissed Hide dismissed
openapi-v1.yaml Dismissed Show dismissed Hide dismissed
openapi-v1.yaml Dismissed Show dismissed Hide dismissed
@mikemrm mikemrm marked this pull request as ready for review March 7, 2024 16:34
@mikemrm mikemrm requested review from a team as code owners March 7, 2024 16:34
@@ -162,6 +162,40 @@ func (s userInfoService) LookupUserInfoByID(ctx context.Context, id gidx.Prefixe
return ui, err
}

// LookupUserOwnerID finds the Owner ID of the Issuer for the given User ID.
func (s userInfoService) LookupUserOwnerID(ctx context.Context, id gidx.PrefixedID) (gidx.PrefixedID, error) {
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 get a test of this?

Copy link
Contributor

@jnschaeffer jnschaeffer left a comment

Choose a reason for hiding this comment

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

Missed a couple of small things here (which we probably want tests for).

Comment on lines 18 to 27
if err != nil {
return nil, echo.NewHTTPError(http.StatusNotFound, err)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This could fail for reasons that aren't a not found error, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, I meant to replace these with switch statements. Thanks.

Comment on lines 26 to 43
info, err := h.engine.LookupUserInfoByID(ctx, req.UserID)
if err != nil {
return nil, echo.NewHTTPError(http.StatusBadRequest, err)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Same re: errors here. This actually looks like a server error.

@mikemrm mikemrm force-pushed the add-get-user-endpoint branch from 318deb3 to 4a2020d Compare March 7, 2024 18:01
@mikemrm mikemrm force-pushed the add-get-user-endpoint branch 2 times, most recently from 4d66d35 to 9420dc1 Compare March 7, 2024 18:24
@mikemrm mikemrm requested a review from jnschaeffer March 7, 2024 18:28
This adds an http endpoint for retrieving a users information by the user's ID.

Permission is checked by checking the user issuer's owner ID for iam_user_get action.

Signed-off-by: Mike Mason <[email protected]>
@mikemrm mikemrm force-pushed the add-get-user-endpoint branch from 9420dc1 to b87c211 Compare March 7, 2024 19:11
@mikemrm mikemrm merged commit 126c0db into infratographer:main Mar 7, 2024
21 checks passed
@mikemrm mikemrm deleted the add-get-user-endpoint branch March 7, 2024 19:54
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.

2 participants