Skip to content
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
88 changes: 16 additions & 72 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,82 +8,26 @@ plugins {
group = "org.clevercastle"
version = "0.0.1-SNAPSHOT"

repositories {
mavenCentral()
}

dependencies {
implementation("com.fasterxml.jackson.core:jackson-databind:2.18.3")
implementation("com.fasterxml.jackson.core:jackson-core:2.18.3")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.3")

implementation("jakarta.annotation:jakarta.annotation-api:3.0.0")
implementation("javax.persistence:javax.persistence-api:2.2")
implementation("jakarta.persistence:jakarta.persistence-api:3.2.0")
implementation("com.auth0:java-jwt:4.5.0")

implementation("com.nimbusds:oauth2-oidc-sdk:11.23.1")

implementation("software.amazon.awssdk:dynamodb:2.31.31")
implementation("software.amazon.awssdk:dynamodb-enhanced:2.31.31")

compileOnly("org.springframework.boot:spring-boot-starter-data-jpa:2.7.18")

implementation("org.apache.commons:commons-lang3:3.17.0")
implementation("org.slf4j:slf4j-api:2.0.17")

testImplementation(platform("org.junit:junit-bom:5.10.0"))
testImplementation("org.junit.jupiter:junit-jupiter")
testImplementation("org.mockito:mockito-core:5.17.0")
testImplementation("ch.qos.logback:logback-classic:1.5.18")
}

tasks.jacocoTestReport {
reports {
xml.required = true
xml.outputLocation = layout.buildDirectory.file("jacoco/jacocoTestReport.xml")
subprojects {
repositories {
mavenCentral()
}
apply {
plugin("java")
plugin("jacoco")
plugin("com.vanniktech.maven.publish")
plugin("signing")
}
}

tasks.test {
useJUnitPlatform()
finalizedBy(tasks.jacocoTestReport)
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
}

tasks.withType<JavaCompile>().configureEach {
options.release.set(11)
tasks.withType<JavaCompile>().configureEach {
options.release.set(11)
}
}

mavenPublishing {
pom {
name.set("auth-forge")
description.set("A description of what my library does.")
inceptionYear.set("2025")
url.set("https://github.com/clevercastle/auth-forge/")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("ivyxjc")
name.set("ivyxjc")
url.set("https://github.com/ivyxjc/")
}
}
scm {
url.set("https://github.com/clevercastle/auth-forge/")
connection.set("scm:git:git://github.com/clevercastle/auth-forge.git")
developerConnection.set("scm:git:ssh://git@github.com/clevercastle/auth-forge.git")
}
}
}
76 changes: 76 additions & 0 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
dependencies {
implementation("com.fasterxml.jackson.core:jackson-databind:2.18.3")
implementation("com.fasterxml.jackson.core:jackson-core:2.18.3")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.3")

implementation("jakarta.annotation:jakarta.annotation-api:3.0.0")
implementation("javax.persistence:javax.persistence-api:2.2")
implementation("jakarta.persistence:jakarta.persistence-api:3.2.0")
implementation("com.auth0:java-jwt:4.5.0")

implementation("com.nimbusds:oauth2-oidc-sdk:11.23.1")

implementation("software.amazon.awssdk:dynamodb:2.31.31")
implementation("software.amazon.awssdk:dynamodb-enhanced:2.31.31")

compileOnly("org.springframework.boot:spring-boot-starter-data-jpa:2.7.18")

implementation("org.apache.commons:commons-lang3:3.18.0")
implementation("commons-codec:commons-codec:1.15")
implementation("org.slf4j:slf4j-api:2.0.17")

testImplementation(platform("org.junit:junit-bom:5.10.0"))
testImplementation("org.junit.jupiter:junit-jupiter")
testImplementation("org.mockito:mockito-core:5.17.0")
testImplementation("ch.qos.logback:logback-classic:1.5.18")
}

tasks.jacocoTestReport {
reports {
xml.required = true
xml.outputLocation = layout.buildDirectory.file("jacoco/jacocoTestReport.xml")
}
}

tasks.test {
useJUnitPlatform()
finalizedBy(tasks.jacocoTestReport)
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}

tasks.withType<JavaCompile>().configureEach {
options.release.set(11)
}

mavenPublishing {
pom {
name.set("auth-forge")
description.set("A description of what my library does.")
inceptionYear.set("2025")
url.set("https://github.com/clevercastle/auth-forge/")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("ivyxjc")
name.set("ivyxjc")
url.set("https://github.com/ivyxjc/")
}
}
scm {
url.set("https://github.com/clevercastle/auth-forge/")
connection.set("scm:git:git://github.com/clevercastle/auth-forge.git")
developerConnection.set("scm:git:ssh://git@github.com/clevercastle/auth-forge.git")
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.clevercastle.authforge;
package org.clevercastle.authforge.core;

public interface CacheService {
void set(String key, String value, long ttl);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.clevercastle.authforge;
package org.clevercastle.authforge.core;

public class Config {
// in second
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.clevercastle.authforge;
package org.clevercastle.authforge.core;

import org.apache.commons.lang3.StringUtils;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.clevercastle.authforge;
package org.clevercastle.authforge.core;

import jakarta.annotation.Nonnull;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.clevercastle.authforge;
package org.clevercastle.authforge.core;

import java.time.OffsetDateTime;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.clevercastle.authforge;
package org.clevercastle.authforge.core;

public class UserRegisterRequest {
private String loginIdentifier;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
package org.clevercastle.authforge;
package org.clevercastle.authforge.core;

import org.apache.commons.lang3.tuple.Pair;
import org.clevercastle.authforge.dto.OneTimePasswordDto;
import org.clevercastle.authforge.exception.CastleException;
import org.clevercastle.authforge.model.ChallengeSession;
import org.clevercastle.authforge.model.User;
import org.clevercastle.authforge.model.UserLoginItem;
import org.clevercastle.authforge.oauth2.Oauth2ClientConfig;
import org.clevercastle.authforge.totp.RequestTotpResponse;
import org.clevercastle.authforge.totp.SetupTotpRequest;
import org.clevercastle.authforge.core.dto.OneTimePasswordDto;
import org.clevercastle.authforge.core.exception.CastleException;
import org.clevercastle.authforge.core.mfa.dto.MfaChallengeResponse;
import org.clevercastle.authforge.core.mfa.dto.MfaFactorResponse;
import org.clevercastle.authforge.core.model.ChallengeSession;
import org.clevercastle.authforge.core.model.User;
import org.clevercastle.authforge.core.model.UserLoginItem;
import org.clevercastle.authforge.core.oauth2.Oauth2ClientConfig;
import org.clevercastle.authforge.core.totp.RequestTotpResponse;
import org.clevercastle.authforge.core.totp.SetupTotpRequest;

import java.util.List;

public interface UserService {
// used for username/password, email/password, mobile/password
Expand Down Expand Up @@ -41,4 +45,15 @@ public interface UserService {

// setup mfa
void setupTotp(User user, SetupTotpRequest request) throws CastleException;

// MFA challenge and verification methods
MfaChallengeResponse createMfaChallenge(User user, String challengeType, String factorId) throws CastleException;

boolean verifyMfaChallenge(String challengeId, String code, String bindingCode) throws CastleException;

List<MfaFactorResponse> listMfaFactors(String userId) throws CastleException;

void deleteMfaFactor(String userId, String factorId) throws CastleException;

boolean verifyTotpCode(String userId, String code) throws CastleException;
}
Loading
Loading