Single sign-on is the only way in when it is configured

The sign-in page shows only the identity provider; password sign-in and
new local accounts are refused. Invites go through the identity provider.
Server 0.1.2, chart 0.1.3.
This commit is contained in:
Oleg Lukasonok committed 2026-11-08 19:39:02 +02:00
1 parent 01a35f7ba6
commit 1ab3d0b26a
5 files changed
+34 -25

No files matched your search

+27 -18
View File
@@ -215,24 +215,29 @@ async fn authorize_form(state: &AppState, q: &AuthorizeQuery, error: Option<&str
.unwrap_or_default(),
]
.concat();
// Single sign-on first when the server has it; the password form stays for local accounts.
let mut body = state
.oidc
.as_ref()
.map(|o| {
format!(
r#"<div class="card"><h2>Sign in for VS Code</h2>{}<a class="button" href="/oidc/start?{}">Sign in with {}</a></div>"#,
error_line(error),
escape(&q.to_query_string()),
escape(&o.config.label),
)
})
.unwrap_or_default();
let (title, error) = if body.is_empty() {
("Sign in for VS Code", error)
} else {
("Or with a password", None)
};
// With single sign-on the identity provider is the only way in: no
// password form, no new local accounts. An invite goes through it too.
if let Some(o) = &state.oidc {
let invited = match &q.invite {
Some(invite) => match state.store.invite_organisation(&auth::sha256(invite)).await {
Ok(Some((_, space_name))) => format!(
r#"<p class="muted">You were invited to <b>{}</b>.</p>"#,
escape(&space_name)
),
_ => String::new(),
},
None => String::new(),
};
let body = format!(
r#"<div class="card"><h2>Sign in for VS Code</h2>{}{invited}<a class="button" href="/oidc/start?{}">Sign in with {}</a></div>"#,
error_line(error),
escape(&q.to_query_string()),
escape(&o.config.label),
);
return page(state, "Sign in", &body);
}
let mut body = String::new();
let title = "Sign in for VS Code";
body.push_str(&format!(
r#"<div class="card"><h2>{title}</h2>{}
<form method="post" action="/authorize">{fields}{}
@@ -269,6 +274,10 @@ pub async fn authorize_submit(
if check_authorize(&state, &q).is_err() {
return authorize_form(&state, &q, None).await;
}
if let Some(o) = &state.oidc {
let message = format!("This server signs in with {} only.", o.config.label);
return authorize_form(&state, &q, Some(&message)).await;
}
let account = match form.action.as_str() {
"signup" => sign_up(&state, &form).await,
_ => sign_in(&state, &form).await,