diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index fc8b154..1e25c1a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -27,11 +27,11 @@ jobs: echo "keyid: ${{ steps.import_gpg.outputs.keyid }}" echo "name: ${{ steps.import_gpg.outputs.name }}" echo "email: ${{ steps.import_gpg.outputs.email }}" -# - name: Publish to the Maven Central Repository -# run: mvn -P sonatype,release -B deploy -# env: -# MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} -# MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} + - name: Publish to the Maven Central Repository + run: mvn -P sonatype,release -B deploy + env: + MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} - name: Set up Java for publishing to GitHub Packages uses: actions/setup-java@v1 with: diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 2896737..80d04ea 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -24,13 +24,13 @@ jobs: # with: # token: ${{ secrets.CODECOV_TOKEN }} test: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} strategy: matrix: # test against latest update of each major Java version, as well as specific updates of LTS versions: - java: [ 8, 9, 10, 11, 12 ] -# java: [ 7, 8, 9, 10, 11, 12, 13, 14 ] - name: Java ${{ matrix.java }} build + java: [ 8, 9, 10, 11, 12, 13, 14, 15, 16-ea] + os: [ubuntu-18.04, windows-2019, macos-10.15] + name: Test JDK ${{ matrix.java }}, ${{ matrix.os }} steps: - uses: actions/checkout@v2 - name: Set up JDK ${{ matrix.java }} diff --git a/README.md b/README.md index 5ba3dee..0f45045 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ Kerb4J ======== -[![Build Status](https://travis-ci.org/bedrin/kerb4j.svg?branch=master)](https://travis-ci.org/bedrin/kerb4j) +![Java CI](https://github.com/bedrin/kerb4j/workflows/Java%20CI/badge.svg?branch=develop) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.kerb4j/kerb4j/badge.svg?style=flat)](https://maven-badges.herokuapp.com/maven-central/com.kerb4j/kerb4j) -Industry standard library for working with Kerberos/SPNEGO authentication in Java in 2018. +Industry standard library for working with Kerberos/SPNEGO authentication in Java in 2020+. Main features: - Getting group membership information from Kerberos token - no need to query LDAP - - Proper caching of tickets - make just one request to domain controller and cache the ticket + - Proper caching of tickets - make just one request to domain controller and cache the ticket on both client and server sides - Flexible SPN resolution - you own the code and do not have to rely on magic SPN calculation algorithms Installation @@ -20,7 +20,7 @@ Kerb4J is available from Maven Central repo: com.kerb4j kerb4j-client - 0.0.9 + 0.1.0-SNAPSHOT ``` @@ -29,7 +29,7 @@ Kerb4J is available from Maven Central repo: com.kerb4j kerb4j-server-spring-security - 0.0.9 + 0.1.0-SNAPSHOT ``` @@ -38,7 +38,7 @@ Kerb4J is available from Maven Central repo: com.kerb4j kerb4j-server-tomcat - 0.0.9 + 0.1.0-SNAPSHOT ``` diff --git a/kerb4j-base64/kerb4j-base64-common/pom.xml b/kerb4j-base64/kerb4j-base64-common/pom.xml index bc36f2e..8fdb8ab 100644 --- a/kerb4j-base64/kerb4j-base64-common/pom.xml +++ b/kerb4j-base64/kerb4j-base64-common/pom.xml @@ -5,7 +5,7 @@ kerb4j-base64 com.kerb4j - 0.0.9 + 0.1.0-SNAPSHOT 4.0.0 diff --git a/kerb4j-base64/kerb4j-base64-java7/pom.xml b/kerb4j-base64/kerb4j-base64-java7/pom.xml index f6a36ee..5d3de32 100644 --- a/kerb4j-base64/kerb4j-base64-java7/pom.xml +++ b/kerb4j-base64/kerb4j-base64-java7/pom.xml @@ -5,7 +5,7 @@ kerb4j-base64 com.kerb4j - 0.0.9 + 0.1.0-SNAPSHOT 4.0.0 @@ -15,7 +15,7 @@ com.kerb4j kerb4j-base64-common - 0.0.9 + 0.1.0-SNAPSHOT jakarta.xml.bind @@ -30,6 +30,7 @@ org.apache.maven.plugins maven-javadoc-plugin + 3.2.0 7 diff --git a/kerb4j-base64/kerb4j-base64-java8/pom.xml b/kerb4j-base64/kerb4j-base64-java8/pom.xml index e550ee9..0bd41d2 100644 --- a/kerb4j-base64/kerb4j-base64-java8/pom.xml +++ b/kerb4j-base64/kerb4j-base64-java8/pom.xml @@ -5,7 +5,7 @@ kerb4j-base64 com.kerb4j - 0.0.9 + 0.1.0-SNAPSHOT 4.0.0 @@ -15,7 +15,7 @@ com.kerb4j kerb4j-base64-common - 0.0.9 + 0.1.0-SNAPSHOT diff --git a/kerb4j-base64/pom.xml b/kerb4j-base64/pom.xml index cab4cd1..c45edae 100644 --- a/kerb4j-base64/pom.xml +++ b/kerb4j-base64/pom.xml @@ -5,7 +5,7 @@ kerb4j com.kerb4j - 0.0.9 + 0.1.0-SNAPSHOT 4.0.0 diff --git a/kerb4j-client/pom.xml b/kerb4j-client/pom.xml index 5952da6..cd8d035 100644 --- a/kerb4j-client/pom.xml +++ b/kerb4j-client/pom.xml @@ -5,7 +5,7 @@ com.kerb4j kerb4j - 0.0.9 + 0.1.0-SNAPSHOT kerb4j-client @@ -17,12 +17,12 @@ com.kerb4j kerb4j-common - 0.0.9 + 0.1.0-SNAPSHOT com.kerb4j kerb4j-common - 0.0.9 + 0.1.0-SNAPSHOT tests test diff --git a/kerb4j-common/pom.xml b/kerb4j-common/pom.xml index e1444ea..77adb78 100644 --- a/kerb4j-common/pom.xml +++ b/kerb4j-common/pom.xml @@ -5,7 +5,7 @@ com.kerb4j kerb4j - 0.0.9 + 0.1.0-SNAPSHOT kerb4j-common @@ -17,12 +17,12 @@ com.kerb4j kerb4j-base64-java7 - 0.0.9 + 0.1.0-SNAPSHOT com.kerb4j kerb4j-base64-java8 - 0.0.9 + 0.1.0-SNAPSHOT org.apache.kerby diff --git a/kerb4j-common/src/test/java/com/kerb4j/KerberosSecurityTestcase.java b/kerb4j-common/src/test/java/com/kerb4j/KerberosSecurityTestcase.java index f6d0201..3168862 100644 --- a/kerb4j-common/src/test/java/com/kerb4j/KerberosSecurityTestcase.java +++ b/kerb4j-common/src/test/java/com/kerb4j/KerberosSecurityTestcase.java @@ -50,7 +50,7 @@ public class KerberosSecurityTestcase { private File workDir; private KrbConfig conf; - private int kdcPort; + protected int kdcPort; private static int i = 10000; diff --git a/kerb4j-server/kerb4j-server-common/pom.xml b/kerb4j-server/kerb4j-server-common/pom.xml index 7f27893..65d56ef 100644 --- a/kerb4j-server/kerb4j-server-common/pom.xml +++ b/kerb4j-server/kerb4j-server-common/pom.xml @@ -5,7 +5,7 @@ com.kerb4j kerb4j-server - 0.0.9 + 0.1.0-SNAPSHOT kerb4j-server-common diff --git a/kerb4j-server/kerb4j-server-spring-security-ldap/pom.xml b/kerb4j-server/kerb4j-server-spring-security-ldap/pom.xml index 7465eb8..7ec18a4 100644 --- a/kerb4j-server/kerb4j-server-spring-security-ldap/pom.xml +++ b/kerb4j-server/kerb4j-server-spring-security-ldap/pom.xml @@ -5,7 +5,7 @@ com.kerb4j kerb4j-server - 0.0.9 + 0.1.0-SNAPSHOT kerb4j-server-spring-security-ldap @@ -19,7 +19,7 @@ com.kerb4j kerb4j-server-spring-security - 0.0.9 + 0.1.0-SNAPSHOT diff --git a/kerb4j-server/kerb4j-server-spring-security/pom.xml b/kerb4j-server/kerb4j-server-spring-security/pom.xml index 6cedd95..4d8c6a8 100644 --- a/kerb4j-server/kerb4j-server-spring-security/pom.xml +++ b/kerb4j-server/kerb4j-server-spring-security/pom.xml @@ -5,7 +5,7 @@ com.kerb4j kerb4j-server - 0.0.9 + 0.1.0-SNAPSHOT kerb4j-server-spring-security @@ -19,7 +19,7 @@ com.kerb4j kerb4j-server-common - 0.0.9 + 0.1.0-SNAPSHOT @@ -49,7 +49,7 @@ io.sniffy sniffy-web - 3.1.5 + 3.1.6 test diff --git a/kerb4j-server/kerb4j-server-spring-security/src/test/java/com/kerb4j/client/spring/SpnegoRestTemplateTest.java b/kerb4j-server/kerb4j-server-spring-security/src/test/java/com/kerb4j/client/spring/SpnegoRestTemplateTest.java index bc66fc2..29f364e 100644 --- a/kerb4j-server/kerb4j-server-spring-security/src/test/java/com/kerb4j/client/spring/SpnegoRestTemplateTest.java +++ b/kerb4j-server/kerb4j-server-spring-security/src/test/java/com/kerb4j/client/spring/SpnegoRestTemplateTest.java @@ -17,6 +17,8 @@ import com.kerb4j.KerberosSecurityTestcase; import com.kerb4j.client.SpnegoClient; +import io.sniffy.boot.EnableSniffy; +import io.sniffy.registry.ConnectionsRegistry; import org.apache.kerby.kerberos.kerb.server.SimpleKdcServer; import org.junit.After; import org.junit.Test; @@ -93,6 +95,50 @@ public void testSpnego() throws Exception { assertThat(response, is("home")); } + @Test + public void testServerRequests() throws Exception { + + SimpleKdcServer kdc = getKdc(); + File workDir = getWorkDir(); + String host = InetAddress.getLocalHost().getCanonicalHostName().toLowerCase(); + + String serverPrincipal = "HTTP/" + host; + File serverKeytab = new File(workDir, "server.keytab"); + kdc.createAndExportPrincipals(serverKeytab, serverPrincipal); + + String clientPrincipal = "client/" + host; + File clientKeytab = new File(workDir, "client.keytab"); + kdc.createAndExportPrincipals(clientKeytab, clientPrincipal); + + + context = SpringApplication.run(new Object[] { WebSecurityConfig.class, VanillaWebConfiguration.class, + WebConfiguration.class }, new String[] { "--security.basic.enabled=true", + "--security.user.name=username", "--security.user.password=password", + "--serverPrincipal=" + serverPrincipal, "--serverKeytab=" + serverKeytab.getAbsolutePath() }); + + PortInitListener portInitListener = context.getBean(PortInitListener.class); + assertThat(portInitListener.latch.await(10, TimeUnit.SECONDS), is(true)); + int port = portInitListener.port; + + SpnegoRestTemplate spnegoRestTemplate = new SpnegoRestTemplate(SpnegoClient.loginWithKeyTab(clientPrincipal, clientKeytab.getAbsolutePath())); + RestTemplate restTemplate = new RestTemplate(); + + { + String response = spnegoRestTemplate.getForObject("http://" + host + ":" + port + "/hello", String.class); + assertThat(response, is("home")); + } + + System.out.println(restTemplate.getForObject("http://" + host + ":" + port + "/sniffy/3.1.6/connectionregistry/", String.class)); + restTemplate.postForEntity("http://" + host + ":" + port + "/sniffy/3.1.6/connectionregistry/socket/localhost/" + kdcPort, "-1", Object.class); + System.out.println(restTemplate.getForObject("http://" + host + ":" + port + "/sniffy/3.1.6/connectionregistry/", String.class)); + + ConnectionsRegistry.INSTANCE.setSocketAddressStatus("localhost", kdcPort, -1); + { + String response = spnegoRestTemplate.getForObject("http://" + host + ":" + port + "/hello", String.class); + assertThat(response, is("home")); + } + } + @Test public void testSpnegoWithPasswordOnServer() throws Exception { @@ -222,6 +268,7 @@ public TomcatEmbeddedServletContainerFactory tomcatEmbeddedServletContainerFacto @MinimalWebConfiguration @Import(SecurityAutoConfiguration.class) + @EnableSniffy @Controller protected static class WebConfiguration { diff --git a/kerb4j-server/kerb4j-server-tomcat/pom.xml b/kerb4j-server/kerb4j-server-tomcat/pom.xml index 04469b7..0231814 100644 --- a/kerb4j-server/kerb4j-server-tomcat/pom.xml +++ b/kerb4j-server/kerb4j-server-tomcat/pom.xml @@ -5,7 +5,7 @@ com.kerb4j kerb4j-server - 0.0.9 + 0.1.0-SNAPSHOT kerb4j-server-tomcat @@ -20,7 +20,7 @@ com.kerb4j kerb4j-server-common - 0.0.9 + 0.1.0-SNAPSHOT diff --git a/kerb4j-server/pom.xml b/kerb4j-server/pom.xml index 3b3d0c8..0d3ccf9 100644 --- a/kerb4j-server/pom.xml +++ b/kerb4j-server/pom.xml @@ -5,7 +5,7 @@ com.kerb4j kerb4j - 0.0.9 + 0.1.0-SNAPSHOT kerb4j-server @@ -23,7 +23,7 @@ com.kerb4j kerb4j-common - 0.0.9 + 0.1.0-SNAPSHOT @@ -36,13 +36,13 @@ com.kerb4j kerb4j-client - 0.0.9 + 0.1.0-SNAPSHOT test com.kerb4j kerb4j-common - 0.0.9 + 0.1.0-SNAPSHOT tests test diff --git a/pom.xml b/pom.xml index fadfc67..80fbd4d 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.kerb4j kerb4j - 0.0.9 + 0.1.0-SNAPSHOT pom @@ -236,7 +236,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 2.9.1 + 3.2.0 attach-javadocs