Skip to content

Add Argon2id for hashing - #25

Merged
essenciary merged 6 commits into
GenieFramework:masterfrom
andreeco:master
Aug 26, 2025
Merged

Add Argon2id for hashing#25
essenciary merged 6 commits into
GenieFramework:masterfrom
andreeco:master

Conversation

@andreeco

Copy link
Copy Markdown
Contributor

No description provided.

@essenciary

Copy link
Copy Markdown
Member

@andreeco thank you for the PR!

A couple of comments:
a) this is going to be a breaking change, as existing passwords stored with the current hashing function won't work anymore. How should we handle this? Should we include a migration tool from sha to argon?
b) the spacing around = is inconsistent. The standard we adopted in Genie is to favour whitespace for readability, so we use x = z, with spaces around =. Can you update please?
c) how is verify_password designed to be used as part of the public API?

@andreeco

andreeco commented Aug 13, 2025

Copy link
Copy Markdown
Contributor Author

a)
What about this?

function verify_password(stored::AbstractString, password::AbstractString)
    if startswith(stored, "\$argon2id\$")
        status = Sodium.crypto_pwhash_str_verify(
            Vector{UInt8}(stored), password, UInt64(sizeof(password))
        )
        return status == 0
    else
        return stored == sha256(password)
    end
end

b)
The whitespace was lost after applying the default Julia formatter in VS Code. It adds spaces around assignments but not around keyword arguments. I’ll see if I can change this, assuming it's reasonable to deviate from Julia’s standard style. But this is intentionally wanted, right?

{
    "workbench.colorTheme": "Default Light Modern",
    "terminal.integrated.commandsToSkipShell": [
        "\"editor.rulers\": [80]",
        "language-julia.interrupt"
    ],
    "julia.symbolCacheDownload": true,
    "workbench.secondarySideBar.defaultVisibility": "hidden",
    "julia.enableTelemetry": false,
    "editor.rulers": [
        80,
        100,
        120
    ],
    "julia.enableCrashReporter": false,
    "[julia]": {
        "editor.defaultFormatter": "julialang.language-julia"
    }
}

c) It's used in the AuthenticationController.

@essenciary

Copy link
Copy Markdown
Member

@andreeco Thanks for the updates.

a) yes, I think it makes sense. This should be an edge case really, like creating a new app but using an existing users table
b) yes, it's intentional. The Genie style is years older than Julia's "official" one. And given this, there's nothing worse than mixing different styles into a codebase (which basically amounts to no style guide at all). So for now we keep the style, unless there is an effort to migrate everything to a new style.
The issues being:

  • spacing around assignments (frankly I don't like the official guidelines here, this kind of thing is bad spacing: password=params(:password) |> hash_password),
  • explicit returns at end of functions - Genie's codebase doesn't use them (this makes things like returning html(...) nice and clean),
  • we use 2 spaces for indentation

I can edit these manually, it's not a lot. It would be great though to have a Genie linter/style guide, it's true!

@essenciary
essenciary merged commit de82832 into GenieFramework:master Aug 26, 2025
@essenciary

Copy link
Copy Markdown
Member

@andreeco Merged! Thanks so much for the contribution and your patience!

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