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

Fix the schema check for setting cookie securely #39

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pubky-homeserver/src/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ testnet = false
# Secret key (in hex) to generate the Homeserver's Keypair
secret_key = "0000000000000000000000000000000000000000000000000000000000000000"
# Domain to be published in Pkarr records for this server to be accessible by.
domain = "localhost"
domain = "backend.privky.app"
# Port for the Homeserver to listen on.
port = 6287
# Storage directory Defaults to <System's Data Directory>
Expand Down
6 changes: 3 additions & 3 deletions pubky-homeserver/src/routes/auth.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use axum::{
debug_handler,
extract::State,
http::{uri::Scheme, StatusCode, Uri},
http::{StatusCode, Uri},
response::IntoResponse,
};
use axum_extra::{headers::UserAgent, TypedHeader};
Expand Down Expand Up @@ -89,7 +89,7 @@ pub async fn signin(
State(state): State<AppState>,
user_agent: Option<TypedHeader<UserAgent>>,
cookies: Cookies,
uri: Uri,
_uri: Uri,
body: Bytes,
) -> Result<impl IntoResponse> {
let token = state.verifier.verify(&body)?;
Expand Down Expand Up @@ -124,7 +124,7 @@ pub async fn signin(
let mut cookie = Cookie::new(public_key.to_string(), session_secret);

cookie.set_path("/");
if *uri.scheme().unwrap_or(&Scheme::HTTP) == Scheme::HTTPS {
if state.config.domain().is_some() {
cookie.set_secure(true);
cookie.set_same_site(SameSite::None);
}
Expand Down
Loading