feat(api): retire ChatGPT plan sign-in by default
ci / checks (push) Successful in 57s
ci / test (push) Successful in 1m0s
ci / chart (push) Successful in 4s
ci / web (push) Successful in 21s
ci / docker (push) Successful in 1m48s
ci / publish-edge-image (push) Successful in 12s
ci / publish-edge-chart (push) Successful in 4s

A room's provider serves every member, while a ChatGPT plan belongs to
one account, so sharing it breaks OpenAI's terms. Together now hides
the chatgpt kind, refuses to store a new one, and fails a room that
still points at it with a message that names the API-key route.

Existing provider rows stay in the database. The room settings dialog
keeps the room's current provider visible even when its kind is
retired, so the room shows what it is pinned to instead of silently
losing it. Creating or updating a room to that provider is refused.

`RHEMA_TOGETHER_I_WANT_CHATGPT_BAN=1` lifts the block for a single-user
local test. The value has to be exactly `1`; any other value leaves the
block in place.
This commit is contained in:
vhaudiquet committed 2026-12-03 16:10:14 +01:00
1 parent 62fa380ec0
commit 64d7f359f5
8 files changed
+157 -34

No files matched your search

+7 -4
View File
@@ -104,10 +104,13 @@ issue certificates.
## First room ## First room
1. **Settings → Providers.** Add a provider kind and its key, address, 1. **Settings → Providers.** Add a provider kind and its key, address,
or sign-in. For GitHub Copilot, ChatGPT, and Mistral Vibe the dialog or sign-in. For GitHub Copilot and Mistral Vibe the dialog runs the
runs the provider's sign-in. The credential is sealed with the provider's sign-in. Together does not offer ChatGPT plan sign-in;
server's master key before it touches SQLite. A new provider stores use the openai kind with an API key instead. Set
no model; the room picks one. `RHEMA_TOGETHER_I_WANT_CHATGPT_BAN=1` to lift the block for a
single-user local test; a shared room still breaks OpenAI's terms.
The credential is sealed with the server's master key before it
touches SQLite. A new provider stores no model; the room picks one.
2. **Settings → Sandboxes.** Add a target. Leave the private key empty 2. **Settings → Sandboxes.** Add a target. Leave the private key empty
and the server generates an ed25519 pair and shows the public key. and the server generates an ed25519 pair and shows the public key.
Append that line to `~/.ssh/authorized_keys` on the target. Set the Append that line to `~/.ssh/authorized_keys` on the target. Set the
+10 -6
View File
@@ -600,7 +600,7 @@ it. No route, log line, or event carries a stored key.
### Provider sign-in ### Provider sign-in
GitHub Copilot, ChatGPT, and Mistral Vibe do not ask for a key. The GitHub Copilot and Mistral Vibe do not ask for a key. The
server runs the adapter's `InteractiveLogin` and keeps a per-account server runs the adapter's `InteractiveLogin` and keeps a per-account
record of its last update. The browser asks the server to start the record of its last update. The browser asks the server to start the
flow, polls the record, and renders the instruction, URL, and code. It flow, polls the record, and renders the instruction, URL, and code. It
@@ -612,10 +612,14 @@ their owner can read or cancel them. They live in memory, so a restart
drops a sign-in in progress. No provider row exists until the adapter drops a sign-in in progress. No provider row exists until the adapter
completes. completes.
ChatGPT's callback returns to loopback port 1455, or 1457 when 1455 is Together does not offer ChatGPT plan sign-in by default. A ChatGPT
taken. The machine that runs the browser must forward that port to the subscription is personal, and a room's provider serves every member,
server before opening the URL. Copilot's device code and Mistral Vibe's so a shared room uses an API-key kind such as `openai`. Existing
console sign-in need no inbound port. `chatgpt` provider rows stay in the database but fail with a clear
message, and neither a new room nor a room settings change can point
at that kind. Setting `RHEMA_TOGETHER_I_WANT_CHATGPT_BAN=1` lifts the
block for a single-user local test; it does not make a shared room
compliant.
A sign-in URL can carry a short-lived device or PKCE token. The server A sign-in URL can carry a short-lived device or PKCE token. The server
does not log it, and it is not the stored provider key. does not log it, and it is not the stored provider key.
@@ -775,7 +779,7 @@ This repository, as committed:
- A model picker over the provider's live catalog, with context, - A model picker over the provider's live catalog, with context,
output, price, and vision from the adapter and models.dev. A custom output, price, and vision from the adapter and models.dev. A custom
id is always accepted. The add-provider dialog asks for a kind and id is always accepted. The add-provider dialog asks for a kind and
key, or runs a sign-in for GitHub Copilot, ChatGPT, and Mistral Vibe. key, or runs a sign-in for GitHub Copilot and Mistral Vibe.
An OpenAI provider also takes a base URL and an explicit chat An OpenAI provider also takes a base URL and an explicit chat
completions or responses API, so one kind reaches OpenAI itself and completions or responses API, so one kind reaches OpenAI itself and
any compatible server. The room chooses the model. any compatible server. The room chooses the model.
+25 -7
View File
@@ -8,6 +8,7 @@ use rhema_core::request::ThinkingEffort;
use serde::Deserialize; use serde::Deserialize;
use serde_json::{Value, json}; use serde_json::{Value, json};
use crate::api::settings::retired_kind;
use crate::auth::{self, AuthUser, clean_display_name}; use crate::auth::{self, AuthUser, clean_display_name};
use crate::error::{AppError, AppResult}; use crate::error::{AppError, AppResult};
use crate::models::{Member, Room, RoomSummary, User}; use crate::models::{Member, Room, RoomSummary, User};
@@ -179,13 +180,19 @@ pub async fn create(
"room name must be 1 to 60 characters", "room name must be 1 to 60 characters",
)); ));
} }
let (provider_model, provider_owner) = state let (provider_model, provider_owner, provider_kind) = state
.db .db
.conn() .conn()
.query_row( .query_row(
"SELECT model, account_id FROM provider_configs WHERE id = ?1", "SELECT model, account_id, kind FROM provider_configs WHERE id = ?1",
rusqlite::params![body.provider_config_id], rusqlite::params![body.provider_config_id],
|row| Ok((row.get::<_, String>(0)?, row.get::<_, String>(1)?)), |row| {
Ok((
row.get::<_, String>(0)?,
row.get::<_, String>(1)?,
row.get::<_, String>(2)?,
))
},
) )
.map_err(|_| AppError::bad_request("provider configuration not found"))?; .map_err(|_| AppError::bad_request("provider configuration not found"))?;
if provider_owner != user.user.id { if provider_owner != user.user.id {
@@ -193,6 +200,9 @@ pub async fn create(
"that provider belongs to another account", "that provider belongs to another account",
)); ));
} }
if let Some(message) = retired_kind(&provider_kind) {
return Err(AppError::bad_request(message));
}
let (workspace_root, target_owner) = state let (workspace_root, target_owner) = state
.db .db
.conn() .conn()
@@ -326,19 +336,27 @@ pub async fn update(
)?; )?;
} }
if let Some(provider_id) = body.provider_config_id.as_deref() { if let Some(provider_id) = body.provider_config_id.as_deref() {
let owner: Option<String> = state let provider: Option<(String, String)> = state
.db .db
.conn() .conn()
.query_row( .query_row(
"SELECT account_id FROM provider_configs WHERE id = ?1", "SELECT account_id, kind FROM provider_configs WHERE id = ?1",
rusqlite::params![provider_id], rusqlite::params![provider_id],
|row| row.get(0), |row| Ok((row.get(0)?, row.get(1)?)),
) )
.ok(); .ok();
if owner.as_deref() != Some(user.user.id.as_str()) { let Some((owner, kind)) = provider else {
return Err(AppError::forbidden( return Err(AppError::forbidden(
"that provider belongs to another account", "that provider belongs to another account",
)); ));
};
if owner != user.user.id {
return Err(AppError::forbidden(
"that provider belongs to another account",
));
}
if let Some(message) = retired_kind(&kind) {
return Err(AppError::bad_request(message));
} }
state.db.conn().execute( state.db.conn().execute(
"UPDATE rooms SET provider_config_id = ?1 WHERE id = ?2", "UPDATE rooms SET provider_config_id = ?1 WHERE id = ?2",
+92 -9
View File
@@ -28,15 +28,76 @@ const KINDS: &[&str] = &[
"mistral", "mistral",
"mistral-vibe", "mistral-vibe",
"copilot", "copilot",
"chatgpt",
"opencode", "opencode",
"llama-cpp", "llama-cpp",
]; ];
/// Kinds whose credential comes from a browser sign-in instead of a /// Whether the operator lifted the ChatGPT block. Off by default:
/// pasted key. The adapter owns the protocol; the server owns the /// Together serves one plan to every room member, which OpenAI's terms
/// record the browser polls and stores the token it produces. /// do not allow for a shared room. A single-user local test can set
pub const FLOW_KINDS: &[&str] = &["copilot", "chatgpt", "mistral-vibe"]; /// `RHEMA_TOGETHER_I_WANT_CHATGPT_BAN=1`; the name keeps the ban, so
/// the default reads as banned and `1` as lifted.
fn chatgpt_enabled() -> bool {
std::env::var("RHEMA_TOGETHER_I_WANT_CHATGPT_BAN")
.ok()
.as_deref()
.is_some_and(enabled_value)
}
fn enabled_value(value: &str) -> bool {
value == "1"
}
/// The provider kinds the add dialog offers. ChatGPT joins the list
/// only when the operator lifted its block.
fn kinds() -> Vec<&'static str> {
let mut kinds = KINDS.to_vec();
if chatgpt_enabled() {
kinds.push("chatgpt");
}
kinds
}
/// The kinds whose credential comes from a browser sign-in. The
/// adapter owns the protocol; the server owns the record the browser
/// polls and stores the token it produces.
pub const FLOW_KINDS: &[&str] = &["copilot", "mistral-vibe"];
/// The flow kinds the add dialog offers, with ChatGPT only when its
/// block is lifted.
fn flow_kinds() -> Vec<&'static str> {
let mut kinds = FLOW_KINDS.to_vec();
if chatgpt_enabled() {
kinds.push("chatgpt");
}
kinds
}
/// Whether `kind` may be stored. `KINDS` is the base list; ChatGPT is
/// accepted only with the operator's opt-in.
fn kind_allowed(kind: &str) -> bool {
kind_allowed_with(kind, chatgpt_enabled())
}
fn kind_allowed_with(kind: &str, chatgpt: bool) -> bool {
KINDS.contains(&kind) || (kind == "chatgpt" && chatgpt)
}
/// Kinds Together has retired. Existing rows stay so a room that
/// points at one fails with this message instead of losing its
/// configuration.
pub(crate) fn retired_kind(kind: &str) -> Option<&'static str> {
retired_kind_with(kind, chatgpt_enabled())
}
fn retired_kind_with(kind: &str, chatgpt: bool) -> Option<&'static str> {
match kind {
"chatgpt" if !chatgpt => Some(
"ChatGPT plan sign-in is not available in Together. Add an API-key provider and point the room at it, or set RHEMA_TOGETHER_I_WANT_CHATGPT_BAN=1 for a single-user local test.",
),
_ => None,
}
}
/// The caller's provider configurations. /// The caller's provider configurations.
pub async fn list_providers(user: AuthUser, State(state): State<Shared>) -> AppResult<Json<Value>> { pub async fn list_providers(user: AuthUser, State(state): State<Shared>) -> AppResult<Json<Value>> {
@@ -58,8 +119,8 @@ pub async fn list_providers(user: AuthUser, State(state): State<Shared>) -> AppR
let configs = rows.collect::<Result<Vec<_>, _>>()?; let configs = rows.collect::<Result<Vec<_>, _>>()?;
Ok(Json(json!({ Ok(Json(json!({
"providers": configs, "providers": configs,
"kinds": KINDS, "kinds": kinds(),
"flow_kinds": FLOW_KINDS, "flow_kinds": flow_kinds(),
}))) })))
} }
@@ -94,7 +155,7 @@ pub async fn create_provider(
if name.is_empty() || name.chars().count() > 60 { if name.is_empty() || name.chars().count() > 60 {
return Err(AppError::bad_request("name must be 1 to 60 characters")); return Err(AppError::bad_request("name must be 1 to 60 characters"));
} }
if !KINDS.contains(&body.kind.as_str()) { if !kind_allowed(&body.kind) {
return Err(AppError::bad_request("unknown provider kind")); return Err(AppError::bad_request("unknown provider kind"));
} }
let model = body.model.trim().to_owned(); let model = body.model.trim().to_owned();
@@ -193,7 +254,7 @@ fn login_flow(kind: &str) -> Option<Box<dyn rhema_provider::InteractiveLogin>> {
"copilot" => Some(Box::new(rhema_provider_copilot::CopilotLogin::new())), "copilot" => Some(Box::new(rhema_provider_copilot::CopilotLogin::new())),
// The ChatGPT callback lands on the server's loopback port; a // The ChatGPT callback lands on the server's loopback port; a
// server cannot open the user's browser for them. // server cannot open the user's browser for them.
"chatgpt" => Some(Box::new( "chatgpt" if chatgpt_enabled() => Some(Box::new(
rhema_provider_chatgpt::ChatGptLogin::new().with_open_browser(false), rhema_provider_chatgpt::ChatGptLogin::new().with_open_browser(false),
)), )),
"mistral-vibe" => Some(Box::new(rhema_provider_mistral::MistralVibeLogin::new())), "mistral-vibe" => Some(Box::new(rhema_provider_mistral::MistralVibeLogin::new())),
@@ -311,6 +372,9 @@ pub async fn list_provider_models(
rusqlite::Error::QueryReturnedNoRows => AppError::not_found("provider not found"), rusqlite::Error::QueryReturnedNoRows => AppError::not_found("provider not found"),
other => other.into(), other => other.into(),
})?; })?;
if let Some(message) = retired_kind(&kind) {
return Err(AppError::bad_request(message));
}
let key = state.secrets.open_str(&ciphertext)?; let key = state.secrets.open_str(&ciphertext)?;
let llama_url = (kind == "llama-cpp") let llama_url = (kind == "llama-cpp")
.then_some(base_url.as_deref()) .then_some(base_url.as_deref())
@@ -622,6 +686,25 @@ mod tests {
} }
} }
#[test]
fn chatgpt_is_retired_until_the_operator_opts_in() {
assert!(retired_kind_with("chatgpt", false).is_some());
assert!(retired_kind_with("chatgpt", true).is_none());
assert!(retired_kind_with("openai", false).is_none());
assert!(!KINDS.contains(&"chatgpt"));
assert!(!FLOW_KINDS.contains(&"chatgpt"));
assert!(!kind_allowed_with("chatgpt", false));
assert!(kind_allowed_with("chatgpt", true));
}
#[test]
fn only_one_lifts_the_block() {
assert!(enabled_value("1"));
assert!(!enabled_value("0"));
assert!(!enabled_value("true"));
assert!(!enabled_value(""));
}
#[test] #[test]
fn a_keyed_kind_has_no_login_flow() { fn a_keyed_kind_has_no_login_flow() {
assert!(login_flow("anthropic").is_none()); assert!(login_flow("anthropic").is_none());
+4
View File
@@ -13,6 +13,7 @@ use rhema_host_agent::{HostAgent, HostAgentConfig, Steering};
use rhema_sandbox::WorkspaceSeed; use rhema_sandbox::WorkspaceSeed;
use rhema_sandbox::{Sandbox, ShellSandbox}; use rhema_sandbox::{Sandbox, ShellSandbox};
use crate::api::settings::retired_kind;
use crate::error::{AppError, AppResult}; use crate::error::{AppError, AppResult};
use crate::state::Shared; use crate::state::Shared;
@@ -116,6 +117,9 @@ pub fn load_turn_config(state: &Shared, room_id: &str) -> AppResult<TurnConfig>
)) ))
}, },
)?; )?;
if let Some(message) = retired_kind(&kind) {
return Err(AppError::bad_request(message));
}
let target = conn.query_row( let target = conn.query_row(
"SELECT id, host, port, user_name, private_key_ciphertext, host_fingerprint "SELECT id, host, port, user_name, private_key_ciphertext, host_fingerprint
FROM sandbox_targets WHERE id = ?1", FROM sandbox_targets WHERE id = ?1",
+2 -1
View File
@@ -67,7 +67,8 @@ onMounted(async () => {
api.get<ProviderListResponse>('/provider-configs'), api.get<ProviderListResponse>('/provider-configs'),
api.get<SandboxListResponse>('/sandbox-targets'), api.get<SandboxListResponse>('/sandbox-targets'),
]) ])
providers.value = providerList.providers const known = new Set(providerList.kinds)
providers.value = providerList.providers.filter((provider) => known.has(provider.kind))
targets.value = targetList.targets targets.value = targetList.targets
providerId.value = providers.value[0]?.id ?? '' providerId.value = providers.value[0]?.id ?? ''
targetId.value = targets.value[0]?.id ?? '' targetId.value = targets.value[0]?.id ?? ''
+14 -2
View File
@@ -19,6 +19,7 @@ const emit = defineEmits<{ close: []; updated: [room: Room]; archived: [] }>()
const api = useApi() const api = useApi()
const providers = ref<ProviderConfig[]>([]) const providers = ref<ProviderConfig[]>([])
const providerKinds = ref<string[]>([])
const loadingProviders = ref(true) const loadingProviders = ref(true)
const providersError = ref('') const providersError = ref('')
@@ -47,7 +48,13 @@ const canSave = computed(
onMounted(async () => { onMounted(async () => {
try { try {
const list = await api.get<ProviderListResponse>('/provider-configs') const list = await api.get<ProviderListResponse>('/provider-configs')
providers.value = list.providers // Keep the room's current provider even when the server no longer
// offers its kind, so the select shows what the room is pinned to.
const known = new Set(list.kinds)
providerKinds.value = list.kinds
providers.value = list.providers.filter(
(provider) => known.has(provider.kind) || provider.id === providerId.value,
)
} catch (err) { } catch (err) {
providersError.value = apiErrorMessage(err) providersError.value = apiErrorMessage(err)
} finally { } finally {
@@ -74,7 +81,9 @@ async function save() {
thinking_effort: thinkingEffort.value, thinking_effort: thinkingEffort.value,
max_turn_steps: Math.min(500, Math.max(1, Math.round(Number(maxSteps.value) || 1))), max_turn_steps: Math.min(500, Math.max(1, Math.round(Number(maxSteps.value) || 1))),
} }
if (providerId.value) body.provider_config_id = providerId.value if (providerId.value && providerId.value !== props.room.provider_config_id) {
body.provider_config_id = providerId.value
}
body.model = model.value.trim() body.model = model.value.trim()
try { try {
const response = await api.patch<UpdateRoomResponse>(`/rooms/${props.room.id}`, body) const response = await api.patch<UpdateRoomResponse>(`/rooms/${props.room.id}`, body)
@@ -130,6 +139,9 @@ async function archive() {
<span v-else-if="providers.length === 0" class="hint"> <span v-else-if="providers.length === 0" class="hint">
No providers yet. <NuxtLink to="/settings">Add one in settings</NuxtLink>. No providers yet. <NuxtLink to="/settings">Add one in settings</NuxtLink>.
</span> </span>
<span v-else-if="selectedProvider && !providerKinds.includes(selectedProvider.kind)" class="hint">
This provider is no longer available. Pick another before the room can run a turn.
</span>
</div> </div>
<div class="field"> <div class="field">
+3 -5
View File
@@ -37,8 +37,8 @@ const KIND_LABELS: Record<string, string> = {
} }
const providers = ref<ProviderConfig[]>([]) const providers = ref<ProviderConfig[]>([])
const kinds = ref<string[]>(['anthropic', 'openai', 'openrouter', 'google', 'deepseek', 'zai', 'mistral', 'mistral-vibe', 'copilot', 'chatgpt', 'opencode', 'llama-cpp']) const kinds = ref<string[]>(['anthropic', 'openai', 'openrouter', 'google', 'deepseek', 'zai', 'mistral', 'mistral-vibe', 'copilot', 'opencode', 'llama-cpp'])
const flowKinds = ref<string[]>(['copilot', 'chatgpt', 'mistral-vibe']) const flowKinds = ref<string[]>(['copilot', 'mistral-vibe'])
const targets = ref<SandboxTarget[]>([]) const targets = ref<SandboxTarget[]>([])
const loading = ref(true) const loading = ref(true)
const loadError = ref('') const loadError = ref('')
@@ -88,8 +88,6 @@ const flowInstruction = computed(() => {
return 'Enter the code on GitHub to authorize Rhema.' return 'Enter the code on GitHub to authorize Rhema.'
case 'mistral-vibe': case 'mistral-vibe':
return 'Sign in with your Mistral account to authorize Rhema for your Vibe plan.' return 'Sign in with your Mistral account to authorize Rhema for your Vibe plan.'
case 'chatgpt':
return sentence(instruction.text)
default: default:
return sentence(instruction.text) return sentence(instruction.text)
} }
@@ -450,7 +448,7 @@ async function copyKey(target: SandboxTarget) {
<div class="settings-row-main"> <div class="settings-row-main">
<div class="settings-row-title">{{ provider.name }}</div> <div class="settings-row-title">{{ provider.name }}</div>
<div class="settings-row-detail"> <div class="settings-row-detail">
{{ kindLabel(provider.kind) }}<template v-if="provider.api">, {{ provider.api }} API</template><template v-if="provider.base_url">, {{ provider.base_url }}</template> {{ kindLabel(provider.kind) }}<template v-if="!kinds.includes(provider.kind)"> (no longer available)</template><template v-if="provider.api">, {{ provider.api }} API</template><template v-if="provider.base_url">, {{ provider.base_url }}</template>
</div> </div>
</div> </div>
<div class="settings-row-actions"> <div class="settings-row-actions">