Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
Delete validator from shared module
Browse files Browse the repository at this point in the history
hibernate-validator causes an error on android
  • Loading branch information
M3DZIK committed Jan 9, 2024
1 parent 291ae3d commit 619744a
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 36 deletions.
5 changes: 5 additions & 0 deletions server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@
<artifactId>bucket4j-core</artifactId>
<version>8.7.0</version>
</dependency>
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>8.0.1.Final</version>
</dependency>

<!-- Kotlin coroutines -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package dev.medzik.librepass.server.database

import dev.medzik.librepass.types.cipher.EncryptedCipher
import jakarta.persistence.*
import jakarta.validation.constraints.Max
import org.hibernate.annotations.CreationTimestamp
import org.hibernate.annotations.UpdateTimestamp
import java.util.*
Expand All @@ -14,6 +15,7 @@ data class CipherTable(
val owner: UUID,
val type: Int,
@Column(columnDefinition = "TEXT")
@Max(5000)
val data: String,
val favorite: Boolean = false,
val collection: UUID? = null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dev.medzik.librepass.server.database

import jakarta.persistence.*
import jakarta.validation.constraints.Max
import org.hibernate.annotations.CreationTimestamp
import org.hibernate.annotations.UpdateTimestamp
import java.util.*
Expand All @@ -11,6 +12,7 @@ data class CollectionTable(
@Id
val id: UUID = UUID.randomUUID(),
val owner: UUID,
@Max(32)
val name: String,
@CreationTimestamp
@Temporal(TemporalType.TIMESTAMP)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package dev.medzik.librepass.server.database

import jakarta.persistence.*
import jakarta.validation.constraints.Email
import jakarta.validation.constraints.Max
import org.hibernate.annotations.CreationTimestamp
import org.hibernate.validator.constraints.Range
import java.util.*

@Entity
Expand All @@ -10,20 +13,26 @@ data class UserTable(
@Id
val id: UUID = UUID.randomUUID(),
@Column(unique = true, columnDefinition = "TEXT")
@Email
val email: String,
val emailVerified: Boolean = false,
val emailVerificationCode: String? = null,
val emailVerificationCodeExpiresAt: Date? = null,
// Argon2id parameters
@Range(min = 1, max = 10)
val parallelism: Int,
@Range(min = 20 * 1024, max = 150 * 1024)
val memory: Int,
@Range(min = 1, max = 10)
val iterations: Int,
// X25519 public key
val publicKey: String,
@Column(columnDefinition = "TEXT")
@Max(100)
val passwordHint: String? = null,
val publicKey: String,
// 2FA
val twoFactorEnabled: Boolean = false,
@Max(32)
val twoFactorSecret: String? = null,
val twoFactorRecoveryCode: String? = null,
@CreationTimestamp
Expand Down
8 changes: 0 additions & 8 deletions shared/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,4 @@
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
</build>

<dependencies>
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>8.0.1.Final</version>
</dependency>
</dependencies>
</project>
2 changes: 0 additions & 2 deletions shared/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
requires kotlin.stdlib;
requires org.apache.commons.codec;
requires otp.java;
requires jakarta.validation;
requires org.hibernate.validator;

exports dev.medzik.librepass.responses;

Expand Down
9 changes: 0 additions & 9 deletions shared/src/main/kotlin/dev/medzik/librepass/types/api/Auth.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package dev.medzik.librepass.types.api

import dev.medzik.libcrypto.Argon2
import jakarta.validation.constraints.Email
import jakarta.validation.constraints.Max
import org.hibernate.validator.constraints.Range
import java.util.*

/**
Expand All @@ -18,16 +15,11 @@ import java.util.*
* @property publicKey The X25519 public key.
*/
data class RegisterRequest(
@Email
val email: String,
@Max(100)
val passwordHint: String? = null,
val sharedKey: String,
@Range(min = 1, max = 10)
val parallelism: Int,
@Range(min = 20 * 1024, max = 150 * 1024)
val memory: Int,
@Range(min = 1, max = 10)
val iterations: Int,
val publicKey: String
)
Expand Down Expand Up @@ -64,7 +56,6 @@ data class PreLoginResponse(
* @property sharedKey The shared key with server, used for authentication.
*/
data class LoginRequest(
@Email
val email: String,
val sharedKey: String
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package dev.medzik.librepass.types.api

import com.google.gson.annotations.JsonAdapter
import dev.medzik.librepass.types.adapters.DateAdapter
import jakarta.validation.constraints.Max
import java.util.*

/** Response from the API contains the Collection ID. */
Expand All @@ -18,7 +17,6 @@ data class CollectionIdResponse(
*/
data class CreateCollectionRequest(
val id: UUID = UUID.randomUUID(),
@Max(32)
val name: String,
)

Expand Down
10 changes: 0 additions & 10 deletions shared/src/main/kotlin/dev/medzik/librepass/types/api/User.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package dev.medzik.librepass.types.api

import jakarta.validation.constraints.Email
import jakarta.validation.constraints.Max
import org.hibernate.validator.constraints.Range
import java.util.*

/**
Expand All @@ -13,7 +10,6 @@ import java.util.*
*/
data class ChangePasswordCipherData(
val id: UUID,
@Max(5000)
val data: String
)

Expand All @@ -27,7 +23,6 @@ data class ChangePasswordCipherData(
* @property ciphers The re-encrypted all ciphers because the key to encrypt it changed.
*/
data class ChangeEmailRequest(
@Email
val newEmail: String,
val oldSharedKey: String,
val newPublicKey: String,
Expand All @@ -49,15 +44,11 @@ data class ChangeEmailRequest(
*/
data class ChangePasswordRequest(
val oldSharedKey: String,
@Max(100)
val newPasswordHint: String?,
val newPublicKey: String,
val newSharedKey: String,
@Range(min = 1, max = 10)
val parallelism: Int,
@Range(min = 20 * 1024, max = 150 * 1024)
val memory: Int,
@Range(min = 1, max = 10)
val iterations: Int,
val ciphers: List<ChangePasswordCipherData>
)
Expand All @@ -71,7 +62,6 @@ data class ChangePasswordRequest(
*/
data class SetupTwoFactorRequest(
val sharedKey: String,
@Max(32)
val secret: String,
val code: String
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import com.google.gson.Gson
import com.google.gson.annotations.JsonAdapter
import dev.medzik.libcrypto.Aes
import dev.medzik.librepass.types.adapters.DateAdapter
import jakarta.validation.constraints.Max
import org.hibernate.validator.constraints.Range
import java.util.*

/**
Expand All @@ -27,12 +25,10 @@ data class EncryptedCipher(
val id: UUID,
val owner: UUID,
val type: Int = CipherType.Login.ordinal,
@Max(5000)
val protectedData: String,
val collection: UUID? = null,
val favorite: Boolean = false,
val rePrompt: Boolean = false,
@Range(min = 1, max = 1)
val version: Int = 1,
@JsonAdapter(DateAdapter::class)
val created: Date? = null,
Expand Down

0 comments on commit 619744a

Please sign in to comment.