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

fix: configuration changes and minor cosmetic changes required to release to maven #9

Merged
merged 5 commits into from
Aug 8, 2024
Merged
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
100 changes: 95 additions & 5 deletions kafka-java-auth/pom.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.google.cloud</groupId>
<artifactId>google-managed-kafka-auth-login-handler</artifactId>
<groupId>com.google.cloud.hosted.kafka</groupId>
<artifactId>managed-kafka-auth-login-handler</artifactId>
<version>1.0.0</version><!-- {x-version-update:pubsublite-kafka:current} -->
<packaging>jar</packaging>
<name>Managed Kafka Auth</name>
Expand All @@ -12,6 +12,23 @@
<name>Google</name>
<url>http://www.google.com/</url>
</organization>
<developers>
<developer>
<id>davidtorres</id>
<name>David Torres</name>
<email>[email protected]</email>
<organization>Google</organization>
<roles>
<role>Developer</role>
</roles>
</developer>
</developers>
<scm>
<connection>scm:git:[email protected]:googleapis/managedkafka.git/kafka-java-auth</connection>
<developerConnection>scm:git:[email protected]:googleapis/managedkafka.git/kafka-java-auth</developerConnection>
<url>https://github.com/googleapis/managedkafka</url>
<tag>managed-kafka-auth-login-handler-1.0.0</tag>
</scm>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
Expand All @@ -20,8 +37,7 @@
</license>
</licenses>
<properties>
<maven.compiler.source>1.10</maven.compiler.source>
<maven.compiler.target>1.10</maven.compiler.target>
<maven.compiler.release>11</maven.compiler.release>
</properties>
<dependencies>
<dependency>
Expand Down Expand Up @@ -53,5 +69,79 @@
<scope>test</scope>
</dependency>
</dependencies>
<distributionManagement>
<repository>
<id>sonatype-nexus-staging</id>
<url>https://google.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
<snapshotRepository>
<id>sonatype-nexus-snapshots</id>
<url>https://google.oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.7.0</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://google.oss.sonatype.org</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.4.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.8.0</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
davidtorres marked this conversation as resolved.
Show resolved Hide resolved

package com.google.cloud.hosted.kafka.auth;

import static java.nio.charset.StandardCharsets.UTF_8;
Expand Down Expand Up @@ -50,24 +50,25 @@
* using OAuth.
*/
public class GcpLoginCallbackHandler implements AuthenticateCallbackHandler {
public static final String JWT_SUBJECT_CLAIM = "sub";
public static final String JWT_ISSUED_AT_CLAIM = "iat";
public static final String JWT_SCOPE_CLAIM = "scope";
public static final String JWT_EXP_CLAIM = "exp";
private static final String JWT_SUBJECT_CLAIM = "sub";
private static final String JWT_ISSUED_AT_CLAIM = "iat";
private static final String JWT_SCOPE_CLAIM = "scope";
private static final String JWT_EXP_CLAIM = "exp";
private static final String GOOGLE_CLOUD_PLATFORM_SCOPE =
"https://www.googleapis.com/auth/cloud-platform";

/** A stub Google credentials class that exposes the account name. Used only for testing. */
public abstract static class StubGoogleCredentials extends GoogleCredentials {
abstract static class StubGoogleCredentials extends GoogleCredentials {
abstract String getAccount();
}

public static final String GOOGLE_CLOUD_PLATFORM_SCOPE =
"https://www.googleapis.com/auth/cloud-platform";
private static final String HEADER =
new Gson().toJson(ImmutableMap.of("typ", "JWT", "alg", "GOOG_OAUTH2_TOKEN"));

private boolean configured = false;
private final GoogleCredentials credentials;

/** Creates a new callback handler using the default application credentials. */
public GcpLoginCallbackHandler() {
try {
this.credentials =
Expand Down Expand Up @@ -174,3 +175,4 @@ private static String getKafkaAccessToken(AccessToken token, String subject) {
@Override
public void close() {}
}

Loading