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

OIDC Add remaining environments (azure, gcp), evergreen testing, API naming updates #1371

Merged
merged 25 commits into from
Apr 29, 2024

Conversation

katcharov
Copy link
Contributor

@katcharov katcharov commented Apr 19, 2024

JAVA-5353 API naming
JAVA-5395 Atlas testing
JAVA-4834 Azure
JAVA-4932 GCP

@@ -916,7 +916,7 @@ private MongoCredential createCredentials(final Map<String, List<String>> option

if (credential != null && authMechanismProperties != null) {
for (String part : authMechanismProperties.split(",")) {
String[] mechanismPropertyKeyValue = part.split(":");
String[] mechanismPropertyKeyValue = part.split(":", 2);
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 ignores the second : (a test passes in a value that decodes to a string that includes :).

@katcharov katcharov marked this pull request as ready for review April 23, 2024 16:24
@katcharov
Copy link
Contributor Author

Rebased feature-oidc and this branch on latest master, no conflicts.

@@ -69,11 +73,20 @@
*/
public final class OidcAuthenticator extends SaslAuthenticator {

private static final List<String> SUPPORTED_PROVIDERS = Arrays.asList("aws");
private static final String TEST_ENVIRONMENT = "test";
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 only used (enabled) in unified tests. The "Entities" class could instead check if this environment is set, and supply the test callback under OIDC_CALLBACK_KEY, which is a mild abuse of mechanism properties, but would avoid the (limited) code needed in the driver to support this.

@@ -601,7 +601,7 @@ class ConnectionStringSpecification extends Specification {
new ConnectionString('mongodb://jeff@localhost/?' +
'authMechanism=GSSAPI' +
'&authMechanismProperties=' +
'SERVICE_NAME:foo:bar')
'SERVICE_NAMEbar') // missing =
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No spec was associated with the Jira ticket where this check was added. OIDC tests include a value with a second : (when decoded). Rather than remove, I replaced with a different invalidity check.

.evergreen/.evg.yml Outdated Show resolved Hide resolved
.evergreen/.evg.yml Outdated Show resolved Hide resolved
.evergreen/run-mongodb-oidc-test.sh Outdated Show resolved Hide resolved
@@ -2216,6 +2339,27 @@ buildvariants:
tasks:
- name: "test_atlas_task_group_search_indexes"

- name: "oidc-auth-test"
display_name: "OIDC Auth"
run_on: ubuntu2204-small
Copy link
Member

Choose a reason for hiding this comment

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

We explicitly test on Windows and MacOS in PyMongo, but I'd consider that optional.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All of our tests use linux/ubuntu as the os, so I took those out.

public static OidcCallback getAzureCallback(final MongoCredential credential) {
return (context) -> {
String resource = assertNotNull(credential.getMechanismProperty(TOKEN_RESOURCE_KEY, null));
String objectId = credential.getUserName();
Copy link
Member

Choose a reason for hiding this comment

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

This is actually the clientId

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, my ensuing fetchAzure... call is calling:

    public static CredentialInfo fetchAzureCredentialInfo(final String resource, @Nullable final String objectId) {
        String endpoint = "http://169.254.169.254:80"
                + "/metadata/identity/oauth2/token?api-version=2018-02-01"
                + "&resource=" + resource
                + (objectId == null ? "" : "&object_id=" + objectId);

This must be incorrect, since the spec says to use:

http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=<resource>&client_id=<client_id>

I'll update this, but why do the tests still pass, and was this changed from object_id?

Copy link
Member

Choose a reason for hiding this comment

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

It was changed from object_id to align with the Azure SDK that uses client_id.

katcharov and others added 6 commits April 25, 2024 17:07
Co-authored-by: Valentin Kovalenko <valentin.male.kovalenko@gmail.com>
Co-authored-by: Valentin Kovalenko <valentin.male.kovalenko@gmail.com>
…ntialInfo.java

Co-authored-by: Valentin Kovalenko <valentin.male.kovalenko@gmail.com>
Copy link
Member

@blink1073 blink1073 left a comment

Choose a reason for hiding this comment

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

LGTM!

driver-core/src/main/com/mongodb/internal/Locks.java Outdated Show resolved Hide resolved
driver-core/src/main/com/mongodb/internal/Locks.java Outdated Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

Commits d856d84 and cc1c7ec in this PR take changes from mongodb/specifications#1569, which hasn't been approved and merged. Are we sure this is the way to go? I realize that we are short of time, but taking spec changes that are still work in progress (if this were not the case, they would have been merged) is not the right process, and we may end up having tests that have never been merged to the spec.

I would also expect that if there is time pressure on the driver, the same (even more, actually) should be true for the spec changes, because they have to go before the driver changes.

Maxim, if you have already confirmed this with Jeff, then OK. If not, then could you please confirm? (alternatively, I can do that)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree that we should block merging of at least the OIDC feature PR on the approval and merging of that PR (and I have no issues with blocking this PR since nothing depends on it).

Comment on lines +45 to +47
// encoded tags will fail parsing with an "invalid read preference tag"
// error if decoding is skipped.
String encodedTags = encode("dc:ny,rack:1");
Copy link
Member

Choose a reason for hiding this comment

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

👌

Copy link
Member

@stIncMale stIncMale left a comment

Choose a reason for hiding this comment

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

Just a small thing

…n/OidcAuthenticationProseTests.java

Co-authored-by: Valentin Kovalenko <valentin.male.kovalenko@gmail.com>
@katcharov katcharov merged commit 106ee4d into mongodb:feature-oidc Apr 29, 2024
2 checks passed
@katcharov katcharov deleted the JAVA-oidc-4395 branch April 29, 2024 21:00
katcharov added a commit that referenced this pull request Apr 30, 2024
* Implement OIDC SASL mechanism in sync (#1107)

JAVA-4980

* Implement OIDC auth for async (#1131)

JAVA-4981

* Remove non-machine workflow (#1259)

JAVA-5077

* Add Human OIDC Workflow (#1316)

JAVA-5328

* OIDC Add remaining environments (azure, gcp), evergreen testing, API naming updates (#1371)

JAVA-5353
JAVA-5395
JAVA-4834
JAVA-4932

Co-authored-by: Valentin Kovalenko <valentin.kovalenko@mongodb.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.

3 participants