Skip to content

Commit

Permalink
Merge pull request #26 from bedrin/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
bedrin authored Oct 23, 2020
2 parents c3e82f9 + 153523e commit 080ebfe
Show file tree
Hide file tree
Showing 17 changed files with 90 additions and 42 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -20,7 +20,7 @@ Kerb4J is available from Maven Central repo:
<dependency>
<groupId>com.kerb4j</groupId>
<artifactId>kerb4j-client</artifactId>
<version>0.0.9</version>
<version>0.1.0-SNAPSHOT</version>
</dependency>
```

Expand All @@ -29,7 +29,7 @@ Kerb4J is available from Maven Central repo:
<dependency>
<groupId>com.kerb4j</groupId>
<artifactId>kerb4j-server-spring-security</artifactId>
<version>0.0.9</version>
<version>0.1.0-SNAPSHOT</version>
</dependency>
```

Expand All @@ -38,7 +38,7 @@ Kerb4J is available from Maven Central repo:
<dependency>
<groupId>com.kerb4j</groupId>
<artifactId>kerb4j-server-tomcat</artifactId>
<version>0.0.9</version>
<version>0.1.0-SNAPSHOT</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion kerb4j-base64/kerb4j-base64-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>kerb4j-base64</artifactId>
<groupId>com.kerb4j</groupId>
<version>0.0.9</version>
<version>0.1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
5 changes: 3 additions & 2 deletions kerb4j-base64/kerb4j-base64-java7/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>kerb4j-base64</artifactId>
<groupId>com.kerb4j</groupId>
<version>0.0.9</version>
<version>0.1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -15,7 +15,7 @@
<dependency>
<groupId>com.kerb4j</groupId>
<artifactId>kerb4j-base64-common</artifactId>
<version>0.0.9</version>
<version>0.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
Expand All @@ -30,6 +30,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<source>7</source>
</configuration>
Expand Down
4 changes: 2 additions & 2 deletions kerb4j-base64/kerb4j-base64-java8/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>kerb4j-base64</artifactId>
<groupId>com.kerb4j</groupId>
<version>0.0.9</version>
<version>0.1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -15,7 +15,7 @@
<dependency>
<groupId>com.kerb4j</groupId>
<artifactId>kerb4j-base64-common</artifactId>
<version>0.0.9</version>
<version>0.1.0-SNAPSHOT</version>
</dependency>
</dependencies>

Expand Down
2 changes: 1 addition & 1 deletion kerb4j-base64/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>kerb4j</artifactId>
<groupId>com.kerb4j</groupId>
<version>0.0.9</version>
<version>0.1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
6 changes: 3 additions & 3 deletions kerb4j-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.kerb4j</groupId>
<artifactId>kerb4j</artifactId>
<version>0.0.9</version>
<version>0.1.0-SNAPSHOT</version>
</parent>

<artifactId>kerb4j-client</artifactId>
Expand All @@ -17,12 +17,12 @@
<dependency>
<groupId>com.kerb4j</groupId>
<artifactId>kerb4j-common</artifactId>
<version>0.0.9</version>
<version>0.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.kerb4j</groupId>
<artifactId>kerb4j-common</artifactId>
<version>0.0.9</version>
<version>0.1.0-SNAPSHOT</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
Expand Down
6 changes: 3 additions & 3 deletions kerb4j-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.kerb4j</groupId>
<artifactId>kerb4j</artifactId>
<version>0.0.9</version>
<version>0.1.0-SNAPSHOT</version>
</parent>

