-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Capability in dagger to consume from ACL enabled kafka clusters (…
…#195) * feat: added source kafka props to consume data from ACL enabled kafka * fix: revert version bump * fix: added SASL_JAAS_CONFIG config key * feat: docs update for JAAS config * revert: local.properties changes * fix: added security page * fix: added security page * fix: security page link update * feat: added basic validation for supported kafka acl configuration * fix: added missing security page in sidebar Co-authored-by: Mayank Rai <[email protected]>
- Loading branch information
1 parent
3243b39
commit 8f32ecc
Showing
11 changed files
with
391 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...e/src/main/java/io/odpf/dagger/core/source/config/adapter/DaggerSASLMechanismAdaptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package io.odpf.dagger.core.source.config.adapter; | ||
|
||
import com.google.gson.TypeAdapter; | ||
import com.google.gson.stream.JsonReader; | ||
import com.google.gson.stream.JsonWriter; | ||
import io.odpf.dagger.core.exception.InvalidConfigurationException; | ||
import io.odpf.dagger.core.utils.Constants; | ||
|
||
import java.io.IOException; | ||
import java.util.Arrays; | ||
|
||
public class DaggerSASLMechanismAdaptor extends TypeAdapter<String> { | ||
@Override | ||
public void write(JsonWriter jsonWriter, String value) throws IOException { | ||
if (value == null) { | ||
jsonWriter.nullValue(); | ||
return; | ||
} | ||
jsonWriter.value(value); | ||
} | ||
|
||
@Override | ||
public String read(JsonReader jsonReader) throws IOException { | ||
String saslMechanism = jsonReader.nextString(); | ||
if (Arrays.stream(Constants.SUPPORTED_SOURCE_KAFKA_CONSUMER_CONFIG_SASL_MECHANISM).anyMatch(saslMechanism::equals)) { | ||
return saslMechanism; | ||
} else { | ||
throw new InvalidConfigurationException(String.format("Configured wrong SOURCE_KAFKA_CONSUMER_CONFIG_SASL_MECHANISM supported values are %s", Arrays.toString(Constants.SUPPORTED_SOURCE_KAFKA_CONSUMER_CONFIG_SASL_MECHANISM))); | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...rc/main/java/io/odpf/dagger/core/source/config/adapter/DaggerSecurityProtocolAdaptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package io.odpf.dagger.core.source.config.adapter; | ||
|
||
import com.google.gson.TypeAdapter; | ||
import com.google.gson.stream.JsonReader; | ||
import com.google.gson.stream.JsonWriter; | ||
import io.odpf.dagger.core.exception.InvalidConfigurationException; | ||
import io.odpf.dagger.core.utils.Constants; | ||
|
||
import java.io.IOException; | ||
import java.util.Arrays; | ||
|
||
public class DaggerSecurityProtocolAdaptor extends TypeAdapter<String> { | ||
@Override | ||
public void write(JsonWriter jsonWriter, String value) throws IOException { | ||
if (value == null) { | ||
jsonWriter.nullValue(); | ||
return; | ||
} | ||
jsonWriter.value(value); | ||
} | ||
|
||
@Override | ||
public String read(JsonReader jsonReader) throws IOException { | ||
String securityProtocol = jsonReader.nextString(); | ||
if (Arrays.stream(Constants.SUPPORTED_SOURCE_KAFKA_CONSUMER_CONFIG_SECURITY_PROTOCOL).anyMatch(securityProtocol::equals)) { | ||
return securityProtocol; | ||
} else { | ||
throw new InvalidConfigurationException(String.format("Configured wrong SOURCE_KAFKA_CONSUMER_CONFIG_SECURITY_PROTOCOL supported values are %s", Arrays.toString(Constants.SUPPORTED_SOURCE_KAFKA_CONSUMER_CONFIG_SECURITY_PROTOCOL))); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...c/test/java/io/odpf/dagger/core/source/config/adapter/DaggerSASLMechanismAdaptorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package io.odpf.dagger.core.source.config.adapter; | ||
|
||
import com.google.gson.stream.JsonReader; | ||
import io.odpf.dagger.core.exception.InvalidConfigurationException; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.mockito.Mock; | ||
import java.io.IOException; | ||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertThrows; | ||
import static org.mockito.Mockito.when; | ||
import static org.mockito.MockitoAnnotations.initMocks; | ||
|
||
public class DaggerSASLMechanismAdaptorTest { | ||
@Mock | ||
private JsonReader jsonReader; | ||
|
||
@Before | ||
public void setup() { | ||
initMocks(this); | ||
} | ||
|
||
@Test | ||
public void shouldAcceptConfiguredValue() throws IOException { | ||
when(jsonReader.nextString()).thenReturn("SCRAM-SHA-512"); | ||
DaggerSASLMechanismAdaptor daggerSASLMechanismAdaptor = new DaggerSASLMechanismAdaptor(); | ||
String saslMechanism = daggerSASLMechanismAdaptor.read(jsonReader); | ||
assertEquals("SCRAM-SHA-512", saslMechanism); | ||
} | ||
|
||
@Test | ||
public void shouldNotAcceptConfiguredValue() throws IOException { | ||
when(jsonReader.nextString()).thenReturn("SCRAMSHA512"); | ||
DaggerSASLMechanismAdaptor daggerSASLMechanismAdaptor = new DaggerSASLMechanismAdaptor(); | ||
assertThrows(InvalidConfigurationException.class, () -> daggerSASLMechanismAdaptor.read(jsonReader)); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...est/java/io/odpf/dagger/core/source/config/adapter/DaggerSecurityProtocolAdaptorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package io.odpf.dagger.core.source.config.adapter; | ||
|
||
import com.google.gson.stream.JsonReader; | ||
import io.odpf.dagger.core.exception.InvalidConfigurationException; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.mockito.Mock; | ||
|
||
import java.io.IOException; | ||
|
||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertThrows; | ||
import static org.mockito.Mockito.when; | ||
import static org.mockito.MockitoAnnotations.initMocks; | ||
|
||
public class DaggerSecurityProtocolAdaptorTest { | ||
|
||
@Mock | ||
private JsonReader jsonReader; | ||
|
||
@Before | ||
public void setup() { | ||
initMocks(this); | ||
} | ||
|
||
@Test | ||
public void shouldAcceptConfiguredValue() throws IOException { | ||
when(jsonReader.nextString()).thenReturn("SASL_PLAINTEXT"); | ||
DaggerSecurityProtocolAdaptor daggerSecurityProtocolAdaptor = new DaggerSecurityProtocolAdaptor(); | ||
String securityProtocol = daggerSecurityProtocolAdaptor.read(jsonReader); | ||
assertEquals("SASL_PLAINTEXT", securityProtocol); | ||
} | ||
|
||
@Test | ||
public void shouldNotAcceptConfiguredValue() throws IOException { | ||
when(jsonReader.nextString()).thenReturn("SASLPLAINTEXT"); | ||
DaggerSecurityProtocolAdaptor daggerSecurityProtocolAdaptor = new DaggerSecurityProtocolAdaptor(); | ||
assertThrows(InvalidConfigurationException.class, () -> daggerSecurityProtocolAdaptor.read(jsonReader)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.