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
Expose GetPassword via the GRPC API #1271
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,7 @@ Finally run the Dex client providing the CA certificate, client certificate and | |
Running the gRPC client will cause the following API calls to be made to the server | ||
1. CreatePassword | ||
2. ListPasswords | ||
3. GetPassword | ||
3. DeletePassword | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nit] I know it doesn't matter for presentation, but it's nicer to read this in raw form if the numbers are actually consecutive -- can you make There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was trying to maintain the style, but I'm just gonna make them all |
||
|
||
## Cleaning up | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -223,6 +223,33 @@ func (d dexAPI) ListPasswords(ctx context.Context, req *api.ListPasswordReq) (*a | |
|
||
} | ||
|
||
func (d dexAPI) GetPassword(ctx context.Context, req *api.GetPasswordReq) (*api.GetPasswordResp, error) { | ||
if req.Email == "" { | ||
return nil, errors.New("no email supplied") | ||
} | ||
|
||
password, err := d.s.GetPassword(req.Email) | ||
if err != nil { | ||
if err == storage.ErrNotFound { | ||
return &api.GetPasswordResp{ | ||
NotFound: true, | ||
}, nil | ||
} | ||
d.logger.Errorf("api: there was an error retrieving the password: %v", err) | ||
return nil, fmt.Errorf("get password: %v", err) | ||
} | ||
|
||
return &api.GetPasswordResp{ | ||
NotFound: false, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nit] this line is superfluous, but being explicit is OK 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep was trying to be explicit. |
||
Password: &api.Password{ | ||
Email: password.Email, | ||
Username: password.Username, | ||
UserId: password.UserID, | ||
}, | ||
}, nil | ||
|
||
} | ||
|
||
func (d dexAPI) ListRefresh(ctx context.Context, req *api.ListRefreshReq) (*api.ListRefreshResp, error) { | ||
id := new(internal.IDTokenSubject) | ||
if err := internal.Unmarshal(req.UserId, id); err != nil { | ||
|
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 is really oddly named. Can we either rename it "GetUserResp" and "GetUserReq"? Or can we strongly clarify that the password isn't returned?