Skip to content
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

[ADD] Support for https redirect URIs (TLS) #41

Merged
merged 1 commit into from
Sep 8, 2024
Merged

Conversation

trembel
Copy link
Contributor

@trembel trembel commented Sep 6, 2024

This commit adds support for TLS-encrypted redirect URIs. The commit adds a second server for https:

  1. Binding a new TCP socket
  2. Uses rcgen to generate a new TLS certificate (only in memory)
  3. Uses rustls to do the TLS handshake and convert the TCPStream into a TLS stream
  4. Generalizes the request function (and its dependent) to accept an object implementing Read + Write instead of just TCPStream
  5. Redirects all redirect_uri that contain https to the https server

This last point I think can be discussed: Should all redirect uri's containing https be redirected to the https server or only the redirect uri's containing localhost? IMO it should not make a difference, as all https URIs will support TLS.

Also: the self-signed certificate is not trusted per default (at least on Firefox), so one has to go "Advanced" -> "Accept Risk ..." in Firefox when being redirected. For me this is no issue, if it is one, we could save the TLS certificate to the apropriate location(s) (requiring sudo).

I have not tested this commit across a http URI, just because I have no OAuth provider except of Microsoft (for hotmail). This commit solves #40.

src/server/http_server.rs Outdated Show resolved Hide resolved
src/server/http_server.rs Outdated Show resolved Hide resolved
src/server/http_server.rs Outdated Show resolved Hide resolved
src/config.rs Show resolved Hide resolved
src/config.rs Outdated Show resolved Hide resolved
@ltratt
Copy link
Owner

ltratt commented Sep 6, 2024

Thanks for this -- this looks really good!

@trembel
Copy link
Contributor Author

trembel commented Sep 6, 2024

Thanks for review, I will take care later today.

@ltratt
Copy link
Owner

ltratt commented Sep 7, 2024

This is excellent, thanks! I need to think a bit about if/where we store certificates, and so on, but that's a luxury add on: this PR does the hard bit.

@ltratt
Copy link
Owner

ltratt commented Sep 7, 2024

If you force push a rustfmt, I'll merge this.

This commit adds support for TLS-encrypted redirect URIs.
The commit adds a second server for https:
1. Binding a new TCP socket
2. Uses `rcgen` to generate a new TLS certificate (only in memory)
3. Uses `rustls` to do the TLS handshake and convert the TCPStream
into a TLS stream
4. Generalizes the `request` function (and its dependent) to accept an
object implementing `Read + Write` instead of just `TCPStream`
5. Redirects all `redirect_uri` that contain `https` to the https server

Signed-off-by: Silvano Cortesi <[email protected]>
@trembel
Copy link
Contributor Author

trembel commented Sep 8, 2024

Sure, thanks a lot for the quick process! rustfmt is pushed.

@ltratt
Copy link
Owner

ltratt commented Sep 8, 2024

Thanks!

@ltratt ltratt merged commit ca2379c into ltratt:master Sep 8, 2024
5 checks passed
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