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 {add,update,delete,list}ServiceAccount and getServiceAccountInfo Admin APIs #1505

Merged
merged 18 commits into from
Dec 2, 2023

Conversation

dormanze
Copy link
Contributor

fix #1498

@Kress6
Copy link

Kress6 commented Oct 30, 2023

Hi guys,

Is there any progress on the review?
I was already planning to contribute myself. 😊 But I see that the pull request is ready. I would really like to see this feature in a new lib release.

@dormanze
Copy link
Contributor Author

Hi guys,

Is there any progress on the review? I was already planning to contribute myself. 😊 But I see that the pull request is ready. I would really like to see this feature in a new lib release.

Can you review my code and approved my changes?😊

@Kress6
Copy link

Kress6 commented Oct 30, 2023

Can you review my code and approved my changes?😊

Yes. I can review, but I don't have write access. 😊

@balamurugana
Copy link
Member

Is the PR #1500 unrelated to this PR?

@dormanze
Copy link
Contributor Author

dormanze commented Nov 3, 2023

Is the PR #1500 unrelated to this PR?

This PR contains the content of PR #1500 and complements the implementation of other related APIs.

@balamurugana
Copy link
Member

Is the PR #1500 unrelated to this PR?

This PR contains the content of PR #1500 and complements the implementation of other related APIs.

You could close the other PR?

@dormanze
Copy link
Contributor Author

dormanze commented Nov 3, 2023

Is the PR #1500 unrelated to this PR?

This PR contains the content of PR #1500 and complements the implementation of other related APIs.

You could close the other PR?

PR #1500 was not initiated by me, you can close PR #1500 and # 1498 after incorporating my PR.😊

@dormanze
Copy link
Contributor Author

dormanze commented Nov 3, 2023

@balamurugana Could you take a moment to review my PR? I'm very grateful.

@balamurugana
Copy link
Member

@balamurugana Could you take a moment to review my PR? I'm very grateful.

I am on it

Resolve conversation
@Kress6
Copy link

Kress6 commented Nov 8, 2023

Hi, @dorma
Have you tried using addServiceAccount method with policy? I got exeption. Although a similar code works in Go.

Exception:

java.lang.RuntimeException: Request failed with response: {"Code":"XMinioMalformedIAMPolicy","Message":"json: cannot unmarshal string into Go value of type policy.subPolicy","Resource":"/minio/admin/v3/add-service-account","RequestId":"***","HostId":"***"}

	at io.minio.admin.MinioAdminClient.execute(MinioAdminClient.java:218)
	at io.minio.admin.MinioAdminClient.addServiceAccount(MinioAdminClient.java:723)

Code:

        MinioAdminClient minioAdminClient = MinioAdminClient.builder()
                .endpoint("http://127.0.0.1:9000/")
                .credentials("test", "password")
                .build()
        String policy = """
            {
                "Statement": [
                    {
                        "Action": "s3:GetObject",
                        "Effect": "Allow",
                        "Principal": "*",
                        "Resource": "arn:aws:s3:::my-bucketname/myobject*"
                    }
                ],
                "Version": "2012-10-17"
            }""";
        Credentials credentials = minioAdminClient.addServiceAccount("user",
                "name",
                "secretKey",
                "accessKey",
                policy,
                null,
                null);

@Kress6
Copy link

Kress6 commented Nov 9, 2023

Hi, @dormanze
I also get NPE if I pass an empty expiration

Caused by: java.lang.NullPointerException: text
	at java.base/java.util.Objects.requireNonNull(Objects.java:235)
	at java.base/java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1951)
	at java.base/java.time.ZonedDateTime.parse(ZonedDateTime.java:600)
	at io.minio.messages.ResponseDate.fromString(ResponseDate.java:57)
	at io.minio.admin.MinioAdminClient.addServiceAccount(MinioAdminClient.java:723)

Maybe you need to unmarshal json response and map it into Credentials.

@dormanze
Copy link
Contributor Author

Hi, @dorma Have you tried using addServiceAccount method with policy? I got exeption. Although a similar code works in Go.

Exception:

java.lang.RuntimeException: Request failed with response: {"Code":"XMinioMalformedIAMPolicy","Message":"json: cannot unmarshal string into Go value of type policy.subPolicy","Resource":"/minio/admin/v3/add-service-account","RequestId":"***","HostId":"***"}

	at io.minio.admin.MinioAdminClient.execute(MinioAdminClient.java:218)
	at io.minio.admin.MinioAdminClient.addServiceAccount(MinioAdminClient.java:723)

Code:

        MinioAdminClient minioAdminClient = MinioAdminClient.builder()
                .endpoint("http://127.0.0.1:9000/")
                .credentials("test", "password")
                .build()
        String policy = """
            {
                "Statement": [
                    {
                        "Action": "s3:GetObject",
                        "Effect": "Allow",
                        "Principal": "*",
                        "Resource": "arn:aws:s3:::my-bucketname/myobject*"
                    }
                ],
                "Version": "2012-10-17"
            }""";
        Credentials credentials = minioAdminClient.addServiceAccount("user",
                "name",
                "secretKey",
                "accessKey",
                policy,
                null,
                null);

I've fixed it. Please try again.

@dormanze
Copy link
Contributor Author

Hi, @dormanze I also get NPE if I pass an empty expiration

Caused by: java.lang.NullPointerException: text
	at java.base/java.util.Objects.requireNonNull(Objects.java:235)
	at java.base/java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1951)
	at java.base/java.time.ZonedDateTime.parse(ZonedDateTime.java:600)
	at io.minio.messages.ResponseDate.fromString(ResponseDate.java:57)
	at io.minio.admin.MinioAdminClient.addServiceAccount(MinioAdminClient.java:723)

Maybe you need to unmarshal json response and map it into Credentials.

I've fixed it. Please try again.

@Kress6
Copy link

Kress6 commented Nov 15, 2023

It works now, thanks

@dormanze
Copy link
Contributor Author

@balamurugana Could you take a moment to review my pr again? I'm very grateful.

@balamurugana balamurugana changed the title AdminClient: add service account API Add {add,update,delete,list}ServiceAccount and getServiceAccountInfo Admin APIs Nov 18, 2023
@dormanze
Copy link
Contributor Author

@harshavardhana I'd appreciate a little help reviewing my pr.

@harshavardhana harshavardhana merged commit 5c2854f into minio:master Dec 2, 2023
8 checks passed
@jean-humann
Copy link

@harshavardhana @balamurugana When could we expect to have this commit released with a new version of minio jdk please ?

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.

How to create a access key to an existing MinIO or AD/LDAP user in java.
5 participants