simonw/datasette-auth-passwords

hash stored in file adds a newline

Closed this issue · 3 comments

I'm trying to config the passwords from a file like so:

{
    "plugins": {
        "datasette-auth-passwords": {
            "someusername_password_hash": {
                "$file": "/path/to/secret"
            }
        }
    }
}

but the hash that ultimately gets populated from that file includes a '\n' newline character at the end and fails the verify_password check.

Is this my own issue or is there something I'm going incorrectly?

simonw commented

I'm going to teach this plugin to strip the newline, though this is likely a bug in Datasette itself.

simonw commented

I'm not sure why this would happen- here's the relevant code in Datasette:

https://github.com/simonw/datasette/blob/7dd671310a4358e74663325336583746413f0993/datasette/utils/__init__.py#L1039-L1040

        elif list(config.keys()) == ["$file"]:
            return open(list(config.values())[0]).read()

Thanks Simon!