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

Fix create authorization command #10947

Merged
merged 1 commit into from
Jan 14, 2019
Merged

Fix create authorization command #10947

merged 1 commit into from
Jan 14, 2019

Conversation

desa
Copy link
Contributor

@desa desa commented Jan 10, 2019

Link https://github.com/influxdata/platform/pull/2185
Closes #10837

Briefly describe your proposed changes:
Previously, authorizations required the users id to be set explicitly on the authorization. As of #2157 the user id is retrieved off of the authorization or session used in the http request.

We now allow users to specify an explicit user when creating authorizations. If the id is not provided, the user from the authorizer will be used.

Additionally, we now need to pass the organization id when creating an authorization.

@ghost ghost assigned desa Jan 10, 2019
@ghost ghost added the review label Jan 10, 2019
Copy link
Contributor

@leodido leodido left a comment

Choose a reason for hiding this comment

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

💯 as always (only one little things about errors).

@@ -387,6 +389,9 @@ func TestService_handlePostAuthorization(t *testing.T) {
},
UserService: &mock.UserService{
FindUserByIDFn: func(ctx context.Context, id platform.ID) (*platform.User, error) {
if !id.Valid() {
return nil, errors.New("invalid ID")
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably you want to use platform.ErrInvalidID here :)

@@ -395,6 +400,9 @@ func TestService_handlePostAuthorization(t *testing.T) {
},
OrganizationService: &mock.OrganizationService{
FindOrganizationByIDF: func(ctx context.Context, id platform.ID) (*platform.Organization, error) {
if !id.Valid() {
return nil, errors.New("invalid ID")
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above.

@mark-rushakoff mark-rushakoff changed the base branch from next to master January 11, 2019 18:46
@mark-rushakoff
Copy link
Contributor

This has some merge conflicts now, and needs to be rebased to get CI sorted out. But when I built merged locally to master and built, and took a blind guess on the merge conflicts, it appeared to fix the issue of being unable to create authorizations for other users.

@desa desa force-pushed the fix/issue#2169 branch 2 times, most recently from ed35a73 to c62895b Compare January 14, 2019 15:14
Copy link
Contributor

@leodido leodido left a comment

Choose a reason for hiding this comment

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

Again 💯

@@ -229,6 +228,23 @@ func authorizationCreateF(cmd *cobra.Command, args []string) error {
OrgID: o.ID,
}

if authorizationCreateFlags.user != "" {
// if the user flag is supplied, the set the user ID explicitly on the request
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps a typo here @desa?

then set?

test(http): get user off of session in create authz test

fix(http): allow user id to be specified explicitly on authorization

create authorization now allows specifying user id explicitly. If no
user id is specified then we use the user id from the authorizer.

fix(http): use influxdb import

fix(http): use platform error in http auth tests

feat(cmd/influx): allow create auth command to specify user explicitly

feat(http): add org id to permissions
@desa desa merged commit 3bbe2c8 into master Jan 14, 2019
@desa desa deleted the fix/issue#2169 branch January 14, 2019 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants