-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Honor play settings on AkkaHttpServer for client auth in SSL #8642
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
Honor play settings on AkkaHttpServer for client auth in SSL #8642
Conversation
|
I marked it as |
Buy contact lenses. |
dwijnand
left a comment
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.
Looks reasonable to me!
| val sslContext = mockSslContext() | ||
| ConnectionContext.https(sslContext = sslContext) | ||
|
|
||
| val playServerConfig = context.config.configuration.get[Configuration]("play.server") |
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.
Since we made parserSettings and createServerSettings overridable, we should make the same here. I think that what we have for parserSettings (lazy val and create method) is what we should do here.
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.
parserSettings is not a lazy val
| val sslContext = mockSslContext() | ||
| ConnectionContext.https(sslContext = sslContext) | ||
|
|
||
| val playServerConfig = context.config.configuration.get[Configuration]("play.server") |
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.
There is a serverConfig you can reuse here.
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.
Good call. Missed that.
|
|
||
| val playServerConfig = context.config.configuration.get[Configuration]("play.server") | ||
| val clientAuth: Option[TLSClientAuth] = | ||
| if (playServerConfig.get[Boolean]("https.needClientAuth")) { |
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.
Maybe add a comment saying that need has a precedence over want?
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.
TBH, I'm not entirely sure what is the precedence. The Java API for SSLEngine only indicates that invoking both setNeedClientAuth and setWantClientAuth override each other so last wins. Using an ADT is better but forces us to choose. The implementation in NettyServer also gives need precedence over want (https://github.com/playframework/playframework/blob/master/framework/src/play-netty-server/src/main/scala/play/core/server/NettyServer.scala#L170-L175)
https://docs.oracle.com/javase/8/docs/api/javax/net/ssl/SSLEngine.html#setNeedClientAuth-boolean-
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.
Intuitively, in English, need has precedence over want. I need oxygen. I want gelato.
puts contact lenses on top of glasses |
|
We discussed two choices to test this:
|
try putting it behind |
…8774) `AkkaHttpServer` didn't honour some HTTPS-related settings: ```` play { server { # HTTPS configuration https { # Whether JSSE want client auth mode should be used. This means, the server # will request a client certificate, but won't fail if one isn't provided. wantClientAuth = false # Whether JSSE need client auth mode should be used. This means, the server # will request a client certificate, and will fail and terminate the session # if one isn't provided. needClientAuth = false } } } ```
Fixes
AkkaHttpServerdidn't honour some HTTPS-related settings: