Browse Source

Merge branch 'main' into sqlite

sqlite
Stephan Richter 3 months ago
parent
commit
b767d3ede9
  1. 43
      Readme.md
  2. 2
      de.srsoftware.oidc.api/build.gradle
  3. 6
      de.srsoftware.oidc.app/build.gradle
  4. 76
      de.srsoftware.oidc.app/src/main/java/de/srsoftware/oidc/app/Application.java
  5. 6
      de.srsoftware.oidc.datastore.encrypted/build.gradle
  6. 4
      settings.gradle

43
Readme.md

@ -1,20 +1,51 @@ @@ -1,20 +1,51 @@
# LightOIDC
This aims to be a [specification] compliant OpenID connect provider with minimal footprint.
<table>
<tr>
<th>Deutsch</th>
<th>English</th>
</tr>
<tr>
<td>
LightOIDC ist ein [Spezifikations][specification]-treuer OpenID-Connect-Provider mit minimalem Fußabdruck.
Dieses Ziel wird durch Minimierung der externen Abhängigkeiten auf ein absolutes Minimum erreicht.
Im Moment baut das Projekt nur auf die folgenden Laufzeit-Bibliotheken auf:
This goal is achieved by reducing external library dependiencies to an absolute minimum.
* [org.json:json](https://github.com/douglascrockford/JSON-java)
* [org.bitbucket.b_c:jose4j](https://bitbucket.org/b_c/jose4j)
* [com.sun.mail:jakarta.mail](https://projects.eclipse.org/projects/ee4j.mail)
* [com.sun.activation:jakarta.activation](https://projects.eclipse.org/projects/ee4j.jaf)
Im Moment haben diese Bibliotheken keine weiteren (transitiven) Anhängigkeiten, so dass das Projekt nicht durch eine Kaskade von Libraries aufgeblasen wird.
Das Ermöglicht es, dass die compilierte JAR-Datei weniger als 1,5 MB groß ist!
## bauen
Currently, this project only depends on the following libraries:
Dies ist ein Gradle-Project. Um es zu compilieren brauchen Sie ein aktuelles Java-Development-Kit.
Das Projekt kann durch Aufruf von `./gradlew build` in einem Terminal innerhalb des Wurzelverzeichnisses gebaut werden.
</td><td>
This aims to be a [specification] compliant OpenID connect provider with minimal footprint.
This goal is achieved by reducing external library dependiencies to an absolute minimum.
Currently, this project only depends on the following runtime libraries:
* [org.json:json](https://github.com/douglascrockford/JSON-java)
* [org.bitbucket.b_c:jose4j](https://bitbucket.org/b_c/jose4j)
* [com.sun.mail:jakarta.mail](https://projects.eclipse.org/projects/ee4j.mail)
* [com.sun.activation:jakarta.activation](https://projects.eclipse.org/projects/ee4j.jaf)
At the time of writing, these libraries have no further transitive dependencies, this mitigating any bloat from the project.
At the time of writing, these libraries have no further transitive dependencies, thus mitigating any bloat from the project.
As a result, the compiled jar has a size of less than 1.5 MB!
## build
This is a gradle project. To compile it, you should have a recent version of a Java Development Kit installed.
This is a gradle project. To compile it, you should have a recent version of a Java Development Kit installed.
Build the project by launching `./gradlew build` in a terminal while being in the root folder of the project.
</td>
</tr>
</table>
[specification]: https://openid.net/specs/openid-connect-core-1_0.html

2
de.srsoftware.oidc.api/build.gradle

@ -11,10 +11,10 @@ repositories { @@ -11,10 +11,10 @@ repositories {
dependencies {
testImplementation platform('org.junit:junit-bom:5.10.0')
testImplementation 'org.junit.jupiter:junit-jupiter'
implementation project(':de.srsoftware.utils')
implementation 'org.json:json:20240303'
implementation 'org.bitbucket.b_c:jose4j:0.9.6'
implementation 'com.sun.mail:jakarta.mail:2.0.1'
implementation project(':de.srsoftware.utils')
}
test {

6
de.srsoftware.oidc.app/build.gradle

@ -17,11 +17,11 @@ dependencies { @@ -17,11 +17,11 @@ dependencies {
implementation project(':de.srsoftware.logging')
implementation project(':de.srsoftware.oidc.api')
implementation project(':de.srsoftware.oidc.backend')
implementation project(':de.srsoftware.oidc.web')
implementation project(':de.srsoftware.utils')
implementation project(':de.srsoftware.oidc.datastore.encrypted')
implementation project(':de.srsoftware.oidc.datastore.file')
implementation project(':de.srsoftware.oidc.datastore.sqlite')
implementation project(':de.srsoftware.oidc.web')
implementation project(':de.srsoftware.utils')
implementation 'org.json:json:20240303'
}
@ -46,4 +46,4 @@ jar { @@ -46,4 +46,4 @@ jar {
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
}
}

76
de.srsoftware.oidc.app/src/main/java/de/srsoftware/oidc/app/Application.java

@ -47,11 +47,11 @@ public class Application { @@ -47,11 +47,11 @@ public class Application {
public static final String ROOT = "/";
public static final String STATIC_PATH = "/web";
private static final String BASE_PATH = "basePath";
private static final String FAVICON = "/favicon.ico";
private static final String INDEX = STATIC_PATH + "/index.html";
private static final String WELL_KNOWN = "/.well-known";
private static System.Logger LOG = new ColorLogger("Application").setLogLevel(DEBUG);
private static final String BASE_PATH = "basePath";
private static final String FAVICON = "/favicon.ico";
private static final String INDEX = STATIC_PATH + "/index.html";
private static final String WELL_KNOWN = "/.well-known";
private static System.Logger LOG = new ColorLogger("Application").setLogLevel(DEBUG);
private static ConnectionProvider connectionProvider = new ConnectionProvider();
public static void main(String[] args) throws Exception {
@ -89,23 +89,23 @@ public class Application { @@ -89,23 +89,23 @@ public class Application {
}
private static ClientService setupClientService(Configuration config, Path defaultFile, FileStoreProvider fileStoreProvider) throws SQLException {
var clientStore = new File(config.getOrDefault("client_store", defaultFile));
var clientStore = new File(config.getOrDefault("client_store", defaultFile));
var clientService = switch (extension(clientStore)) {
case "db", "sqlite", "sqlite3" -> new SqliteClientService(connectionProvider.get(clientStore));
default -> fileStoreProvider.get(clientStore);
};
Optional<String> encryptionKey = config.get(ENCRYPTION_KEY);
Optional<String> encryptionKey = config.get(ENCRYPTION_KEY);
if (encryptionKey.isPresent()){
var salt = config.getOrDefault(SALT,uuid());
clientService = new EncryptedClientService(encryptionKey.get(),salt,clientService);
if (encryptionKey.isPresent()) {
var salt = config.getOrDefault(SALT, uuid());
clientService = new EncryptedClientService(encryptionKey.get(), salt, clientService);
}
return clientService;
}
private static AuthorizationService setupAuthService(Configuration config, Path defaultFile, FileStoreProvider fileStoreProvider) throws SQLException {
var authServiceLocation = new File(config.getOrDefault("auth_store",defaultFile));
var authServiceLocation = new File(config.getOrDefault("auth_store", defaultFile));
return switch (extension(authServiceLocation)){
case "db", "sqlite", "sqlite3" -> new SqliteAuthService(connectionProvider.get(authServiceLocation));
default -> fileStoreProvider.get(authServiceLocation);
@ -113,7 +113,7 @@ public class Application { @@ -113,7 +113,7 @@ public class Application {
}
private static SessionService setupSessionService(Configuration config, Path defaultFile, FileStoreProvider fileStoreProvider) throws SQLException {
var sessionStore = new File(config.getOrDefault("session_storage",defaultFile));
var sessionStore = new File(config.getOrDefault("session_storage", defaultFile));
return switch (extension(sessionStore)){
case "db", "sqlite", "sqlite3" -> new SqliteSessionService(connectionProvider.get(sessionStore));
default -> fileStoreProvider.get(sessionStore);
@ -121,33 +121,33 @@ public class Application { @@ -121,33 +121,33 @@ public class Application {
}
private static MailConfig setupMailConfig(Configuration config, Path defaultFile, FileStoreProvider fileStoreProvider) throws SQLException {
var mailConfigLocation = new File(config.getOrDefault("mail_config_storage",defaultFile));
var mailConfigLocation = new File(config.getOrDefault("mail_config_storage", defaultFile));
var mailConfig = switch (extension(mailConfigLocation)){
case "db", "sqlite", "sqlite3" -> new SqliteMailConfig(connectionProvider.get(mailConfigLocation));
default -> fileStoreProvider.get(mailConfigLocation);
};
Optional<String> encryptionKey = config.get(ENCRYPTION_KEY);
Optional<String> encryptionKey = config.get(ENCRYPTION_KEY);
if (encryptionKey.isPresent()){
var salt = config.getOrDefault(SALT,uuid());
mailConfig = new EncryptedMailConfig(mailConfig,encryptionKey.get(),salt);
if (encryptionKey.isPresent()) {
var salt = config.getOrDefault(SALT, uuid());
mailConfig = new EncryptedMailConfig(mailConfig, encryptionKey.get(), salt);
}
return mailConfig;
}
private static UserService setupUserService(Configuration config, Path defaultFile, FileStoreProvider fileStoreProvider, UuidHasher passHasher) throws SQLException {
var userStorageLocation = new File(config.getOrDefault("user_storage",defaultFile));
var userStorageLocation = new File(config.getOrDefault("user_storage", defaultFile));
var userService = switch (extension(userStorageLocation).toLowerCase()){
case "db", "sqlite", "sqlite3" -> new SqliteUserService(connectionProvider.get(userStorageLocation),passHasher);
default -> fileStoreProvider.get(userStorageLocation);
};
Optional<String> encryptionKey = config.get(ENCRYPTION_KEY);
Optional<String> encryptionKey = config.get(ENCRYPTION_KEY);
if (encryptionKey.isPresent()){
var salt = config.getOrDefault(SALT,uuid());
userService = new EncryptedUserService(userService,encryptionKey.get(),salt,passHasher);
if (encryptionKey.isPresent()) {
var salt = config.getOrDefault(SALT, uuid());
userService = new EncryptedUserService(userService, encryptionKey.get(), salt, passHasher);
}
return userService;
}
@ -162,11 +162,11 @@ public class Application { @@ -162,11 +162,11 @@ public class Application {
keyStore = new SqliteKeyStore(conn);
}
Optional<String> encryptionKey = config.get(ENCRYPTION_KEY);
Optional<String> encryptionKey = config.get(ENCRYPTION_KEY);
if (encryptionKey.isPresent()){
var salt = config.getOrDefault(SALT,uuid());
keyStore = new EncryptedKeyStore(encryptionKey.get(),salt,keyStore);
if (encryptionKey.isPresent()) {
var salt = config.getOrDefault(SALT, uuid());
keyStore = new EncryptedKeyStore(encryptionKey.get(), salt, keyStore);
}
return keyStore;
}
@ -183,18 +183,18 @@ public class Application { @@ -183,18 +183,18 @@ public class Application {
var token = tokens.remove(0);
switch (token) {
case "--base":
if (tokens.isEmpty()) throw new IllegalArgumentException("--base option requires second argument!");
map.put(BASE_PATH, Path.of(tokens.remove(0)));
break;
case "--config":
if (tokens.isEmpty()) throw new IllegalArgumentException("--config option requires second argument!");
map.put(CONFIG_PATH, Path.of(tokens.remove(0)));
break;
default:
LOG.log(ERROR, "Unknown option: {0}", token);
if (tokens.isEmpty()) throw new IllegalArgumentException("--base option requires second argument!");
map.put(BASE_PATH, Path.of(tokens.remove(0)));
break;
case "--config":
if (tokens.isEmpty()) throw new IllegalArgumentException("--config option requires second argument!");
map.put(CONFIG_PATH, Path.of(tokens.remove(0)));
break;
default:
LOG.log(ERROR, "Unknown option: {0}", token);
}
}
}
return map;
}
return map;
}
}

6
de.srsoftware.oidc.datastore.encrypted/build.gradle

@ -12,14 +12,14 @@ repositories { @@ -12,14 +12,14 @@ repositories {
dependencies {
testImplementation platform('org.junit:junit-bom:5.10.0')
testImplementation 'org.junit.jupiter:junit-jupiter'
testImplementation project(path: ':de.srsoftware.oidc.api', configuration: "testBundle")
implementation project(':de.srsoftware.oidc.api')
implementation 'com.sun.mail:jakarta.mail:2.0.1'
implementation project(':de.srsoftware.utils')
testImplementation project(path: ':de.srsoftware.oidc.api', configuration: "testBundle")
implementation 'com.sun.mail:jakarta.mail:2.0.1'
implementation 'org.bitbucket.b_c:jose4j:0.9.6'
}
test {
useJUnitPlatform()
}
}

4
settings.gradle

@ -4,9 +4,9 @@ include 'de.srsoftware.logging' @@ -4,9 +4,9 @@ include 'de.srsoftware.logging'
include 'de.srsoftware.oidc.api'
include 'de.srsoftware.oidc.app'
include 'de.srsoftware.oidc.backend'
include 'de.srsoftware.oidc.datastore.sqlite'
include 'de.srsoftware.oidc.datastore.encrypted'
include 'de.srsoftware.oidc.datastore.file'
include 'de.srsoftware.oidc.web'
include 'de.srsoftware.utils'
include 'de.srsoftware.oidc.datastore.sqlite'
include 'de.srsoftware.oidc.datastore.encrypted'

Loading…
Cancel
Save