Skip to content

Commit

Permalink
Merge pull request kbase#433 from kbase/develop
Browse files Browse the repository at this point in the history
Develop -> Master (0.7.0 release)
  • Loading branch information
MrCreosote committed Mar 5, 2024
2 parents 0f8c064 + 910bad7 commit cdbecfd
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 28 deletions.
6 changes: 6 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Authentication Service MKII release notes

## 0.7.0

* BACKWARDS INCOMPATIBILITY - the auth server now logs to stdout vs. syslog.
* The the `fatTestJar` Gradle task has been replaced with the `shadowJar` task, which builds
a shadowed version of the test fat jar.

## 0.6.1

* Gradle has replaced Ant as the build tool. As a consequence, all the built artifacts
Expand Down
22 changes: 9 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ plugins {
id 'war'
id 'jacoco'
id 'org.ajoberstar.grgit' version '4.1.1'
id 'com.github.johnrengelman.shadow' version '8.1.1'
}

repositories {
Expand Down Expand Up @@ -94,28 +95,24 @@ task generateTemplateFileList {
}
}


task fatTestJar(type: Jar) {
shadowJar {
// Be careful when updating jars - you may want to set the duplicates strategy to WARN
// to see if any of the jars are shadowing the others when building the fat jar, which
// has been the case in the past
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
dependsOn generateTemplateFileList
archiveAppendix = 'test-fat'

// include source files
archiveAppendix = 'test-shadow'
from sourceSets.test.output
configurations = [project.configurations.testRuntimeClasspath]

// include all jars
from {
configurations.testimpl.collect { it.isDirectory() ? it : zipTree(it) }
}

enableRelocation true
relocationPrefix 'us.kbase.auth2.shadow'

mergeServiceFiles()
// Include text files from the "templates" directory
from('templates') { into JAR_TEMPLATE_DIR }
from("$buildDir/" + TEMPLATE_LIST_FILE_NAME) { into JAR_TEMPLATE_DIR }

with jar
}

task generateManageAuthScript {
Expand Down Expand Up @@ -217,7 +214,6 @@ dependencies {
'syslog4j-0.9.46'
)
// needed for syslog4j
implementation 'net.java.dev.jna:jna:3.4.0'
implementation 'joda-time:joda-time:2.3'

// ### Test ###
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/us/kbase/auth2/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
public class Version {

/** The version of the KBase Auth2 service. */
public static final String VERSION = "0.6.1";
public static final String VERSION = "0.7.0";

}
53 changes: 43 additions & 10 deletions src/main/java/us/kbase/auth2/kbase/KBaseAuthConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Path;
Expand All @@ -15,6 +16,7 @@
import java.util.regex.Pattern;

import org.ini4j.Ini;
import org.productivity.java.syslog4j.SyslogIF;
import org.slf4j.LoggerFactory;

import us.kbase.auth2.lib.identity.IdentityProviderConfig;
Expand All @@ -25,6 +27,7 @@
import us.kbase.auth2.service.exceptions.AuthConfigurationException;
import us.kbase.common.service.JsonServerSyslog;
import us.kbase.common.service.JsonServerSyslog.RpcInfo;
import us.kbase.common.service.JsonServerSyslog.SyslogOutput;

public class KBaseAuthConfig implements AuthStartupConfig {

Expand Down Expand Up @@ -85,16 +88,8 @@ public KBaseAuthConfig() throws AuthConfigurationException {
public KBaseAuthConfig(final Path filepath, final boolean nullLogger)
throws AuthConfigurationException {
final Map<String, String> cfg = getConfig(filepath);
final String ln = getString(KEY_LOG_NAME, cfg);
if (nullLogger) {
logger = new NullLogger();
} else {
logger = new JsonServerSysLogAutoLogger(new JsonServerSyslog(
ln == null ? DEFAULT_LOG_NAME : ln,
//TODO KBASECOMMON allow null for the fake config prop arg
"thisisafakekeythatshouldntexistihope",
JsonServerSyslog.LOG_LEVEL_INFO, true));
}
final String logname = getString(KEY_LOG_NAME, cfg);
logger = nullLogger ? new NullLogger() : buildLogger(logname);
try {
isTestModeEnabled = TRUE.equals(getString(KEY_TEST_MODE_ENABLED, cfg));
templateDir = Paths.get(getString(KEY_TEMPLATE_DIR, cfg, true));
Expand Down Expand Up @@ -125,6 +120,44 @@ public KBaseAuthConfig(final Path filepath, final boolean nullLogger)
}
}

private SLF4JAutoLogger buildLogger(final String logname) {
// Warning - this code is tested manually. Ensure
// logs are making it to stdout after changing
// TODO LOGGING just remove JsonServerSyslog altogether
// and get rid of Syslog4j. Not sure how much work this'd be
JsonServerSyslog.setStaticUseSyslog(false);
final JsonServerSyslog jssl = new JsonServerSyslog(
logname == null ? DEFAULT_LOG_NAME : logname,
null,
JsonServerSyslog.LOG_LEVEL_INFO,
true
);
jssl.changeOutput(new SyslogOutput() {

@Override
public void logToSystem(
final SyslogIF log,
final int level,
final String message) {
System.out.println(String.format(
"[Auth2] Lvl: %s Message: %s", level, message));
}

@Override
public PrintWriter logToFile(
final File f,
final PrintWriter pw,
final int level,
final String message) {
System.out.println(
"log to file called - this is not supported and not expected");
return null;
}

});
return new JsonServerSysLogAutoLogger(jssl);
}

private static final String INVALID_CHARS_REGEX = "[^A-Z-]+";
private static final Pattern INVALID_CHARS = Pattern.compile(INVALID_CHARS_REGEX);

Expand Down
8 changes: 5 additions & 3 deletions src/test/java/us/kbase/test/auth2/TestConfigurator.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,13 @@ private static class TestLogger implements SLF4JAutoLogger {
private final JsonServerSyslog logger;

public TestLogger() {
JsonServerSyslog.setStaticUseSyslog(false);
logger = new JsonServerSyslog(
"AuthTestLogger",
//TODO CODE update kbase-common and pass null instead
"thisisafakekeythatshouldntexistihope",
JsonServerSyslog.LOG_LEVEL_INFO, true);
null,
JsonServerSyslog.LOG_LEVEL_INFO,
true
);
logger.changeOutput(new SyslogOutput() {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
public class ServiceCommonTest {

public static final String SERVICE_NAME = "Authentication Service";
public static final String SERVER_VER = "0.6.1";
public static final String SERVER_VER = "0.7.0";
public static final String GIT_ERR =
"Missing git commit file gitcommit, should be in us.kbase.auth2";

Expand Down

0 comments on commit cdbecfd

Please sign in to comment.