Skip to content

create User Api#411

Merged
jessesuen merged 4 commits intoargoproj:masterfrom
JazminElkan-Gonzalez:UserAPI
Jul 16, 2018
Merged

create User Api#411
jessesuen merged 4 commits intoargoproj:masterfrom
JazminElkan-Gonzalez:UserAPI

Conversation

@JazminElkan-Gonzalez
Copy link
Contributor

closes #377

import "google/api/annotations.proto";


message Body {
Copy link
Member

Choose a reason for hiding this comment

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

Theres no need for a Body message, just put these fields in theUsersPasswordRequest. In the grpc option you can put * and it will pick up the fields automatically.

See ApplicationSyncRequest for an example.

rpc UpdatePassword(UsersPasswordRequest) returns (UserResponse) {
option (google.api.http) = {
put: "/api/v1/users/{name}/password"
body: "body"
Copy link
Member

Choose a reason for hiding this comment

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

body should be * after making suggested changes.

}

if CurrentPassword == "" {
CurrentPassword = settings.ReadAndConfirmPassword("Current Password")
Copy link
Member

Choose a reason for hiding this comment

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

We should not require that the user type in their current password twice. Password confirmation should be done only for the new one.


}

//This Function is used to Update User Passwords \
Copy link
Member

Choose a reason for hiding this comment

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

Go doc convention is to repeat the name of the function in the comment. e.g.:

// UpdatePassword updates a user's password

func ReadAndConfirmPassword(types string) string {
for {
fmt.Print("*** Enter an admin password: ")
fmt.Printf("*** Enter an %s password: ", types)
Copy link
Member

Choose a reason for hiding this comment

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

Lets just remove types argument and say "Enter password:" and "Confirm password"

}
message UsersPasswordRequest {
string name = 1;
Body body = 2;
Copy link
Member

Choose a reason for hiding this comment

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

Remove body and have currentPassword and newPassword as fields here.

string currentPassword = 2;
string newPassword = 3;
}
message UsersPasswordRequest {
Copy link
Member

Choose a reason for hiding this comment

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

message name should be UpdatePasswordRequest

Body body = 2;
}

message UserResponse {}
Copy link
Member

Choose a reason for hiding this comment

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

message name should be UpdatePasswordResponse

@JazminElkan-Gonzalez
Copy link
Contributor Author

JazminElkan-Gonzalez commented Jul 14, 2018

Hello @jessesuen

  1. changed the response/request message name
  2. removed types argument from ReadAndConfirmPassword
  3. current password only needs to be entered once

but before i update the body, I wanted to explain why I did it this way.

in the current setup the swagger UI shows the body and required path parameter that we would expect,

image

but when I use '*' I see that the name gets duplicated in the body of the request.

image

(also when I looked online, the documentation for using '*' mentioned "Note that when using * in the body mapping, it is not possible to have HTTP parameters, as all fields not bound by the path end in the body. This makes this option more rarely used in practice of defining REST APIs. The common usage of * is in custom methods which don't use the URL at all for transferring data." which lead me to searching for an alternative)

but let me know if this should still be changed, it's a quick update. (I'll be in the mountains without connectivity until Monday night, but I can make the change then)

@jessesuen
Copy link
Member

Thanks for pointing out your reasoning.

when I use '*' I see that the name gets duplicated in the body of the request.

Right, this is an unfortunate side affect of grpc-gateway.

as all fields not bound by the path end in the body.

This is the behavior we want, the only consequence is the name also gets into the body, despite already being in the path.

It's more important that we get the gRPC messages and data structures in a way that we like, then swagger docs. Having an extra Body field just to make the swagger docs cleaner, unnecessarily makes the gRPC API more confusing, which will be our preferred way of interacting with the API server.

@jessesuen
Copy link
Member

I'll be in the mountains without connectivity until Monday night, but I can make the change then

Given that you'll be out, I'll go ahead and merge your current progress. I also realize we are missing an RBAC policy rule and check for user management, so I will pick off where you left off.

@jessesuen jessesuen merged commit 062b13e into argoproj:master Jul 16, 2018
@JazminElkan-Gonzalez
Copy link
Contributor Author

Kk i have the change staged on my computer so i will push it first thing in the morning.

leoluz pushed a commit to leoluz/argo-cd that referenced this pull request Sep 29, 2023
Signed-off-by: Florent Monbillard <f.monbillard@gmail.com>
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.

API and CLI to change password

2 participants