-
-
Notifications
You must be signed in to change notification settings - Fork 83
Support for SCRAM-SHA-256 SASL authentication #89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ypes 10 (SASL mechanisms), 11 (SASL continue), and 12 (SASL final). Add more specific errors for types 2(Kerberos), 7(GSSAPI), 8(GSSAPI), 9(SSPI), and 6(obsolete SCM).
…generics) SASL mechanism implementations.
…56 and SCRAM-SHA-256-PLUS per RFC 7677 et al. Things that are still missing: Channel binding support (Postgres DOES use this), authorization names (Postgres does not use these), proper username and password normalization, RFC-compliant validation of nonces, and determining whether the Hi() function can be replaced with PBKDF2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This generally looks good to me. I think it's safe to assume you know what you're doing so I don't have to read the docs for the Postgres authentication protocol.
One question though, should there be tests for this?
@calebkleveter The Postgres-specific side of it is implicitly tested whenever the test suite is run against a database configured for
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huge +1 to this ❤️
Can we configure the DB image we use in CI to test this?
It could also be nice to add a psql-sasl
image to the docker-compose file:
For easy testing locally.
Sources/PostgresNIO/Connection/PostgresConnection+Authenticate.swift
Outdated
Show resolved
Hide resolved
Sources/PostgresNIO/Utilities/SASLAuthentication+SCRAM-SHA256.swift
Outdated
Show resolved
Hide resolved
Sources/PostgresNIO/Connection/PostgresConnection+Authenticate.swift
Outdated
Show resolved
Hide resolved
…a stray print, make the SASL stuff internal for now.
a832b1a
to
8a784dc
Compare
…bos disabled to cut down on the excessive number of checks generated by the test matrices (72 instead of 234).
8a784dc
to
2cf6b5a
Compare
@tanner0101 Test workflow has been updated to test all three auth methods (trust, MD5, SCRAM-SHA-256) for all supported PostgreSQL versions (and lots of Swift versions...), |
Thank you for implementing this! I was getting my dev environment set up on a new machine and sure enough, postgresql has started defaulting to scram-sha-256. That means it was rejecting any connections from postgres-nio. I'm happy to see the fix is ready to go! 🌟 For other people who might run into this, the error you'll get is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of commented code could be removed, but it's non-critical for sure. LGTM
These changes are now available in 1.4.2 |
SCRAM-SHA-256
authentication since version 11. This is preliminary support for that authentication type.