Skip to content

Commit

Permalink
Refactor authentication flow and enhance events handling
Browse files Browse the repository at this point in the history
- **SupabaseAutoConfiguration.kt**:
  - Added `SupabaseJwtVerifier` bean import and `ApplicationEventPublisher` bean injection.
  - Updated `supabaseJwtVerifier` bean to return `SupabaseJwtVerifier`.
  - Injected `applicationEventPublisher` in `SupabaseUserService`.

- **SupabaseUserServiceGoTrueImpl.kt**:
  - Added new event classes for user events.
  - Refactored `loginWithEmail` to use `authenticateWithCurrentSession`.
  - Added methods for anonymous sign-in and linking anonymous to identity.
  - Implemented `authenticateWithCurrentSession` and `authenticate` methods.

- **SupabaseUserService.kt**:
  - Renamed `authorizeWithJwtOrResetPassword` to `handleClientAuthentication`.
  - Added methods for anonymous sign-in, linking anonymous to identity, and authentication.

- **SupabaseUser.kt**:
  - Updated to parse JWT and handle user metadata, roles, and provider.

- **ExampleWebController.kt**:
  - Removed unused `dataSource` and `jdbc` method.

- **SupabaseJwtFilter.kt**:
  - Removed direct authentication logic and delegated to `SupabaseUserService`.

- **SupabaseSecurityConfig.kt**:
  - Updated `supabaseAuthenticationProvider` to use `SupabaseJwtVerifier`.
  - Modified `supabaseJwtFilter` to inject `SupabaseUserService`.

- **SupabaseAuthenticationProvider.kt**:
  - Updated to use `SupabaseJwtVerifier` for authentication.

- **SupabaseAuthenticationEntryPoint.kt**:
  - Added handling for `HX-Request` header to redirect unauthenticated requests.

- **Templates**:
  - Updated Thymeleaf template syntax for script blocks.
  - Added `hx-target` for response element in `updatePassword.html`.
  • Loading branch information
tschuehly committed Aug 23, 2024
1 parent 53ceb13 commit 5b153e2
Show file tree
Hide file tree
Showing 39 changed files with 1,372 additions and 155 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Publish package to the Maven Central Repository
on:
push:
branches:
- '**-SNAPSHOT'
- '**SNAPSHOT'
tags:
- v*
jobs:
Expand Down
41 changes: 21 additions & 20 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jreleaser.model.Active

plugins {
id("org.springframework.boot") version "3.2.2"
id("io.spring.dependency-management") version "1.1.4"
kotlin("jvm") version "1.9.22"
kotlin("plugin.spring") version "1.9.22"
kotlin("plugin.jpa") version "1.9.22"
id("org.springframework.boot") version "3.3.1"
id("io.spring.dependency-management") version "1.1.5"
kotlin("jvm") version "2.0.0"
kotlin("plugin.spring") version "2.0.0"

id("maven-publish")
id("org.jreleaser") version "1.13.0"
id("org.jreleaser") version "1.13.1"
id("signing")
}

group = "de.tschuehly"
version = "0.3.5-RC1"
java.sourceCompatibility = JavaVersion.VERSION_17
version = "0.3.6-SNAPSHOT"
java {
toolchain {
languageVersion = JavaLanguageVersion.of(22)
}
}

repositories {
mavenCentral()
maven("https://jitpack.io")
}

dependencies {
Expand All @@ -32,8 +34,8 @@ dependencies {
implementation("org.springframework.boot:spring-boot-autoconfigure")
implementation("org.springframework:spring-context-support")

implementation("jakarta.annotation:jakarta.annotation-api:2.1.1")
implementation("com.auth0:java-jwt:4.3.0")
implementation("jakarta.annotation:jakarta.annotation-api:3.0.0")
implementation("com.auth0:java-jwt:4.4.0")

implementation("io.github.jan-tennert.supabase:gotrue-kt:2.6.0")
runtimeOnly("io.ktor:ktor-client-java:2.3.12")
Expand All @@ -45,14 +47,13 @@ dependencies {
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")


implementation("io.github.wimdeblauwe:htmx-spring-boot:3.4.1")

annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")

runtimeOnly("org.postgresql:postgresql")

testImplementation("org.htmlunit:htmlunit:3.9.0")
testImplementation("org.htmlunit:htmlunit:4.2.0")
testImplementation("org.thymeleaf.extras:thymeleaf-extras-springsecurity6")
testImplementation("org.springframework.boot:spring-boot-starter-thymeleaf")
testImplementation("org.springframework.boot:spring-boot-starter-test")
Expand All @@ -62,17 +63,17 @@ dependencies {

}

tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "17"

kotlin {
compilerOptions {
freeCompilerArgs.addAll("-Xjsr305=strict")
}
}

tasks.withType<Test> {
useJUnitPlatform()
}


tasks {
bootJar {
enabled = false
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Empty file modified gradlew
100644 → 100755
Empty file.
Loading

0 comments on commit 5b153e2

Please sign in to comment.