Repository navigation
Add Secure attribute to session cookie - #3902
Conversation
Secure attribute to session cookie
|
This seems like a good change.
I think we might want to do this? I don't know about other people but I definitely do run Omicron that way. We could also lean into making even dev setups use TLS, but that requires a more real DNS setup that's a little tricky. |
|
Ok, I'll add the check for the config value. I agree local TLS is too much, at least for right now. |
4f060d0 to
ff03418
Compare
| // browser expiration is mostly for convenience, as the API will | ||
| // reject requests with an expired session regardless | ||
| apictx.session_absolute_timeout(), | ||
| apictx.external_tls_enabled, |
There was a problem hiding this comment.
I thought about having session_cookie_header_value take the whole apictx, but then the unit tests become less trivial, and it's nice for unit tests to be trivial.
| /// registry of metric producers | ||
| pub producer_registry: ProducerRegistry, | ||
| /// TLS enabled on the external Dropshot server | ||
| pub external_tls_enabled: bool, |
There was a problem hiding this comment.
It feels a little sad to clutter up the context with another config value, but I wasn't sure whether I should get the answer from nexus itself because of the Arc around it. A method on nexus would have to look something like this. @davepacheco?
pub async fn external_tls_enabled(&self) -> bool {
let external_server = self.external_server.lock().unwrap().take();
if let Some(server) = external_server {
return server.using_tls();
}
false
}There was a problem hiding this comment.
I think it's okay as-is. One advantage of what's here over that method impl is that if someone asks the question before we've started the external server for some reason, it will report what's configured (which seems right) rather than panicking.
It seems like Dropshot could use a method on the RequestContext for this. Then you could just check that in the handler.
We had a TODO item in the code pointing to #249, but no dedicated issue. The
Secureattribute means the browser will only include the cookie with encrypted requests. This is a no-brainer table stakes kind of thing we must do. This was blocked on adding TLS to Nexus.We use
deployment.dropshot_external.tlsto decide whether to includeSecureso things will still work in non-TLS environments like local dev.Because the tests do not run in a browser, I think they should be indifferent to theSecureattribute, but I'll find out when CI runs.The browser ignores this onlocalhost, so for a simple local Nexus instance without TLS this shouldn't be a problem. However, if people are running Nexus without TLS for other test and dev setups, that might be a problem — the web console won't work. I think we could get around that by looking at the config value fordeployment.dropshot_external.tlsand only includingSecureif it's true.