<artifactId>kerb4j-common</artifactId>
Expand All @@ -17,12 +17,12 @@
<dependency>
<groupId>com.kerb4j</groupId>
<artifactId>kerb4j-base64-java7</artifactId>
<version>0.0.9</version>
<version>0.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.kerb4j</groupId>
<artifactId>kerb4j-base64-java8</artifactId>
<version>0.0.9</version>
<version>0.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.kerby</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class KerberosSecurityTestcase {
private File workDir;
private KrbConfig conf;

private int kdcPort;
protected int kdcPort;

private static int i = 10000;

Expand Down
2 changes: 1 addition & 1 deletion kerb4j-server/kerb4j-server-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.kerb4j</groupId>
<artifactId>kerb4j-server</artifactId>
<version>0.0.9</version>
<version>0.1.0-SNAPSHOT</version>
</parent>

<artifactId>kerb4j-server-common</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions kerb4j-server/kerb4j-server-spring-security-ldap/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.kerb4j</groupId>
<artifactId>kerb4j-server</artifactId>
<version>0.0.9</version>
<version>0.1.0-SNAPSHOT</version>
</parent>

<artifactId>kerb4j-server-spring-security-ldap</artifactId>
Expand All @@ -19,7 +19,7 @@
<dependency>
<groupId>com.kerb4j</groupId>
<artifactId>kerb4j-server-spring-security</artifactId>
<version>0.0.9</version>
<version>0.1.0-SNAPSHOT</version>
</dependency>

<dependency>
Expand Down
6 changes: 3 additions & 3 deletions kerb4j-server/kerb4j-server-spring-security/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.kerb4j</groupId>
<artifactId>kerb4j-server</artifactId>
<version>0.0.9</version>
<version>0.1.0-SNAPSHOT</version>
</parent>

<artifactId>kerb4j-server-spring-security</artifactId>
Expand All @@ -19,7 +19,7 @@
<dependency>
<groupId>com.kerb4j</groupId>
<artifactId>kerb4j-server-common</artifactId>
<version>0.0.9</version>
<version>0.1.0-SNAPSHOT</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -49,7 +49,7 @@
<dependency>
<groupId>io.sniffy</groupId>
<artifactId>sniffy-web</artifactId>
<version>3.1.5</version>
<version>3.1.6</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {

Expand Down Expand Up @@ -222,6 +268,7 @@ public TomcatEmbeddedServletContainerFactory tomcatEmbeddedServletContainerFacto

@MinimalWebConfiguration
@Import(SecurityAutoConfiguration.class)
@EnableSniffy
@Controller
protected static class WebConfiguration {

Expand Down
4 changes: 2 additions & 2 deletions kerb4j-server/kerb4j-server-tomcat/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.kerb4j</groupId>
<artifactId>kerb4j-server</artifactId>
<version>0.0.9</version>
<version>0.1.0-SNAPSHOT</version>
</parent>

<artifactId>kerb4j-server-tomcat</artifactId>
Expand All @@ -20,7 +20,7 @@
<dependency>
<groupId>com.kerb4j</groupId>
<artifactId>kerb4j-server-common</artifactId>
<version>0.0.9</version>
<version>0.1.0-SNAPSHOT</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.apache.tomcat/tomcat-catalina -->
Expand Down
8 changes: 4 additions & 4 deletions kerb4j-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.kerb4j</groupId>
<artifactId>kerb4j</artifactId>
<version>0.0.9</version>
<version>0.1.0-SNAPSHOT</version>
</parent>

<artifactId>kerb4j-server</artifactId>
Expand All @@ -23,7 +23,7 @@
<dependency>
<groupId>com.kerb4j</groupId>
<artifactId>kerb4j-common</artifactId>
<version>0.0.9</version>
<version>0.1.0-SNAPSHOT</version>
</dependency>

<dependency>
Expand All @@ -36,13 +36,13 @@
<dependency>
<groupId>com.kerb4j</groupId>
<artifactId>kerb4j-client</artifactId>
<version>0.0.9</version>
<version>0.1.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.kerb4j</groupId>
<artifactId>kerb4j-common</artifactId>
<version>0.0.9</version>
<version>0.1.0-SNAPSHOT</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.kerb4j</groupId>
<artifactId>kerb4j</artifactId>
<version>0.0.9</version>
<version>0.1.0-SNAPSHOT</version>
<packaging>pom</packaging>

<modules>
Expand Down Expand Up @@ -236,7 +236,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<version>3.2.0</version>
<executions>
<execution>
<id>attach-javadocs</id>
Expand Down

0 comments on commit 080ebfe

Please sign in to comment.