Skip to content

API for checking object management permissions #2086

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions api-bucket-policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,32 @@ func (c *Client) getBucketPolicy(ctx context.Context, bucketName string) (string
policy := string(bucketPolicyBuf)
return policy, err
}

// CheckObjectManagePermissions verifies if user has object permissions for given bucket
func (c *Client) CheckObjectManagePermissions(ctx context.Context, bucket string, user string) error {
Copy link
Member

Choose a reason for hiding this comment

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

And also why is this an S3 SDK API? This is specific to MinIO and must be in madmin-go

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This we are checking with replicated bucket target clients. We need to reach all targets of bucket replication and see target has got PutObject/DeleteObject etc. Is there a way to achieve it? I may be missing something here.

Copy link
Member

Choose a reason for hiding this comment

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

You need to add a new API in admin API for that not here

Copy link
Member

Choose a reason for hiding this comment

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

If you want to implement a proper S3 API then implement GetAccessBlock()

Copy link
Contributor

Choose a reason for hiding this comment

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

this should be in madmin-go

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, will better move to madmin-go

urlValues := make(url.Values)
urlValues.Set("user", user)

// Execute HEAD on bucketName.
resp, err := c.executeMethod(ctx, http.MethodGet, requestMetadata{
bucketName: bucket,
queryValues: urlValues,
})
defer closeResponse(resp)
if err != nil {
if ToErrorResponse(err).Code == "NoSuchBucket" {
return nil
}
return err
}
if resp != nil {
resperr := httpRespToErrorResponse(resp, bucket, "")
if ToErrorResponse(resperr).Code == "NoSuchBucket" {
return nil
}
if resp.StatusCode != http.StatusOK {
return httpRespToErrorResponse(resp, bucket, "")
}
}
return nil
}
12 changes: 12 additions & 0 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1071,3 +1071,15 @@ func (c *Client) CredContext() *credentials.CredContext {
Endpoint: c.endpointURL.String(),
}
}

// GetCreds returns the access creds for the client
func (c *Client) GetCreds() (string, string, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Credentials are always 3 entities, you should return the value()

But what is the point of this function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not needed with new changes. Will remove.

if c.credsProvider == nil {
return "", "", errors.New("no credentials provider")
}
value, err := c.credsProvider.GetWithContext(c.CredContext())
if err != nil {
return "", "", err
}
return value.AccessKeyID, value.SecretAccessKey, nil
}
Loading