Skip to content

Commit

Permalink
Revert "Add Client Assertion Support in OBO + Fix PWSH auth for Ubuntu (
Browse files Browse the repository at this point in the history
#40552)"

This reverts commit d78fcd6. It only reverts the OBO changes.
  • Loading branch information
billwert committed Jul 16, 2024
1 parent 184e04a commit c3b0fc3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 225 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
import com.azure.identity.implementation.util.LoggingUtil;
import reactor.core.publisher.Mono;

import java.util.function.Supplier;

/**
* <p>On Behalf of authentication in Azure is a way for a user or application to authenticate to a service or resource
* using credentials from another identity provider. This type of authentication is typically used when a user or
Expand Down Expand Up @@ -66,14 +64,12 @@ public class OnBehalfOfCredential implements TokenCredential {
* @param identityClientOptions the options for configuring the identity client
*/
OnBehalfOfCredential(String clientId, String tenantId, String clientSecret, String certificatePath,
String certificatePassword, Supplier<String> clientAssertionSupplier,
IdentityClientOptions identityClientOptions) {
String certificatePassword, IdentityClientOptions identityClientOptions) {
IdentityClientBuilder builder = new IdentityClientBuilder()
.tenantId(tenantId)
.clientId(clientId)
.clientSecret(clientSecret)
.certificatePath(certificatePath)
.clientAssertionSupplier(clientAssertionSupplier)
.certificatePassword(certificatePassword)
.identityClientOptions(identityClientOptions);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import com.azure.core.util.logging.ClientLogger;
import com.azure.identity.implementation.util.ValidationUtil;

import java.util.function.Supplier;

/**
* Fluent credential builder for instantiating a {@link OnBehalfOfCredential}.
*
Expand Down Expand Up @@ -49,8 +47,6 @@ public class OnBehalfOfCredentialBuilder extends AadCredentialBuilderBase<OnBeha
private String clientSecret;
private String clientCertificatePath;
private String clientCertificatePassword;
private Supplier<String> clientAssertionSupplier;


/**
* Constructs an instance of OnBehalfOfCredentialBuilder.
Expand Down Expand Up @@ -140,17 +136,6 @@ public OnBehalfOfCredentialBuilder userAssertion(String userAssertion) {
return this;
}

/**
* Sets the supplier containing the logic to supply the client assertion when invoked.
*
* @param clientAssertionSupplier the supplier supplying client assertion.
* @return An updated instance of this builder.
*/
public OnBehalfOfCredentialBuilder clientAssertion(Supplier<String> clientAssertionSupplier) {
this.clientAssertionSupplier = clientAssertionSupplier;
return this;
}

/**
* Creates a new {@link OnBehalfOfCredential} with the current configurations.
*
Expand All @@ -161,16 +146,19 @@ public OnBehalfOfCredentialBuilder clientAssertion(Supplier<String> clientAssert
public OnBehalfOfCredential build() {
ValidationUtil.validate(CLASS_NAME, LOGGER, "clientId", clientId, "tenantId", tenantId);

if ((clientSecret == null && clientCertificatePath == null && clientAssertionSupplier == null)
|| (clientSecret != null && clientCertificatePath != null)
|| (clientSecret != null && clientAssertionSupplier != null)
|| (clientCertificatePath != null && clientAssertionSupplier != null)) {
throw LOGGER.logExceptionAsWarning(new IllegalArgumentException("Exactly one of client secret, "
+ "client certificate path, or client assertion supplier must be provided "
+ "in OnBehalfOfCredentialBuilder."));
if (clientSecret == null && clientCertificatePath == null) {
throw LOGGER.logExceptionAsWarning(new IllegalArgumentException("At least client secret or certificate "
+ "path should provided in OnBehalfOfCredentialBuilder. Only one of them should "
+ "be provided."));
}

if (clientCertificatePath != null && clientSecret != null) {
throw LOGGER.logExceptionAsWarning(new IllegalArgumentException("Both client secret and certificate "
+ "path are provided in OnBehalfCredentialBuilder. Only one of them should "
+ "be provided."));
}

return new OnBehalfOfCredential(clientId, tenantId, clientSecret, clientCertificatePath,
clientCertificatePassword, clientAssertionSupplier, identityClientOptions);
clientCertificatePassword, identityClientOptions);
}
}

This file was deleted.

0 comments on commit c3b0fc3

Please sign in to comment.