Skip to content

Conversation

drcapulet
Copy link
Collaborator

Since the middleware isn't the one managing the TLS connection, we already have to rely on whatever is managing the TLS connection to verify & pass it down into the Rack environment safely. Verifying it in the middleware simply proves you know the cert (which are more or less public) and doesn't prove ownership of the underlying private key.

@drcapulet drcapulet force-pushed the alexc-x509-verify branch from 102964a to be5e85c Compare July 30, 2020 20:01
@drcapulet drcapulet requested a review from mbyczkowski July 30, 2020 20:07
Copy link
Contributor

@mbyczkowski mbyczkowski left a comment

Choose a reason for hiding this comment

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

Some comments about comments (meta!), but other than that LGTM.

At some point it would probably be useful to have a higher-level middleware that would capture and set the identity of the forwarded client (e.g. something like ForwardedIdentityMiddleware). Such middleware would not operate on certificates directly though, but client identities (like a slug or SPIFFE ID), and it would set it accordingly (e.g. credentials[:client]).

Either way, this seems like a good change for now. 👍

CHANGES.md Outdated
### Unreleased

* [#67](https://github.com/square/rails-auth/pull/67)
Remove `ca_file`, `require_cert`, and `truststore` options to X509 middleware.
Copy link
Contributor

Choose a reason for hiding this comment

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

we should probably add here that the X509 middleware will no longer attempt to verify a certificate chain.

# @param [Logger] logger place to log verification successes & failures
# @param [Boolean] require_cert causes middleware to raise if certs are unverified
# @param [OpenSSL::X509::Store] truststore (optional) provide your own truststore (for e.g. CRLs)
# @param [Object] app next app in the Rack middleware chain
Copy link
Contributor

Choose a reason for hiding this comment

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

I can't seem to add my review directly on line 9, but that comment is no longer true. It might be worth adding a bit of context that you've added to the PR description.

Copy link
Contributor

Choose a reason for hiding this comment

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

Similarly, I believe CertificateVerifyFailed (line 7) is unused now.

Copy link
Contributor

@mbyczkowski mbyczkowski left a comment

Choose a reason for hiding this comment

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

👍

@drcapulet drcapulet merged commit dfa8eea into master Aug 10, 2020
@drcapulet drcapulet deleted the alexc-x509-verify branch August 10, 2020 20:32
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