Skip to content

feat: EXPOSED-1049 Support hashing algorithms for the Crypt module - #2876

Open
obabichevjb wants to merge 2 commits into
mainfrom
obabichev/exposed-1049-hashing-algorithms
Open

feat: EXPOSED-1049 Support hashing algorithms for the Crypt module#2876
obabichevjb wants to merge 2 commits into
mainfrom
obabichev/exposed-1049-hashing-algorithms

Conversation

@obabichevjb

Copy link
Copy Markdown
Collaborator

Description

Summary of the change: Adds one-way hashing to exposed-crypt, so that values such as passwords can be
stored as salted hashes in a column instead of being encrypted and decrypted.

Detailed description:

  • What: a new set of public types in org.jetbrains.exposed.v1.crypt:

    Type Purpose
    Hasher Interface declaring hash(plainText): Hashed and matches(plainText, encodedValue)
    Hashed The value a hashed column holds; exposes encodedValue and matches(plainText)
    Column<String>.hashed(hasher) Turns a character column into a hashed one; nullable overload included
    BCryptHasher, Argon2Hasher, Pbkdf2Hasher, SCryptHasher The four OWASP-recommended algorithms
    Pbkdf2Algorithm Pseudorandom function for Pbkdf2Hasher: SHA1, SHA256, SHA512
    PasswordEncoderHasher Adapts any Spring Security PasswordEncoder to Hasher
    HashingTransformer, NullableHashingTransformer The ColumnTransformers behind hashed()
    val hasher = BCryptHasher()
    
    object Users : IntIdTable() {
        val password = text("password").hashed(hasher)
    }
    
    Users.insert { it[password] = hasher.hash("s3cret") }
    
    val user = Users.selectAll().where { Users.email eq email }.single()
    if (user[Users.password].matches(submittedPassword)) { /* ... */ }

Type of Change

Please mark the relevant options with an "X":

  • New feature

Affected databases:

  • All

Related Issues

@e5l Leonid Stashevsky (e5l) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, please check comments before merging

Comment thread exposed-crypt/src/main/kotlin/org/jetbrains/exposed/v1/crypt/Argon2Hasher.kt Outdated
Comment thread exposed-crypt/src/main/kotlin/org/jetbrains/exposed/v1/crypt/Tables.kt Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants