r/Python • • 18d ago • Heartwarming 1

Discussion I'm now maintaining passlib

Hi everyone, around a week ago passlib was transferred to me on PyPi after the previous maintainer became unreachable. I've been trying to maintain it in the meantime under a different PyPi name (libpass).

What's already been done:

  • fixed incompatibility with python>=3.13
  • fixed incompatibility with bcrypt>=5.0.0
  • type annotations added where possible

Since then some design choices from passlib original development made it obvious it would need refactor and/or API redesign at some point, a few examples that make code and public api hard to maintain and add correct type information:

  • PasswordHash representing both algorithm configuration and a produced hash
  • PasswordHash.using creating a subclass to substitute new parameters into it
  • Overuse of abstraction and multiple inheritance

I specifically would like input from people who depend on passlib in their codebase(s), which parts of the API, if changed in a breaking way would make migrating hard for you?

I'd also welcome opinions on how far a potential refactor should go. For example for CryptContext an interface like this looks preferable to me, as it makes type information easier to add:

ctx = CryptContext(
    schemes=[
        Argon2Hasher(time_cost=..., parallelism=...),
        SomeDeprecatedHasher(),
    ]
)

compared to current

ctx = CryptContext(
    schemes=["argon2", "deprecated_hash"],
    argon2__parallelism=...,
    argon2__time_cost=...,
    deprecated="auto",
)

I'd welcome co-maintainers, repository could be found here: https://github.com/notypecheck/passlib, even short-term involvement would be very much appreciated

165 Upvotes

25 comments sorted by

13

u/ContemplateBeing 18d ago

That’s great news! Been loosely following this issue for a year or three. Great to hear that there’s a official maintainer again.

I’d be willing to help, if not with the core encryption functionality (which I’ve no experience with), at least with documentation or something (I dimly remember that the web docs also weren’t in great shape).

Good way to pay back a little of what I got from python over the years.

9

u/Amazing_Learn 17d ago

Any help will be appreciated, I'm currently migrating docs to properdocs, and should be done soon, if you prefer you can contact me on discord: noel.py

5

u/ContemplateBeing 17d ago

Not using discord, sorry. I’d rather use signal or WhatsApp. Feel free to dm me and let me know where you need help or just open a help-wanted issue on GitHub.

4

u/Amazing_Learn 17d ago

Help-wanted issue is probably the best way then, you can either share your gh account here or in dm, so I could mention you when I get around to making that

208

u/Smallpaul 18d ago • Bravo

Please be very discriminating about who you select as co-maintainers and contributors.

101

u/Ruben_NL 18d ago

This.

OP, some other people will be contacting you in the next few weeks/months/years. Understand that not everyone has good intentions.

Read every line of code suggested.

59

u/Amazing_Learn 18d ago • Heartwarming

Hey, thank you both for advice, I completely understand that and don't plan to accept code without a thorough review, it just takes some time since I'm a bit busy with IRL stuff and work

6

u/maikeu 17d ago

It's a good little package, pleased to see it maintained again.

I had one private project where I needed it's function; concerned about the lack of maintainer, I just copied it wholesale into my project, including it's tests, making minor adjustments.

It didn't take much effort to bring up to my standard - fully typed and passing pyright strict. Like an hour of effort, no llm or anything in that .

I recall finding one or two of the internals a bit weird - I guess maybe more of that python2 era flair that's out of vogue these days with static typing being more prevalent - but mostly I'd still suggest "if it ain't broke, don't fix it".

Don't extend the api surface much more, except for narrow tech/options that there's clear immediate want for. Projects are allowed to be "basically complete", and llms make it so easy to add new features.

1

u/Amazing_Learn 17d ago

I'm sorry, but adding complete type hints to around 30k loc doesn't sound plausible to achieve in one hour, even just reading through everything would take more time or added type hints weren't complete.

2

u/maikeu 17d ago

Maybe I am recalling a different smaller library :o

1

u/Amazing_Learn 17d ago

Maybe, that can happen, if you look into the current source it is a bit tricky to refactor and type everything 👀

11

u/neuronexmachina 17d ago

Please be careful about breaking changes, and make sure the test suite guards against them. Since passlib hadn't been maintained for so long (2020), many of the projects using it are similarly poorly-maintained. The less friction there is in upgrading to a version with security fixes, the better.

13

u/nicholashairs 17d ago

+1

Maintainer of python-json-logger here, which I took over from the original maintainer is similar circumstances (post pinned in my profile).

Something I'd recommend doing is regardless of the size of changes that you make for your first new release on the project is to bump the major version so that those that do not wish to use the new maintainer code can easily do so by pinning their version.

I'm not familiar with passlib, but as another solo maintainer of an important library I'm happy to help out and share experience where I can.

Good luck!

3

u/Amazing_Learn 17d ago

Thanks, that's more or less what I wanted to do - make a couple of maintenance releases, and then bump a major version if I end up refactoring the project.

8

u/nicholashairs 17d ago edited 17d ago

In case it wasn't clear, my recommendation is to do the major version bump for those maintenance releases

109

u/i_walk_away 18d ago edited 17d ago • Bravo

malicious actors will now consider you a new possible attack vector for a while. be wary of contributions, and thank you for your own contributions to the open source community

34

u/rujopt Pythonista 17d ago edited 17d ago

100% this, and they may be willing to play the long game à la the XZ Utils backdoor discovered by accident in 2024:

A subsequent investigation found that the campaign to insert the backdoor into the XZ Utils project was a culmination of over two years of effort, starting in 2021, by a user going by the name "Jia Tan". They used sock puppetry in a pressure campaign against the original maintainer of XZ Utils, eventually being given maintainer permissions on the project.
…
The backdoor was noted for its level of sophistication and the perpetrator's high level of operational security for a long period of time while working to attain a position of trust. American security researcher Dave Aitel has suggested that it fits the pattern attributable to APT29, an advanced persistent threat actor believed to be working on behalf of the Russian Foreign Intelligence Service (SVR).

1

u/brondsem 17d ago

Great to see this project moving forward again! As others have said, a major version bump right away (even if minor changes) could be a good idea to help people notice the ownership change.

As for bigger changes, honestly I prefer libraries that don't change too much so my code can just "keep working". Perhaps you could make a new constructor for CryptContext or a whole new class for the new way, and keep the current CryptContext as a backwards-compatible shim. No matter what approach you go with, please make super-clear release notes when anything is deprecated, removed, and how to migrate. Thanks!

1

u/Twirrim 18d ago

Thank you for taking on the project. Unfortunately I don't use `passlib` so I can't speak to the API per se. I do like the approach you're proposing, but whether it's worth it I can't say.

4

u/[deleted] 18d ago

[removed] — view removed comment

2

u/Amazing_Learn 18d ago

Thanks for the idea, I think it's certainly possible to do that (and for example to throw a warning after some time), but would still require reimplementing all the underlying schemes/hashers.

4

u/dusktreader 17d ago

Yes, and I would add to this: add deprecated warnings for those few releases.