g1t/services/identity/src/lib.rs
Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| API and MCP server, Rust identity service, registration, site redesign | 1 | //! The identity service: accounts, sessions, SSH keys and access tokens. |
| 2 | //! | |
| 3 | //! Reached only through service bindings; see `g1t_contracts::identity` for | |
| 4 | //! the methods and their arguments. | |
| 5 | ||
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 6 | mod access; |
| Billing on Stripe's pages, month-end charges, warnings; sudo by workspace | 7 | mod admin; |
| Workspace names and icons, and a component kit for every control | 8 | mod avatars; |
| API and MCP server, Rust identity service, registration, site redesign | 9 | mod crypto; |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 10 | mod deletion; |
| Device sign-in replaces registering and minting tokens over the API | 11 | mod device; |
| Search across all of g1t, Explore, and a command palette | 12 | mod directory; |
| Email verification, password reset, and Git for AI scale positioning | 13 | mod email; |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 14 | mod emails; |
| 15 | mod github; | |
| 16 | mod invites; | |
| OAuth 2.1 sign-in for MCP clients and other applications | 17 | mod oauth; |
| Agents and memory, checks and conflicts, profiles, slug renames, custom domains | 18 | mod profiles; |
| 19 | mod rename; | |
| Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API | 20 | mod run_credentials; |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 21 | mod security; |
| 22 | mod throttle; | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 23 | mod tokens; |
| Workspaces own repositories | 24 | mod workspaces; |
| API and MCP server, Rust identity service, registration, site redesign | 25 | |
| 26 | use g1t_contracts::identity::*; | |
| RFC 3339 timestamps in identity and repos | 27 | use g1t_contracts::time::{SQL_NOW, rfc3339, sql_after}; |
| API and MCP server, Rust identity service, registration, site redesign | 28 | use g1t_contracts::{FailureCode, Outcome, User, Viewer, is_valid_namespace, new_id}; |
| 29 | use g1t_kit::{args, now_ms, reply, rpc_method}; | |
| 30 | use serde::Deserialize; | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 31 | use tokens::TOKEN_PREFIX; |
| API and MCP server, Rust identity service, registration, site redesign | 32 | use worker::wasm_bindgen::JsValue; |
| 33 | use worker::{Context, D1Database, Env, Request, Response, Result, event}; | |
| 34 | ||
| RFC 3339 timestamps in identity and repos | 35 | const SESSION_TTL_SECONDS: u64 = 30 * 24 * 60 * 60; |
| 36 | const VERIFY_TTL_SECONDS: u64 = 24 * 60 * 60; | |
| 37 | const RESET_TTL_SECONDS: u64 = 60 * 60; | |
| API and MCP server, Rust identity service, registration, site redesign | 38 | const MIN_PASSWORD_LENGTH: usize = 10; |
| Email verification, password reset, and Git for AI scale positioning | 39 | const PASSWORD_TOO_SHORT: &str = "Use a password of at least 10 characters."; |
| 40 | ||
| 41 | /// A user as selected from the database; `verified` arrives as 0 or 1. | |
| 42 | #[derive(Deserialize)] | |
| 43 | struct Account { | |
| 44 | id: String, | |
| 45 | username: String, | |
| 46 | verified: u8, | |
| Workspace names and icons, and a component kit for every control | 47 | /// Selected only where the person is being shown to themselves. |
| 48 | #[serde(default)] | |
| 49 | avatar: Option<String>, | |
| Email verification, password reset, and Git for AI scale positioning | 50 | } |
| 51 | ||
| 52 | impl From<Account> for User { | |
| 53 | fn from(row: Account) -> Self { | |
| 54 | User { | |
| 55 | id: row.id, | |
| 56 | username: row.username, | |
| 57 | verified: row.verified != 0, | |
| Workspace names and icons, and a component kit for every control | 58 | avatar: row.avatar, |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 59 | ..User::default() |
| Email verification, password reset, and Git for AI scale positioning | 60 | } |
| 61 | } | |
| 62 | } | |
| API and MCP server, Rust identity service, registration, site redesign | 63 | |
| 64 | #[derive(Deserialize)] | |
| 65 | struct UserRow { | |
| 66 | id: String, | |
| 67 | username: String, | |
| 68 | password_hash: String, | |
| Email verification, password reset, and Git for AI scale positioning | 69 | verified: u8, |
| API and MCP server, Rust identity service, registration, site redesign | 70 | } |
| 71 | ||
| Email verification, password reset, and Git for AI scale positioning | 72 | /// The owner of an emailed token. |
| API and MCP server, Rust identity service, registration, site redesign | 73 | #[derive(Deserialize)] |
| Email verification, password reset, and Git for AI scale positioning | 74 | struct TokenOwner { |
| 75 | id: String, | |
| 76 | username: String, | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 77 | /// The address a link was sent to; null on links from before accounts |
| 78 | /// had several, which are for the primary. | |
| 79 | #[serde(default)] | |
| 80 | email_id: Option<String>, | |
| Email verification, password reset, and Git for AI scale positioning | 81 | } |
| 82 | ||
| 83 | #[derive(Deserialize)] | |
| API and MCP server, Rust identity service, registration, site redesign | 84 | struct KeyRow { |
| 85 | id: String, | |
| 86 | title: String, | |
| 87 | fingerprint: String, | |
| RFC 3339 timestamps in identity and repos | 88 | created_at: String, |
| API and MCP server, Rust identity service, registration, site redesign | 89 | } |
| 90 | ||
| 91 | impl From<KeyRow> for SshKey { | |
| 92 | fn from(row: KeyRow) -> Self { | |
| 93 | SshKey { | |
| 94 | id: row.id, | |
| 95 | title: row.title, | |
| 96 | fingerprint: row.fingerprint, | |
| RFC 3339 timestamps in identity and repos | 97 | created_at: row.created_at, |
| API and MCP server, Rust identity service, registration, site redesign | 98 | } |
| 99 | } | |
| 100 | } | |
| 101 | ||
| 102 | struct Identity { | |
| 103 | db: D1Database, | |
| Email verification, password reset, and Git for AI scale positioning | 104 | env: Env, |
| API and MCP server, Rust identity service, registration, site redesign | 105 | } |
| 106 | ||
| 107 | impl Identity { | |
| Workspaces own repositories | 108 | /// Runs a query that returns at most one user, for showing to others: |
| 109 | /// without their workspaces. | |
| 110 | async fn find_public_user(&self, sql: &str, param: &str) -> Result<Viewer> { | |
| Email verification, password reset, and Git for AI scale positioning | 111 | Ok(self |
| 112 | .db | |
| API and MCP server, Rust identity service, registration, site redesign | 113 | .prepare(sql) |
| 114 | .bind(&[JsValue::from(param)])? | |
| Email verification, password reset, and Git for AI scale positioning | 115 | .first::<Account>(None) |
| 116 | .await? | |
| 117 | .map(User::from)) | |
| 118 | } | |
| 119 | ||
| Workspaces own repositories | 120 | /// Attaches the workspaces a user belongs to, so that any service can |
| 121 | /// authorize them without asking again. | |
| 122 | async fn with_workspaces(&self, user: Viewer) -> Result<Viewer> { | |
| 123 | let Some(mut user) = user else { | |
| 124 | return Ok(None); | |
| 125 | }; | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 126 | let memberships = self.memberships(&user.id).await?; |
| 127 | // Access to a workspace is used only within its policy; see security.rs. | |
| 128 | user.workspaces = self.within_policy(&user.id, memberships).await?; | |
| 129 | // Roles on single repositories, under the same policy (access.rs). | |
| 130 | let grants = self.grants_of(&user.id).await?; | |
| 131 | user.grants = self.grants_within_policy(&user.id, grants).await?; | |
| Workspaces own repositories | 132 | Ok(Some(user)) |
| 133 | } | |
| 134 | ||
| 135 | /// Runs a query that resolves credentials to at most one user. | |
| 136 | async fn find_user(&self, sql: &str, param: &str) -> Result<Viewer> { | |
| 137 | let user = self.find_public_user(sql, param).await?; | |
| 138 | self.with_workspaces(user).await | |
| 139 | } | |
| 140 | ||
| Email verification, password reset, and Git for AI scale positioning | 141 | /// Stores a one-time token of `kind` for the user and returns it. |
| RFC 3339 timestamps in identity and repos | 142 | async fn issue_email_token(&self, user_id: &str, kind: &str, ttl: u64) -> Result<String> { |
| Email verification, password reset, and Git for AI scale positioning | 143 | let token = crypto::random_hex(32); |
| 144 | self.db | |
| RFC 3339 timestamps in identity and repos | 145 | .prepare(format!( |
| Email verification, password reset, and Git for AI scale positioning | 146 | "INSERT INTO email_tokens (id, user_id, kind, expires_at) |
| RFC 3339 timestamps in identity and repos | 147 | VALUES (?, ?, ?, {})", |
| 148 | sql_after(ttl) | |
| 149 | )) | |
| Email verification, password reset, and Git for AI scale positioning | 150 | .bind(&[ |
| 151 | crypto::sha256_hex(&token).into(), | |
| 152 | user_id.into(), | |
| 153 | kind.into(), | |
| 154 | ])? | |
| 155 | .run() | |
| 156 | .await?; | |
| 157 | Ok(token) | |
| API and MCP server, Rust identity service, registration, site redesign | 158 | } |
| 159 | ||
| Email verification, password reset, and Git for AI scale positioning | 160 | /// Consumes a token of `kind`, returning its owner if it was valid. |
| 161 | async fn redeem_email_token(&self, token: &str, kind: &str) -> Result<Option<TokenOwner>> { | |
| 162 | let id = crypto::sha256_hex(token); | |
| 163 | let owner = self | |
| 164 | .db | |
| RFC 3339 timestamps in identity and repos | 165 | .prepare(format!( |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 166 | "SELECT users.id, users.username, email_tokens.email_id FROM email_tokens |
| Email verification, password reset, and Git for AI scale positioning | 167 | JOIN users ON users.id = email_tokens.user_id |
| 168 | WHERE email_tokens.id = ? AND email_tokens.kind = ? | |
| RFC 3339 timestamps in identity and repos | 169 | AND email_tokens.expires_at > {SQL_NOW}" |
| 170 | )) | |
| Email verification, password reset, and Git for AI scale positioning | 171 | .bind(&[id.as_str().into(), kind.into()])? |
| 172 | .first::<TokenOwner>(None) | |
| 173 | .await?; | |
| 174 | if let Some(owner) = &owner { | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 175 | // Every outstanding token of this kind dies with the one used: |
| 176 | // every reset link, and every confirmation link for the same | |
| 177 | // address (another address's links still work). | |
| Email verification, password reset, and Git for AI scale positioning | 178 | self.db |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 179 | .prepare( |
| 180 | "DELETE FROM email_tokens WHERE user_id = ?1 AND kind = ?2 | |
| 181 | AND (?2 = 'reset' OR email_id IS ?3)", | |
| 182 | ) | |
| 183 | .bind(&[ | |
| 184 | owner.id.as_str().into(), | |
| 185 | kind.into(), | |
| 186 | owner.email_id.as_deref().map_or(JsValue::NULL, Into::into), | |
| 187 | ])? | |
| Email verification, password reset, and Git for AI scale positioning | 188 | .run() |
| 189 | .await?; | |
| 190 | } | |
| 191 | Ok(owner) | |
| 192 | } | |
| 193 | ||
| 194 | async fn send_verification(&self, user: &User, email: &str) -> Result<()> { | |
| 195 | let token = self | |
| 196 | .issue_email_token(&user.id, "verify", VERIFY_TTL_SECONDS) | |
| 197 | .await?; | |
| 198 | email::send_verification(&self.env, email, &user.username, &token).await | |
| 199 | } | |
| 200 | ||
| 201 | async fn resend_verification(&self, a: UserArgs) -> Result<Outcome<bool>> { | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 202 | if !self.allow(throttle::CONFIRM_ACCOUNT, &a.user.id).await? { |
| 203 | return Ok(Outcome::fail(FailureCode::Conflict, "Too many confirmation emails this hour. Check your inbox, or try again later.")); | |
| 204 | } | |
| 205 | self.resend_primary(&a.user).await | |
| Email verification, password reset, and Git for AI scale positioning | 206 | } |
| 207 | ||
| 208 | async fn verify_email(&self, a: EmailTokenArgs) -> Result<Outcome<User>> { | |
| 209 | let Some(owner) = self.redeem_email_token(&a.token, "verify").await? else { | |
| 210 | return Ok(Outcome::fail( | |
| 211 | FailureCode::Invalid, | |
| 212 | "This confirmation link is not valid or has expired.", | |
| 213 | )); | |
| 214 | }; | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 215 | if let Outcome::Fail(failure) = self.confirm_address(&owner.id, owner.email_id.as_deref()).await? { |
| 216 | return Ok(Outcome::Fail(failure)); | |
| 217 | } | |
| 218 | // Whether the account is confirmed: whether its primary is. | |
| 219 | let verified = self | |
| 220 | .find_public_user( | |
| 221 | "SELECT id, username, email_verified_at IS NOT NULL AS verified FROM users WHERE id = ?", | |
| 222 | &owner.id, | |
| 223 | ) | |
| 224 | .await? | |
| 225 | .is_some_and(|user| user.verified); | |
| Email verification, password reset, and Git for AI scale positioning | 226 | Ok(Outcome::Ok(User { |
| 227 | id: owner.id, | |
| 228 | username: owner.username, | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 229 | verified, |
| Workspaces own repositories | 230 | ..User::default() |
| Email verification, password reset, and Git for AI scale positioning | 231 | })) |
| 232 | } | |
| 233 | ||
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 234 | /// Any confirmed address of an account can ask for a reset; so can the |
| 235 | /// unconfirmed address a new account signed up with. See emails.rs. | |
| Email verification, password reset, and Git for AI scale positioning | 236 | async fn request_password_reset(&self, a: EmailArgs) -> Result<bool> { |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 237 | let allowed = self.allow(throttle::RESET_EMAIL, &a.email).await? |
| 238 | && match a.client.as_deref() { | |
| 239 | Some(client) => self.allow(throttle::RESET_CLIENT, client).await?, | |
| 240 | None => true, | |
| 241 | }; | |
| 242 | if allowed && let Some(target) = self.reset_target(&a.email).await? { | |
| 243 | let token = crypto::random_hex(32); | |
| 244 | self.db | |
| 245 | .prepare(format!( | |
| 246 | "INSERT INTO email_tokens (id, user_id, kind, expires_at, email_id) | |
| 247 | VALUES (?, ?, 'reset', {}, ?)", | |
| 248 | sql_after(RESET_TTL_SECONDS) | |
| 249 | )) | |
| 250 | .bind(&[ | |
| 251 | crypto::sha256_hex(&token).into(), | |
| 252 | target.user_id.as_str().into(), | |
| 253 | target.email_id.as_str().into(), | |
| 254 | ])? | |
| 255 | .run() | |
| Email verification, password reset, and Git for AI scale positioning | 256 | .await?; |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 257 | email::send_password_reset(&self.env, &target.display, &target.username, &token).await?; |
| 258 | // The primary and the backup hear of it when it went elsewhere. | |
| 259 | let elsewhere = self.notice_recipients(&target.user_id, false).await?; | |
| 260 | for address in elsewhere.iter().filter(|address| !address.eq_ignore_ascii_case(&target.display)) { | |
| 261 | let change = format!("A password reset was asked for through {}", target.display); | |
| 262 | if let Err(error) = email::send_security_notice(&self.env, address, &target.username, &change).await { | |
| 263 | worker::console_error!("security notice failed: {error}"); | |
| 264 | } | |
| 265 | } | |
| Email verification, password reset, and Git for AI scale positioning | 266 | } |
| 267 | // The same answer either way, so addresses cannot be probed. | |
| 268 | Ok(true) | |
| 269 | } | |
| 270 | ||
| 271 | async fn reset_password(&self, a: ResetPasswordArgs) -> Result<Outcome<User>> { | |
| 272 | if a.password.chars().count() < MIN_PASSWORD_LENGTH { | |
| 273 | return Ok(Outcome::fail(FailureCode::Invalid, PASSWORD_TOO_SHORT)); | |
| 274 | } | |
| 275 | let Some(owner) = self.redeem_email_token(&a.token, "reset").await? else { | |
| 276 | return Ok(Outcome::fail( | |
| 277 | FailureCode::Invalid, | |
| 278 | "This reset link is not valid or has expired.", | |
| 279 | )); | |
| 280 | }; | |
| 281 | self.db | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 282 | .prepare("UPDATE users SET password_hash = ? WHERE id = ?") |
| Email verification, password reset, and Git for AI scale positioning | 283 | .bind(&[ |
| 284 | crypto::hash_password(&a.password).into(), | |
| 285 | owner.id.as_str().into(), | |
| 286 | ])? | |
| 287 | .run() | |
| 288 | .await?; | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 289 | // Following an emailed link also proves the address it went to |
| 290 | // (unless another account confirmed it first). | |
| 291 | let _ = self.confirm_address(&owner.id, owner.email_id.as_deref()).await?; | |
| 292 | // Anyone signed in with the old password is signed out, and nobody | |
| 293 | // stays locked out by the wrong guesses before it. | |
| Email verification, password reset, and Git for AI scale positioning | 294 | self.db |
| 295 | .prepare("DELETE FROM sessions WHERE user_id = ?") | |
| 296 | .bind(&[owner.id.as_str().into()])? | |
| 297 | .run() | |
| 298 | .await?; | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 299 | self.clear(&throttle::key(throttle::PASSWORD_ACCOUNT, &owner.id)).await?; |
| 300 | self.log_security(&owner.id, "password_changed", None, None).await; | |
| 301 | self.tell_primary_and_backup(&owner.id, &owner.username, "Your password was changed").await; | |
| 302 | let verified = self | |
| 303 | .find_public_user( | |
| 304 | "SELECT id, username, email_verified_at IS NOT NULL AS verified FROM users WHERE id = ?", | |
| 305 | &owner.id, | |
| 306 | ) | |
| 307 | .await? | |
| 308 | .is_some_and(|user| user.verified); | |
| Email verification, password reset, and Git for AI scale positioning | 309 | Ok(Outcome::Ok(User { |
| 310 | id: owner.id, | |
| 311 | username: owner.username, | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 312 | verified, |
| Workspaces own repositories | 313 | ..User::default() |
| Email verification, password reset, and Git for AI scale positioning | 314 | })) |
| 315 | } | |
| 316 | ||
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 317 | /// The account a login names: a username, or any confirmed address. |
| 318 | async fn password_row(&self, login: &str) -> Result<Option<UserRow>> { | |
| 319 | let login = login.trim().to_lowercase(); | |
| 320 | let (column, value) = if login.contains('@') { | |
| 321 | match self.user_with_verified_email(&login).await? { | |
| 322 | Some(id) => ("id", id), | |
| 323 | None => return Ok(None), | |
| 324 | } | |
| 325 | } else { | |
| 326 | ("username", login) | |
| 327 | }; | |
| 328 | self.db | |
| 329 | .prepare(format!( | |
| 330 | "SELECT id, username, password_hash, email_verified_at IS NOT NULL AS verified FROM users WHERE {column} = ?" | |
| 331 | )) | |
| 332 | .bind(&[JsValue::from(value)])? | |
| API and MCP server, Rust identity service, registration, site redesign | 333 | .first::<UserRow>(None) |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 334 | .await |
| 335 | } | |
| 336 | ||
| 337 | /// Checks a password for a login, throttled (see throttle.rs). The | |
| 338 | /// refusal is one of two messages, the same for every account. | |
| 339 | async fn checked_password( | |
| 340 | &self, | |
| 341 | login: &str, | |
| 342 | password: &str, | |
| 343 | client: Option<&str>, | |
| 344 | ) -> Result<std::result::Result<User, &'static str>> { | |
| 345 | let row = self.password_row(login).await?; | |
| 346 | let subject = row.as_ref().map_or_else(|| login.trim().to_lowercase(), |row| row.id.clone()); | |
| 347 | let (account_key, client_key) = Identity::password_keys(&subject, client); | |
| 348 | if self.password_locked(&account_key, client_key.as_deref()).await? { | |
| 349 | return Ok(Err(throttle::THROTTLED)); | |
| 350 | } | |
| 351 | let owner = row.as_ref().map(|row| (row.id.clone(), row.username.clone())); | |
| 352 | match row.filter(|row| !row.password_hash.is_empty() && crypto::verify_password(password, &row.password_hash)) { | |
| 353 | Some(row) => { | |
| 354 | self.clear(&account_key).await?; | |
| 355 | Ok(Ok(User { | |
| 356 | id: row.id, | |
| 357 | username: row.username, | |
| 358 | verified: row.verified != 0, | |
| 359 | ..User::default() | |
| 360 | })) | |
| 361 | } | |
| 362 | None => { | |
| 363 | let owner = owner.as_ref().map(|(id, name)| (id.as_str(), name.as_str())); | |
| 364 | self.password_failed(&account_key, client_key.as_deref(), owner).await?; | |
| 365 | Ok(Err("Incorrect username or password.")) | |
| 366 | } | |
| 367 | } | |
| 368 | } | |
| 369 | ||
| 370 | async fn user_for_password(&self, login: &str, password: &str) -> Result<Viewer> { | |
| 371 | let user = self.checked_password(login, password, None).await?.ok(); | |
| Workspaces own repositories | 372 | self.with_workspaces(user).await |
| API and MCP server, Rust identity service, registration, site redesign | 373 | } |
| 374 | ||
| 375 | async fn register(&self, a: RegisterArgs) -> Result<Outcome<SignedIn>> { | |
| 376 | let username = a.username.trim().to_lowercase(); | |
| 377 | let email = a.email.trim().to_lowercase(); | |
| 378 | let invalid = |message: &str| Ok(Outcome::fail(FailureCode::Invalid, message)); | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 379 | let invite_code = a.invite_code.as_deref().map(str::trim).filter(|code| !code.is_empty()); |
| 380 | // The invite first: without one, nothing else on the form matters. | |
| 381 | if self.invites_required() && invite_code.is_none() { | |
| 382 | return Ok(Outcome::fail(FailureCode::Forbidden, invites::MISSING)); | |
| 383 | } | |
| API and MCP server, Rust identity service, registration, site redesign | 384 | if !is_valid_namespace(&username) { |
| 385 | return invalid( | |
| 386 | "Usernames use lowercase letters, digits and single hyphens, up to 39 characters.", | |
| 387 | ); | |
| 388 | } | |
| 389 | let well_formed_email = email | |
| 390 | .split_once('@') | |
| 391 | .is_some_and(|(local, domain)| !local.is_empty() && domain.contains('.')) | |
| 392 | && !email.contains(char::is_whitespace); | |
| 393 | if !well_formed_email { | |
| 394 | return invalid("Enter a valid email address."); | |
| 395 | } | |
| 396 | if a.password.chars().count() < MIN_PASSWORD_LENGTH { | |
| Email verification, password reset, and Git for AI scale positioning | 397 | return invalid(PASSWORD_TOO_SHORT); |
| API and MCP server, Rust identity service, registration, site redesign | 398 | } |
| 399 | let taken = self | |
| 400 | .db | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 401 | // Usernames and workspaces share one namespace, so that a name |
| 402 | // means the same thing wherever it appears. | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 403 | // An address is taken once an account has confirmed it; an |
| 404 | // unconfirmed one goes to whoever confirms it first (emails.rs). | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 405 | .prepare( |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 406 | "SELECT username FROM users WHERE username = ? |
| 407 | UNION ALL SELECT email FROM user_emails WHERE email = ? AND verified_at IS NOT NULL | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 408 | UNION ALL SELECT slug FROM workspaces WHERE slug = ?", |
| 409 | ) | |
| 410 | .bind(&[ | |
| 411 | username.as_str().into(), | |
| 412 | email.as_str().into(), | |
| 413 | username.as_str().into(), | |
| 414 | ])? | |
| API and MCP server, Rust identity service, registration, site redesign | 415 | .first::<serde_json::Value>(None) |
| 416 | .await?; | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 417 | // A renamed workspace's old slug stays reserved for it a while, and |
| 418 | // a deleted workspace's for good. | |
| 419 | if taken.is_some() || self.slug_held(&username).await? || self.slug_deleted(&username).await? { | |
| API and MCP server, Rust identity service, registration, site redesign | 420 | return Ok(Outcome::fail( |
| 421 | FailureCode::Conflict, | |
| 422 | "That username or email is already registered.", | |
| 423 | )); | |
| 424 | } | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 425 | let password_hash = crypto::hash_password(&a.password); |
| 426 | let user = match self | |
| 427 | .create_account(invites::NewAccount { | |
| 428 | username: &username, | |
| 429 | email: &email, | |
| 430 | password_hash: &password_hash, | |
| 431 | verified: false, | |
| 432 | invite_code, | |
| 433 | client: a.client.as_deref(), | |
| 434 | }) | |
| 435 | .await? | |
| 436 | { | |
| 437 | Outcome::Ok(user) => user, | |
| 438 | Outcome::Fail(failure) => return Ok(Outcome::Fail(failure)), | |
| API and MCP server, Rust identity service, registration, site redesign | 439 | }; |
| Email verification, password reset, and Git for AI scale positioning | 440 | // The account exists either way; the email can be sent again later. |
| 441 | if let Err(error) = self.send_verification(&user, &email).await { | |
| 442 | worker::console_error!("verification email failed: {error}"); | |
| 443 | } | |
| API and MCP server, Rust identity service, registration, site redesign | 444 | self.start_session(user).await |
| 445 | } | |
| 446 | ||
| 447 | async fn sign_in(&self, a: SignInArgs) -> Result<Outcome<SignedIn>> { | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 448 | let user = match self.checked_password(&a.username, &a.password, a.client.as_deref()).await? { |
| 449 | Ok(user) => user, | |
| 450 | Err(message) => return Ok(Outcome::fail(FailureCode::Unauthenticated, message)), | |
| API and MCP server, Rust identity service, registration, site redesign | 451 | }; |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 452 | let user = self.with_workspaces(Some(user)).await?.unwrap_or_default(); |
| API and MCP server, Rust identity service, registration, site redesign | 453 | self.start_session(user).await |
| 454 | } | |
| 455 | ||
| 456 | async fn start_session(&self, user: User) -> Result<Outcome<SignedIn>> { | |
| 457 | let session_token = crypto::random_hex(32); | |
| 458 | self.db | |
| RFC 3339 timestamps in identity and repos | 459 | .prepare(format!( |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 460 | // Signing in is proof it is the person: see security.rs. |
| 461 | "INSERT INTO sessions (id, user_id, expires_at, authenticated_at) VALUES (?, ?, {}, {SQL_NOW})", | |
| RFC 3339 timestamps in identity and repos | 462 | sql_after(SESSION_TTL_SECONDS) |
| 463 | )) | |
| API and MCP server, Rust identity service, registration, site redesign | 464 | .bind(&[ |
| 465 | crypto::sha256_hex(&session_token).into(), | |
| 466 | user.id.as_str().into(), | |
| 467 | ])? | |
| 468 | .run() | |
| 469 | .await?; | |
| 470 | Ok(Outcome::Ok(SignedIn { | |
| 471 | user, | |
| 472 | session_token, | |
| 473 | })) | |
| 474 | } | |
| 475 | ||
| 476 | async fn sign_out(&self, a: SessionArgs) -> Result<()> { | |
| 477 | self.db | |
| 478 | .prepare("DELETE FROM sessions WHERE id = ?") | |
| 479 | .bind(&[crypto::sha256_hex(&a.session_token).into()])? | |
| 480 | .run() | |
| 481 | .await?; | |
| 482 | Ok(()) | |
| 483 | } | |
| 484 | ||
| 485 | async fn user_for_session(&self, a: SessionArgs) -> Result<Viewer> { | |
| 486 | self.find_user( | |
| RFC 3339 timestamps in identity and repos | 487 | &format!( |
| Workspace names and icons, and a component kit for every control | 488 | "SELECT users.id, users.username, users.email_verified_at IS NOT NULL AS verified, |
| 489 | users.avatar | |
| RFC 3339 timestamps in identity and repos | 490 | FROM sessions JOIN users ON users.id = sessions.user_id |
| 491 | WHERE sessions.id = ? AND sessions.expires_at > {SQL_NOW}" | |
| 492 | ), | |
| API and MCP server, Rust identity service, registration, site redesign | 493 | &crypto::sha256_hex(&a.session_token), |
| 494 | ) | |
| 495 | .await | |
| 496 | } | |
| 497 | ||
| 498 | async fn user_for_git_credentials(&self, a: GitCredentialsArgs) -> Result<Viewer> { | |
| 499 | // Like GitHub, a token alone identifies its user. | |
| 500 | if a.secret.starts_with(TOKEN_PREFIX) { | |
| 501 | self.user_for_access_token(&a.secret).await | |
| 502 | } else { | |
| 503 | self.user_for_password(&a.username, &a.secret).await | |
| 504 | } | |
| 505 | } | |
| 506 | ||
| 507 | async fn user_for_ssh_key(&self, a: FingerprintArgs) -> Result<Viewer> { | |
| 508 | self.find_user( | |
| Email verification, password reset, and Git for AI scale positioning | 509 | "SELECT users.id, users.username, users.email_verified_at IS NOT NULL AS verified FROM ssh_keys |
| API and MCP server, Rust identity service, registration, site redesign | 510 | JOIN users ON users.id = ssh_keys.user_id |
| 511 | WHERE fingerprint = ?", | |
| 512 | &a.fingerprint, | |
| 513 | ) | |
| 514 | .await | |
| 515 | } | |
| 516 | ||
| 517 | async fn user_by_username(&self, a: UsernameArgs) -> Result<Viewer> { | |
| Workspaces own repositories | 518 | self.find_public_user( |
| Email verification, password reset, and Git for AI scale positioning | 519 | "SELECT id, username, email_verified_at IS NOT NULL AS verified FROM users WHERE username = ?", |
| API and MCP server, Rust identity service, registration, site redesign | 520 | &a.username.to_lowercase(), |
| 521 | ) | |
| 522 | .await | |
| 523 | } | |
| 524 | ||
| What happened across an outcome, as a feed beside its graph | 525 | async fn usernames(&self, a: UsernamesArgs) -> Result<std::collections::HashMap<String, String>> { |
| 526 | #[derive(serde::Deserialize)] | |
| 527 | struct Named { | |
| 528 | id: String, | |
| 529 | name: String, | |
| 530 | } | |
| 531 | let ids: Vec<String> = a.ids.into_iter().take(200).collect(); | |
| 532 | let mut names = std::collections::HashMap::new(); | |
| 533 | if ids.is_empty() { | |
| 534 | return Ok(names); | |
| 535 | } | |
| 536 | let marks = vec!["?"; ids.len()].join(", "); | |
| 537 | let bind: Vec<worker::wasm_bindgen::JsValue> = ids.iter().map(|id| id.as_str().into()).collect(); | |
| 538 | for sql in [ | |
| 539 | format!("SELECT id, username AS name FROM users WHERE id IN ({marks})"), | |
| 540 | format!("SELECT id, slug AS name FROM workspaces WHERE id IN ({marks})"), | |
| 541 | ] { | |
| 542 | for row in self.db.prepare(sql).bind(&bind)?.all().await?.results::<Named>()? { | |
| 543 | names.insert(row.id, row.name); | |
| 544 | } | |
| 545 | } | |
| 546 | Ok(names) | |
| 547 | } | |
| 548 | ||
| API and MCP server, Rust identity service, registration, site redesign | 549 | async fn list_ssh_keys(&self, a: UserArgs) -> Result<Vec<SshKey>> { |
| 550 | let rows = self | |
| 551 | .db | |
| 552 | .prepare("SELECT id, title, fingerprint, created_at FROM ssh_keys WHERE user_id = ? ORDER BY id") | |
| 553 | .bind(&[a.user.id.into()])? | |
| 554 | .all() | |
| 555 | .await? | |
| 556 | .results::<KeyRow>()?; | |
| 557 | Ok(rows.into_iter().map(SshKey::from).collect()) | |
| 558 | } | |
| 559 | ||
| 560 | async fn add_ssh_key(&self, a: AddSshKeyArgs) -> Result<Outcome<SshKey>> { | |
| 561 | let Some(key) = crypto::parse_ssh_key(&a.public_key) else { | |
| 562 | return Ok(Outcome::fail( | |
| 563 | FailureCode::Invalid, | |
| 564 | "That is not a valid OpenSSH public key.", | |
| 565 | )); | |
| 566 | }; | |
| 567 | let taken = self | |
| 568 | .db | |
| 569 | .prepare("SELECT id FROM ssh_keys WHERE fingerprint = ?") | |
| 570 | .bind(&[key.fingerprint.as_str().into()])? | |
| 571 | .first::<serde_json::Value>(None) | |
| 572 | .await?; | |
| 573 | if taken.is_some() { | |
| 574 | return Ok(Outcome::fail( | |
| 575 | FailureCode::Conflict, | |
| 576 | "That key is already registered.", | |
| 577 | )); | |
| 578 | } | |
| 579 | let now = now_ms(); | |
| 580 | let title = [a.title.trim(), key.comment.as_str(), "SSH key"] | |
| 581 | .into_iter() | |
| 582 | .find(|candidate| !candidate.is_empty()) | |
| 583 | .unwrap_or_default() | |
| 584 | .to_owned(); | |
| 585 | let row = KeyRow { | |
| 586 | id: new_id("key", now), | |
| 587 | title, | |
| 588 | fingerprint: key.fingerprint, | |
| RFC 3339 timestamps in identity and repos | 589 | created_at: rfc3339(now), |
| API and MCP server, Rust identity service, registration, site redesign | 590 | }; |
| 591 | self.db | |
| 592 | .prepare( | |
| 593 | "INSERT INTO ssh_keys (id, user_id, title, public_key, fingerprint, created_at) | |
| 594 | VALUES (?, ?, ?, ?, ?, ?)", | |
| 595 | ) | |
| 596 | .bind(&[ | |
| 597 | row.id.as_str().into(), | |
| 598 | a.user.id.into(), | |
| 599 | row.title.as_str().into(), | |
| 600 | key.public_key.into(), | |
| 601 | row.fingerprint.as_str().into(), | |
| RFC 3339 timestamps in identity and repos | 602 | row.created_at.as_str().into(), |
| API and MCP server, Rust identity service, registration, site redesign | 603 | ])? |
| 604 | .run() | |
| 605 | .await?; | |
| 606 | Ok(Outcome::Ok(row.into())) | |
| 607 | } | |
| 608 | ||
| 609 | /// Deletes a row the user owns from `table`. | |
| 610 | async fn remove(&self, table: &str, a: RemoveArgs) -> Result<()> { | |
| 611 | self.db | |
| 612 | .prepare(format!("DELETE FROM {table} WHERE id = ? AND user_id = ?")) | |
| 613 | .bind(&[a.id.into(), a.user.id.into()])? | |
| 614 | .run() | |
| 615 | .await?; | |
| 616 | Ok(()) | |
| 617 | } | |
| 618 | } | |
| 619 | ||
| 620 | #[event(fetch)] | |
| 621 | async fn fetch(mut request: Request, env: Env, _ctx: Context) -> Result<Response> { | |
| 622 | let Some(method) = rpc_method(&request) else { | |
| 623 | return Response::error("Not found", 404); | |
| 624 | }; | |
| 625 | let body: serde_json::Value = request.json().await?; | |
| Email verification, password reset, and Git for AI scale positioning | 626 | let identity = Identity { |
| 627 | db: env.d1("DB")?, | |
| 628 | env, | |
| 629 | }; | |
| API and MCP server, Rust identity service, registration, site redesign | 630 | |
| 631 | match method.as_str() { | |
| Search across all of g1t, Explore, and a command palette | 632 | "register" => { |
| 633 | let outcome = identity.register(args(body)?).await?; | |
| 634 | if let Outcome::Ok(signed_in) = &outcome { | |
| 635 | identity.announce_user(&signed_in.user.username, Some(&signed_in.user.id)).await; | |
| 636 | } | |
| 637 | reply(&outcome) | |
| 638 | } | |
| API and MCP server, Rust identity service, registration, site redesign | 639 | "sign_in" => reply(&identity.sign_in(args(body)?).await?), |
| Search across all of g1t, Explore, and a command palette | 640 | "create_workspace" => { |
| 641 | let outcome = identity.create_workspace(args(body)?).await?; | |
| 642 | if let Outcome::Ok(workspace) = &outcome { | |
| 643 | identity.announce_workspace(&workspace.id, &workspace.slug, None).await; | |
| 644 | } | |
| 645 | reply(&outcome) | |
| 646 | } | |
| Workspaces own repositories | 647 | "get_workspace" => reply(&identity.get_workspace(args(body)?).await?), |
| 648 | "list_members" => reply(&identity.list_members(args(body)?).await?), | |
| 649 | "add_member" => reply(&identity.add_member(args(body)?).await?), | |
| 650 | "remove_member" => reply(&identity.remove_member(args(body)?).await?), | |
| Search across all of g1t, Explore, and a command palette | 651 | "update_workspace" => { |
| 652 | let outcome = identity.update_workspace(args(body)?).await?; | |
| 653 | if let Outcome::Ok(workspace) = &outcome { | |
| 654 | identity.announce_workspace(&workspace.id, &workspace.slug, None).await; | |
| 655 | } | |
| 656 | reply(&outcome) | |
| 657 | } | |
| Agents and memory, checks and conflicts, profiles, slug renames, custom domains | 658 | "rename_workspace" => reply(&identity.rename_workspace(args(body)?).await?), |
| 659 | "check_workspace_rename" => reply(&identity.check_workspace_rename(args(body)?).await?), | |
| 660 | "resolve_slug" => reply(&identity.resolve_slug(args(body)?).await?), | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 661 | "check_workspace_deletion" => reply(&identity.check_workspace_deletion(args(body)?).await?), |
| 662 | "delete_workspace" => reply(&identity.delete_workspace(args(body)?).await?), | |
| 663 | "transfer_repo_scopes" => reply(&identity.transfer_repo_scopes(args(body)?).await?), | |
| Search across all of g1t, Explore, and a command palette | 664 | "set_workspace_avatar" => { |
| 665 | let outcome = identity.set_workspace_avatar(args(body)?).await?; | |
| 666 | if let Outcome::Ok(workspace) = &outcome { | |
| 667 | identity.announce_workspace(&workspace.id, &workspace.slug, None).await; | |
| 668 | } | |
| 669 | reply(&outcome) | |
| 670 | } | |
| 671 | "set_user_avatar" => { | |
| 672 | let a: SetUserAvatarArgs = args(body)?; | |
| 673 | let (username, id) = (a.user.username.clone(), a.user.id.clone()); | |
| 674 | let outcome = identity.set_user_avatar(a).await?; | |
| 675 | if matches!(outcome, Outcome::Ok(_)) { | |
| 676 | identity.announce_user(&username, Some(&id)).await; | |
| 677 | } | |
| 678 | reply(&outcome) | |
| 679 | } | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 680 | "list_workspace_tokens" => reply(&identity.list_workspace_tokens(args(body)?).await?), |
| 681 | "create_workspace_token" => reply(&identity.create_workspace_token(args(body)?).await?), | |
| 682 | "remove_workspace_token" => reply(&identity.remove_workspace_token(args(body)?).await?), | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 683 | // Signing in with GitHub; see github.rs. |
| 684 | "github_enabled" => reply(&identity.github_enabled()), | |
| 685 | "github_start" => reply(&identity.github_start(args(body)?).await?), | |
| 686 | "github_finish" => reply(&identity.github_finish(args(body)?).await?), | |
| 687 | "github_pending" => reply(&identity.github_pending(args(body)?).await?), | |
| 688 | "github_sign_up" => reply(&identity.github_sign_up(args(body)?).await?), | |
| 689 | "github_claim" => reply(&identity.github_claim(args(body)?).await?), | |
| 690 | "github_account" => reply(&identity.github_account(args(body)?).await?), | |
| 691 | "github_unlink" => reply(&identity.github_unlink(args(body)?).await?), | |
| 692 | "github_user_token" => reply(&identity.github_user_token(args(body)?).await?), | |
| 693 | "github_revoked" => reply(&identity.github_revoked(args(body)?).await?), | |
| 694 | "github_usernames" => reply(&identity.github_usernames(args(body)?).await?), | |
| OAuth 2.1 sign-in for MCP clients and other applications | 695 | "oauth_authorize" => reply(&identity.oauth_authorize(args(body)?).await?), |
| 696 | "oauth_exchange" => reply(&identity.oauth_exchange(args(body)?).await?), | |
| 697 | "oauth_refresh" => reply(&identity.oauth_refresh(args(body)?).await?), | |
| 698 | "list_oauth_grants" => reply(&identity.list_oauth_grants(args(body)?).await?), | |
| 699 | "revoke_oauth_grant" => reply(&identity.revoke_oauth_grant(args(body)?).await?), | |
| Device sign-in replaces registering and minting tokens over the API | 700 | "device_start" => reply(&identity.device_start(args(body)?).await?), |
| 701 | "device_lookup" => reply(&identity.device_lookup(args(body)?).await?), | |
| 702 | "device_resolve" => reply(&identity.device_resolve(args(body)?).await?), | |
| 703 | "device_claim" => reply(&identity.device_claim(args(body)?).await?), | |
| Email verification, password reset, and Git for AI scale positioning | 704 | "resend_verification" => reply(&identity.resend_verification(args(body)?).await?), |
| 705 | "verify_email" => reply(&identity.verify_email(args(body)?).await?), | |
| 706 | "request_password_reset" => reply(&identity.request_password_reset(args(body)?).await?), | |
| 707 | "reset_password" => reply(&identity.reset_password(args(body)?).await?), | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 708 | // A person's email addresses; see emails.rs and security.rs. |
| 709 | "list_emails" => reply(&identity.list_emails(args(body)?).await?), | |
| 710 | "add_email" => reply(&identity.add_email(args(body)?).await?), | |
| 711 | "remove_email" => reply(&identity.remove_email(args(body)?).await?), | |
| 712 | "resend_email_verification" => reply(&identity.resend_email_verification(args(body)?).await?), | |
| 713 | "update_email_settings" => reply(&identity.update_email_settings(args(body)?).await?), | |
| 714 | "reauthenticate" => reply(&identity.reauthenticate(args(body)?).await?), | |
| 715 | "security_log" => reply(&identity.security_log(args(body)?).await?), | |
| 716 | "email_owners" => reply(&identity.email_owners(args(body)?).await?), | |
| 717 | "commit_identity" => reply(&identity.commit_identity(args(body)?).await?), | |
| 718 | "push_email_guard" => reply(&identity.push_email_guard(args(body)?).await?), | |
| 719 | "admin_user" => reply(&identity.admin_user(args(body)?).await?), | |
| 720 | "admin_remove_email" => reply(&identity.admin_remove_email(args(body)?).await?), | |
| API and MCP server, Rust identity service, registration, site redesign | 721 | "sign_out" => reply(&identity.sign_out(args(body)?).await?), |
| 722 | "user_for_session" => reply(&identity.user_for_session(args(body)?).await?), | |
| 723 | "user_for_git_credentials" => reply(&identity.user_for_git_credentials(args(body)?).await?), | |
| 724 | "user_for_access_token" => { | |
| 725 | let a: TokenArgs = args(body)?; | |
| 726 | reply(&identity.user_for_access_token(&a.token).await?) | |
| 727 | } | |
| 728 | "user_for_ssh_key" => reply(&identity.user_for_ssh_key(args(body)?).await?), | |
| 729 | "user_by_username" => reply(&identity.user_by_username(args(body)?).await?), | |
| What happened across an outcome, as a feed beside its graph | 730 | "usernames" => reply(&identity.usernames(args(body)?).await?), |
| Agents and memory, checks and conflicts, profiles, slug renames, custom domains | 731 | "profile" => reply(&identity.profile(args(body)?).await?), |
| Search across all of g1t, Explore, and a command palette | 732 | "update_profile" => { |
| 733 | let outcome = identity.update_profile(args(body)?).await?; | |
| 734 | if let Outcome::Ok(profile) = &outcome { | |
| 735 | identity.announce_user(&profile.username, None).await; | |
| 736 | } | |
| 737 | reply(&outcome) | |
| 738 | } | |
| 739 | "directory" => reply(&identity.directory(args(body)?).await?), | |
| Agents and memory, checks and conflicts, profiles, slug renames, custom domains | 740 | "profile_workspaces" => reply(&identity.profile_workspaces(args(body)?).await?), |
| API and MCP server, Rust identity service, registration, site redesign | 741 | "list_ssh_keys" => reply(&identity.list_ssh_keys(args(body)?).await?), |
| 742 | "add_ssh_key" => reply(&identity.add_ssh_key(args(body)?).await?), | |
| 743 | "remove_ssh_key" => reply(&identity.remove("ssh_keys", args(body)?).await?), | |
| 744 | "list_access_tokens" => reply(&identity.list_access_tokens(args(body)?).await?), | |
| 745 | "create_access_token" => reply(&identity.create_access_token(args(body)?).await?), | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 746 | "create_agent_token" => reply(&identity.create_agent_token(args(body)?).await?), |
| 747 | "agent_scope" => reply(&identity.agent_scope(args(body)?).await?), | |
| Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API | 748 | "create_run_credential" => reply(&identity.create_run_credential(args(body)?).await?), |
| 749 | "bind_run_credentials" => reply(&identity.bind_run_credentials(args(body)?).await?), | |
| 750 | "revoke_run_credentials" => reply(&identity.revoke_run_credentials(args(body)?).await?), | |
| API and MCP server, Rust identity service, registration, site redesign | 751 | "remove_access_token" => reply(&identity.remove("access_tokens", args(body)?).await?), |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 752 | // Invites and the waitlist; see invites.rs. |
| 753 | "registration" => reply(&identity.registration_mode()), | |
| 754 | "list_invites" => reply(&identity.list_invites(args(body)?).await?), | |
| 755 | "create_invite" => reply(&identity.create_invite(args(body)?).await?), | |
| 756 | "revoke_invite" => reply(&identity.revoke_invite(args(body)?).await?), | |
| 757 | "check_invite" => reply(&identity.check_invite(args(body)?).await?), | |
| 758 | "accept_invite" => reply(&identity.accept_invite(args(body)?).await?), | |
| 759 | "invite_member" => reply(&identity.invite_member(args(body)?).await?), | |
| 760 | "workspace_invites" => reply(&identity.workspace_invites(args(body)?).await?), | |
| 761 | "revoke_workspace_invite" => reply(&identity.revoke_workspace_invite(args(body)?).await?), | |
| 762 | "request_access" => reply(&identity.request_access(args(body)?).await?), | |
| 763 | // Who has access to a repository; see access.rs. | |
| 764 | "repo_access" => reply(&identity.repo_access(args(body)?).await?), | |
| 765 | "add_collaborator" => reply(&identity.add_collaborator(args(body)?).await?), | |
| 766 | "set_collaborator_role" => reply(&identity.set_collaborator_role(args(body)?).await?), | |
| 767 | "remove_collaborator" => reply(&identity.remove_collaborator(args(body)?).await?), | |
| 768 | "collaborator_permission" => reply(&identity.collaborator_permission(args(body)?).await?), | |
| 769 | "my_repo_invitations" => reply(&identity.my_repo_invitations(args(body)?).await?), | |
| 770 | "respond_repo_invitation" => reply(&identity.respond_repo_invitation(args(body)?).await?), | |
| 771 | "revoke_repo_invitation" => reply(&identity.revoke_repo_invitation(args(body)?).await?), | |
| 772 | "set_base_permission" => reply(&identity.set_base_permission(args(body)?).await?), | |
| 773 | "outside_collaborators" => reply(&identity.outside_collaborators(args(body)?).await?), | |
| 774 | "forget_repo_access" => reply(&identity.forget_repo_access(args(body)?).await?), | |
| Billing on Stripe's pages, month-end charges, warnings; sudo by workspace | 775 | // Staff only: sudo.g1t.sh, over its service binding. See admin.rs. |
| 776 | "notify_owners" => reply(&identity.notify_owners(args(body)?).await?), | |
| 777 | "admin_workspaces" => reply(&identity.admin_workspaces(args(body)?).await?), | |
| 778 | "admin_workspace" => reply(&identity.admin_workspace(args(body)?).await?), | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 779 | "admin_waitlist" => reply(&identity.admin_waitlist(args(body)?).await?), |
| 780 | "admin_decide_waitlist" => reply(&identity.admin_decide_waitlist(args(body)?).await?), | |
| 781 | "admin_invites" => reply(&identity.admin_invites(args(body)?).await?), | |
| 782 | "admin_revoke_invite" => reply(&identity.admin_revoke_invite(args(body)?).await?), | |
| 783 | "admin_mint_invite" => reply(&identity.admin_mint_invite(args(body)?).await?), | |
| 784 | "admin_grant_invites" => reply(&identity.admin_grant_invites(args(body)?).await?), | |
| 785 | "admin_invite_tree" => reply(&identity.admin_invite_tree(args(body)?).await?), | |
| 786 | "admin_workspace_invites" => reply(&identity.admin_workspace_invites(args(body)?).await?), | |
| API and MCP server, Rust identity service, registration, site redesign | 787 | _ => Response::error("Unknown method", 404), |
| 788 | } | |
| 789 | } |