Replace demo invites with Heimdall sign-in
This commit is contained in:
parent
f2398545f3
commit
92c3e81d92
12 changed files with 537 additions and 175 deletions
86
Cargo.lock
generated
86
Cargo.lock
generated
|
|
@ -425,6 +425,12 @@ version = "2.11.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4583a4551df46e2792f82ceeac45e850d2e2d5debba0b91f102385cda5b11f06"
|
||||
|
||||
[[package]]
|
||||
name = "deranged"
|
||||
version = "0.5.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c"
|
||||
|
||||
[[package]]
|
||||
name = "diff"
|
||||
version = "0.1.13"
|
||||
|
|
@ -688,6 +694,7 @@ dependencies = [
|
|||
"cultnet-rs",
|
||||
"ghostlight-persona-projection",
|
||||
"jsonschema",
|
||||
"jsonwebtoken",
|
||||
"rand 0.9.5",
|
||||
"reqwest",
|
||||
"rmp-serde",
|
||||
|
|
@ -1064,6 +1071,21 @@ dependencies = [
|
|||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jsonwebtoken"
|
||||
version = "9.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5a87cc7a48537badeae96744432de36f4be2b4a34a05a5ef32e9dd8a1c169dde"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"js-sys",
|
||||
"pem",
|
||||
"ring",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"simple_asn1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.5.0"
|
||||
|
|
@ -1211,6 +1233,12 @@ dependencies = [
|
|||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-conv"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441"
|
||||
|
||||
[[package]]
|
||||
name = "num-integer"
|
||||
version = "0.1.47"
|
||||
|
|
@ -1291,6 +1319,16 @@ dependencies = [
|
|||
"windows-link 0.2.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pem"
|
||||
version = "3.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d30c53c26bc5b31a98cd02d20f25a7c8567146caf63ed593a9d87b2775291be"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"serde_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "percent-encoding"
|
||||
version = "2.3.2"
|
||||
|
|
@ -1324,6 +1362,12 @@ dependencies = [
|
|||
"zerovec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "powerfmt"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
|
||||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.21"
|
||||
|
|
@ -1884,6 +1928,18 @@ dependencies = [
|
|||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "simple_asn1"
|
||||
version = "0.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0d585997b0ac10be3c5ee635f1bab02d512760d14b7c468801ac8a01d9ae5f1d"
|
||||
dependencies = [
|
||||
"num-bigint",
|
||||
"num-traits",
|
||||
"thiserror",
|
||||
"time",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "slab"
|
||||
version = "0.4.12"
|
||||
|
|
@ -2033,6 +2089,36 @@ dependencies = [
|
|||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.3.55"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cdb87b95ec50ddfa440816d227a17b2ccbdda963a316a727fda0fc4334f7d134"
|
||||
dependencies = [
|
||||
"deranged",
|
||||
"num-conv",
|
||||
"powerfmt",
|
||||
"serde_core",
|
||||
"time-core",
|
||||
"time-macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time-core"
|
||||
version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9e1c906769ad99c88eaa54e728060edef082f8e358ff32030cb7c7d315e81109"
|
||||
|
||||
[[package]]
|
||||
name = "time-macros"
|
||||
version = "0.2.32"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7e689342a48d2ea927c87ea50cabf8594854bf940e9310208848d680d668ed85"
|
||||
dependencies = [
|
||||
"num-conv",
|
||||
"time-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tinystr"
|
||||
version = "0.8.4"
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ cultcache-rs = { path = "vendor/cultcache-rs" }
|
|||
cultnet-rs = { path = "vendor/cultnet-rs" }
|
||||
cultmesh-rs = { path = "vendor/cultmesh-rs" }
|
||||
jsonschema = { version = "0.49", default-features = false }
|
||||
jsonwebtoken = "9"
|
||||
rand = "0.9"
|
||||
reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls", "stream"] }
|
||||
rmp-serde = "1.3"
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ Ghostlight Dungeon is implemented and deployed as a private Starfire-hosted
|
|||
playtest harness. The current acceptance surface covers:
|
||||
|
||||
- source-grounded world compilation with approval previews;
|
||||
- persistent campaigns, forks, resets, exports, and isolated invite sessions;
|
||||
- persistent campaigns, forks, resets, exports, and Heimdall-account-isolated sessions;
|
||||
- parallel affected-character Projector/Persona/Interpreter waves;
|
||||
- impossible-action refusal, assessed stakes, server-side rolls, and receipted
|
||||
commits;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ cultcache-rs.workspace = true
|
|||
cultnet-rs.workspace = true
|
||||
cultmesh-rs.workspace = true
|
||||
jsonschema.workspace = true
|
||||
jsonwebtoken.workspace = true
|
||||
ghostlight-persona-projection = { path = "../ghostlight-persona-projection" }
|
||||
rand.workspace = true
|
||||
reqwest.workspace = true
|
||||
|
|
|
|||
164
crates/ghostlight-dungeon/src/heimdall.rs
Normal file
164
crates/ghostlight-dungeon/src/heimdall.rs
Normal file
|
|
@ -0,0 +1,164 @@
|
|||
use anyhow::{Context, bail};
|
||||
use jsonwebtoken::{Algorithm, DecodingKey, Validation, decode, decode_header, jwk::JwkSet};
|
||||
use reqwest::Client;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
const APP_SLUG: &str = "ghostlight";
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct HeimdallClient {
|
||||
client: Client,
|
||||
base_url: String,
|
||||
public_app_url: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct StartRequest<'a> {
|
||||
app_slug: &'a str,
|
||||
mode: &'a str,
|
||||
return_to: &'a str,
|
||||
handoff: Handoff<'a>,
|
||||
requested_scopes: [&'a str; 1],
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct Handoff<'a> {
|
||||
kind: &'a str,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct StartResponse {
|
||||
pub authorization_url: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct RedeemRequest<'a> {
|
||||
completion_code: &'a str,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct RedeemResponse {
|
||||
access_token: String,
|
||||
shared_capabilities: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct AccessClaims {
|
||||
pub iss: String,
|
||||
pub aud: String,
|
||||
pub typ: String,
|
||||
pub account_id: String,
|
||||
pub capabilities: Vec<String>,
|
||||
pub app: AppClaim,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct AppClaim {
|
||||
pub slug: String,
|
||||
}
|
||||
|
||||
impl HeimdallClient {
|
||||
pub fn public_demo() -> anyhow::Result<Self> {
|
||||
Ok(Self {
|
||||
client: Client::builder()
|
||||
.timeout(std::time::Duration::from_secs(10))
|
||||
.build()?,
|
||||
base_url: std::env::var("GHOSTLIGHT_HEIMDALL_BASE_URL")
|
||||
.unwrap_or_else(|_| "https://heimdall.gamecult.org".into())
|
||||
.trim_end_matches('/')
|
||||
.into(),
|
||||
public_app_url: std::env::var("GHOSTLIGHT_PUBLIC_APP_URL")
|
||||
.unwrap_or_else(|_| "https://yggdrasil.gamecult.org/ghostlight/".into()),
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub fn fixture() -> Self {
|
||||
Self {
|
||||
client: Client::new(),
|
||||
base_url: "https://heimdall.invalid".into(),
|
||||
public_app_url: "https://ghostlight.invalid/".into(),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn start(&self) -> anyhow::Result<StartResponse> {
|
||||
self.client
|
||||
.post(format!("{}/v1/oauth/discord/start", self.base_url))
|
||||
.json(&StartRequest {
|
||||
app_slug: APP_SLUG,
|
||||
mode: "sign_in",
|
||||
return_to: &self.public_app_url,
|
||||
handoff: Handoff {
|
||||
kind: "browser_completion",
|
||||
},
|
||||
requested_scopes: ["identify"],
|
||||
})
|
||||
.send()
|
||||
.await?
|
||||
.error_for_status()?
|
||||
.json()
|
||||
.await
|
||||
.context("Heimdall start response was malformed")
|
||||
}
|
||||
|
||||
pub async fn redeem(&self, completion_code: &str) -> anyhow::Result<AccessClaims> {
|
||||
let redeemed: RedeemResponse = self
|
||||
.client
|
||||
.post(format!(
|
||||
"{}/v1/apps/{APP_SLUG}/auth-completions/redeem",
|
||||
self.base_url
|
||||
))
|
||||
.json(&RedeemRequest { completion_code })
|
||||
.send()
|
||||
.await?
|
||||
.error_for_status()?
|
||||
.json()
|
||||
.await
|
||||
.context("Heimdall redeem response was malformed")?;
|
||||
if !redeemed
|
||||
.shared_capabilities
|
||||
.iter()
|
||||
.any(|value| value == "app_access")
|
||||
{
|
||||
bail!("Heimdall did not grant Ghostlight app_access");
|
||||
}
|
||||
self.verify(&redeemed.access_token).await
|
||||
}
|
||||
|
||||
async fn verify(&self, token: &str) -> anyhow::Result<AccessClaims> {
|
||||
let header = decode_header(token)?;
|
||||
if header.alg != Algorithm::EdDSA {
|
||||
bail!("Heimdall used an unsupported signing algorithm");
|
||||
}
|
||||
let kid = header.kid.context("Heimdall token omitted kid")?;
|
||||
let jwks: JwkSet = self
|
||||
.client
|
||||
.get(format!("{}/.well-known/jwks.json", self.base_url))
|
||||
.send()
|
||||
.await?
|
||||
.error_for_status()?
|
||||
.json()
|
||||
.await?;
|
||||
let jwk = jwks
|
||||
.find(&kid)
|
||||
.context("Heimdall signing key was not published")?;
|
||||
let key = DecodingKey::from_jwk(jwk)?;
|
||||
let mut validation = Validation::new(Algorithm::EdDSA);
|
||||
validation.set_audience(&[APP_SLUG]);
|
||||
validation.set_issuer(&[self.base_url.as_str()]);
|
||||
let claims = decode::<AccessClaims>(token, &key, &validation)?.claims;
|
||||
if claims.typ != "heimdall_access"
|
||||
|| claims.aud != APP_SLUG
|
||||
|| claims.iss != self.base_url
|
||||
|| claims.app.slug != APP_SLUG
|
||||
|| !claims.capabilities.iter().any(|v| v == "app_access")
|
||||
{
|
||||
bail!("Heimdall claim did not grant Ghostlight app_access");
|
||||
}
|
||||
Ok(claims)
|
||||
}
|
||||
}
|
||||
|
|
@ -45,11 +45,15 @@ use tokio::sync::{Mutex, Notify, OwnedRwLockReadGuard, RwLock};
|
|||
use tower_http::services::ServeDir;
|
||||
use tracing_subscriber::EnvFilter;
|
||||
|
||||
mod heimdall;
|
||||
use heimdall::HeimdallClient;
|
||||
|
||||
#[derive(Clone)]
|
||||
struct AppState {
|
||||
registry: CampaignRegistry,
|
||||
runtime_root: PathBuf,
|
||||
auth: Arc<Mutex<AuthOwner>>,
|
||||
heimdall: Arc<HeimdallClient>,
|
||||
deepseek_status: String,
|
||||
compiler: Option<Arc<WorldCompiler>>,
|
||||
assessor: Option<Arc<ActionAssessor>>,
|
||||
|
|
@ -125,6 +129,11 @@ struct ProviderParallelismRequest {
|
|||
provider_parallelism: u8,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct HeimdallRedeemRequest {
|
||||
completion_code: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize)]
|
||||
struct AuthState {
|
||||
schema: String,
|
||||
|
|
@ -133,6 +142,8 @@ struct AuthState {
|
|||
provisioned_invite_hashes: BTreeSet<String>,
|
||||
session_hashes: BTreeSet<String>,
|
||||
#[serde(default)]
|
||||
session_aliases: BTreeMap<String, String>,
|
||||
#[serde(default)]
|
||||
session_campaigns: BTreeMap<String, uuid::Uuid>,
|
||||
#[serde(default)]
|
||||
session_campaign_ids: BTreeMap<String, BTreeSet<uuid::Uuid>>,
|
||||
|
|
@ -237,6 +248,7 @@ async fn main() -> anyhow::Result<()> {
|
|||
unused_invite_hashes: supplied_invite_hashes.clone(),
|
||||
provisioned_invite_hashes: supplied_invite_hashes,
|
||||
session_hashes: BTreeSet::new(),
|
||||
session_aliases: BTreeMap::new(),
|
||||
session_campaigns: BTreeMap::new(),
|
||||
session_campaign_ids: BTreeMap::new(),
|
||||
};
|
||||
|
|
@ -297,6 +309,7 @@ async fn main() -> anyhow::Result<()> {
|
|||
row: auth_row,
|
||||
state: auth_state,
|
||||
})),
|
||||
heimdall: Arc::new(HeimdallClient::public_demo()?),
|
||||
deepseek_status,
|
||||
compiler,
|
||||
assessor,
|
||||
|
|
@ -377,11 +390,56 @@ fn app_router(state: AppState, web_root: PathBuf) -> Router {
|
|||
Router::new()
|
||||
.route("/health", get(health))
|
||||
.route("/invite/{token}", get(invite))
|
||||
.route("/api/auth/heimdall/start", post(heimdall_start))
|
||||
.route("/api/auth/heimdall/redeem", post(heimdall_redeem))
|
||||
.merge(protected_api)
|
||||
.fallback_service(ServeDir::new(web_root).append_index_html_on_directories(true))
|
||||
.with_state(state)
|
||||
}
|
||||
|
||||
async fn heimdall_start(State(state): State<AppState>) -> Response {
|
||||
match state.heimdall.start().await {
|
||||
Ok(start) => {
|
||||
Json(serde_json::json!({"authorization_url": start.authorization_url})).into_response()
|
||||
}
|
||||
Err(error) => (StatusCode::BAD_GATEWAY, error.to_string()).into_response(),
|
||||
}
|
||||
}
|
||||
|
||||
async fn heimdall_redeem(
|
||||
State(state): State<AppState>,
|
||||
Json(request): Json<HeimdallRedeemRequest>,
|
||||
) -> Response {
|
||||
if request.completion_code.len() > 1024 || request.completion_code.trim().is_empty() {
|
||||
return (StatusCode::BAD_REQUEST, "invalid completion code").into_response();
|
||||
}
|
||||
let claims = match state.heimdall.redeem(request.completion_code.trim()).await {
|
||||
Ok(claims) => claims,
|
||||
Err(error) => return (StatusCode::UNAUTHORIZED, error.to_string()).into_response(),
|
||||
};
|
||||
let account_session = secret_hash(&format!("heimdall-account:{}", claims.account_id));
|
||||
let raw_session = uuid::Uuid::new_v4().to_string();
|
||||
let alias_hash = secret_hash(&raw_session);
|
||||
let mut auth = state.auth.lock().await;
|
||||
let mut next_state = auth.state.clone();
|
||||
next_state.session_hashes.insert(account_session.clone());
|
||||
next_state
|
||||
.session_aliases
|
||||
.insert(alias_hash, account_session);
|
||||
if let Err(error) = auth.commit(next_state) {
|
||||
return (StatusCode::INTERNAL_SERVER_ERROR, error.to_string()).into_response();
|
||||
}
|
||||
let mut response = Json(serde_json::json!({"status":"authenticated"})).into_response();
|
||||
response.headers_mut().insert(
|
||||
header::SET_COOKIE,
|
||||
HeaderValue::from_str(&format!(
|
||||
"ghostlight_session={raw_session}; HttpOnly; Secure; SameSite=Lax; Path=/"
|
||||
))
|
||||
.unwrap(),
|
||||
);
|
||||
response
|
||||
}
|
||||
|
||||
async fn require_api_authentication(
|
||||
State(state): State<AppState>,
|
||||
headers: HeaderMap,
|
||||
|
|
@ -2328,14 +2386,11 @@ async fn authenticated_session(headers: &HeaderMap, state: &AppState) -> Option<
|
|||
.find_map(|cookie| cookie.strip_prefix("ghostlight_session="))
|
||||
});
|
||||
let hash = secret_hash(session?);
|
||||
state
|
||||
.auth
|
||||
.lock()
|
||||
.await
|
||||
.state
|
||||
.session_hashes
|
||||
.contains(&hash)
|
||||
.then_some(hash)
|
||||
let auth = state.auth.lock().await;
|
||||
if auth.state.session_hashes.contains(&hash) {
|
||||
return Some(hash);
|
||||
}
|
||||
auth.state.session_aliases.get(&hash).cloned()
|
||||
}
|
||||
|
||||
async fn session_runtime(
|
||||
|
|
@ -2514,6 +2569,7 @@ mod tests {
|
|||
unused_invite_hashes: BTreeSet::new(),
|
||||
provisioned_invite_hashes: BTreeSet::new(),
|
||||
session_hashes: BTreeSet::new(),
|
||||
session_aliases: BTreeMap::new(),
|
||||
session_campaigns: BTreeMap::new(),
|
||||
session_campaign_ids: BTreeMap::new(),
|
||||
};
|
||||
|
|
@ -2533,6 +2589,7 @@ mod tests {
|
|||
row,
|
||||
state: auth_state,
|
||||
})),
|
||||
heimdall: Arc::new(HeimdallClient::fixture()),
|
||||
deepseek_status: "fixture".into(),
|
||||
compiler: None,
|
||||
assessor: None,
|
||||
|
|
@ -2595,6 +2652,30 @@ mod tests {
|
|||
assert_eq!(response.status(), StatusCode::BAD_REQUEST);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn heimdall_cookie_alias_resolves_to_stable_account_campaign_authority() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let state = empty_app_state(dir.path());
|
||||
let account_session = secret_hash("heimdall-account:acct-1");
|
||||
let cookie_hash = secret_hash("browser-session");
|
||||
{
|
||||
let mut auth = state.auth.lock().await;
|
||||
auth.state.session_hashes.insert(account_session.clone());
|
||||
auth.state
|
||||
.session_aliases
|
||||
.insert(cookie_hash, account_session.clone());
|
||||
}
|
||||
let mut headers = HeaderMap::new();
|
||||
headers.insert(
|
||||
header::COOKIE,
|
||||
HeaderValue::from_static("ghostlight_session=browser-session"),
|
||||
);
|
||||
assert_eq!(
|
||||
authenticated_session(&headers, &state).await,
|
||||
Some(account_session)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn generated_start_selection_uses_only_server_owned_ids() {
|
||||
let opening = OpeningSuggestion {
|
||||
|
|
@ -2870,6 +2951,7 @@ mod tests {
|
|||
unused_invite_hashes: BTreeSet::new(),
|
||||
provisioned_invite_hashes: BTreeSet::new(),
|
||||
session_hashes: BTreeSet::from(["left".into(), "right".into()]),
|
||||
session_aliases: BTreeMap::new(),
|
||||
session_campaigns: BTreeMap::from([
|
||||
("left".into(), left.id),
|
||||
("right".into(), right.id),
|
||||
|
|
@ -2895,6 +2977,7 @@ mod tests {
|
|||
row,
|
||||
state: auth_state,
|
||||
})),
|
||||
heimdall: Arc::new(HeimdallClient::fixture()),
|
||||
deepseek_status: "fixture".into(),
|
||||
compiler: None,
|
||||
assessor: None,
|
||||
|
|
@ -2929,6 +3012,7 @@ mod tests {
|
|||
unused_invite_hashes: BTreeSet::from(["invite".into()]),
|
||||
provisioned_invite_hashes: BTreeSet::from(["invite".into()]),
|
||||
session_hashes: BTreeSet::new(),
|
||||
session_aliases: BTreeMap::new(),
|
||||
session_campaigns: BTreeMap::new(),
|
||||
session_campaign_ids: BTreeMap::new(),
|
||||
};
|
||||
|
|
@ -2971,6 +3055,7 @@ mod tests {
|
|||
unused_invite_hashes: BTreeSet::new(),
|
||||
provisioned_invite_hashes: BTreeSet::from(["consumed".into()]),
|
||||
session_hashes: BTreeSet::new(),
|
||||
session_aliases: BTreeMap::new(),
|
||||
session_campaigns: BTreeMap::new(),
|
||||
session_campaign_ids: BTreeMap::new(),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -51,13 +51,11 @@ institutions, two clocks, explicit gaps, and branch assumptions. It remained
|
|||
an uncommitted revision-0 preview with `requires_approval: true` until the
|
||||
tester explicitly approved it.
|
||||
|
||||
The invite/session authority is persisted separately in `service/auth.cc`.
|
||||
Only hashes of invite and session tokens enter CultCache. Consuming an invite
|
||||
atomically replaces that auth row, so daemon restart neither resurrects a used
|
||||
invite nor invalidates an established session. A disposable HTTP acceptance
|
||||
run verified unauthenticated `401`, pre-approval compiler surface, explicit
|
||||
approval, campaign/evidence persistence, session survival across restart, and
|
||||
`401` on consumed-invite reuse.
|
||||
Heimdall owns public identity and Discord OAuth. The browser receives a
|
||||
one-time completion code rather than a provider token. Ghostlight redeems that
|
||||
code server-to-server, verifies the EdDSA `aud=ghostlight` access claim against
|
||||
Heimdall's published JWKS, and maps the account to stable app-local campaign
|
||||
authority. Only hashed local session aliases enter `service/auth.cc`.
|
||||
|
||||
## Body and faculty map
|
||||
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@ stake prose alone never impersonates world mutation.
|
|||
- optional operator inspector for evidence, topology, state versions, model receipts, rejected proposals, and private spoiler traces.
|
||||
- Do not expose model chain-of-thought or secrets.
|
||||
- Serve the embedded web bundle on TCP `8831`. Firewall access is limited to Starfire’s private LAN and `10.77.0.0/24`; no public listener or Yggdrasil web gateway is added.
|
||||
- Use provisioned single-use invite links that establish separate HttpOnly sessions. Campaigns are single-player; simultaneous co-op is outside the MVP.
|
||||
- Use Heimdall's Discord browser-completion path to establish account-bound HttpOnly sessions. Ghostlight verifies `aud=ghostlight` claims locally and owns campaign authorization. Campaigns are single-player; simultaneous co-op is outside the MVP.
|
||||
- Run `GhostlightDungeon` as a normal detached process under the Starfire operator account. Record its PID, executable, and logs; explicit start, stop, health, release, and rollback scripts own lifecycle. ACL the runtime root to administrators and that operator account.
|
||||
- Read the DeepSeek key from stdin during setup, protect it with machine-scoped DPAPI plus file ACLs, and never place it in source, arguments, logs, or environment projections.
|
||||
- Build immutable release directories from the exact Git commit, switch the active release through the guarded junction, and record provenance in CultCache plus the immutable release manifest. Process restart is explicit; Windows service installation and automatic boot recovery are outside this MVP by operator choice.
|
||||
|
|
|
|||
153
web/dist/assets/index-CngTndFJ.js
vendored
Normal file
153
web/dist/assets/index-CngTndFJ.js
vendored
Normal file
File diff suppressed because one or more lines are too long
153
web/dist/assets/index-DT1ZfEs6.js
vendored
153
web/dist/assets/index-DT1ZfEs6.js
vendored
File diff suppressed because one or more lines are too long
2
web/dist/index.html
vendored
2
web/dist/index.html
vendored
|
|
@ -1,5 +1,5 @@
|
|||
<!doctype html>
|
||||
<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>GhostlightDungeon</title> <script type="module" crossorigin src="/assets/index-DT1ZfEs6.js"></script>
|
||||
<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>GhostlightDungeon</title> <script type="module" crossorigin src="/assets/index-CngTndFJ.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-B7Qh0xAi.css">
|
||||
</head>
|
||||
<body><header><p class="eyebrow">STARFIRE / PRIVATE VERSE</p><h1>GhostlightDungeon</h1><p id="status" role="status" aria-live="polite">Reading the world…</p></header><main>
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ function renderCommandReceipt(body: any) {
|
|||
}
|
||||
|
||||
function showAuthenticationGate() {
|
||||
const message = "This laboratory requires an unused invite link.";
|
||||
const message = "Sign in through Heimdall to enter the public demo.";
|
||||
status.textContent = message;
|
||||
compiler.hidden = true;
|
||||
composer.hidden = true;
|
||||
|
|
@ -143,13 +143,40 @@ function showAuthenticationGate() {
|
|||
host.hidden = false;
|
||||
const gate = node("article", undefined, "card");
|
||||
gate.append(
|
||||
node("h2", "Private campaign laboratory"),
|
||||
node("h2", "Ghostlight Dungeon public demo"),
|
||||
node("p", message),
|
||||
node("p", "Open a single-use tester invitation on this device. The resulting session stays separate from every other player's campaigns.", "quiet"),
|
||||
node("p", "Heimdall uses Discord only to establish your GameCult identity. Ghostlight keeps your campaigns isolated from every other account.", "quiet"),
|
||||
);
|
||||
const login = node("button", "Continue with Discord") as HTMLButtonElement;
|
||||
login.type = "button";
|
||||
login.addEventListener("click", () => { void startHeimdallLogin().catch(reportClientFailure); });
|
||||
gate.append(login);
|
||||
host.replaceChildren(gate);
|
||||
}
|
||||
|
||||
async function startHeimdallLogin() {
|
||||
const response = await fetch("/api/auth/heimdall/start", { method: "POST" });
|
||||
const body = await decodeResponse(response);
|
||||
if (!response.ok || typeof body?.authorization_url !== "string") {
|
||||
throw new ServerResponseFailure(responseError(body, "Heimdall could not start Discord sign-in."));
|
||||
}
|
||||
window.location.assign(body.authorization_url);
|
||||
}
|
||||
|
||||
async function redeemHeimdallReturn() {
|
||||
const fragment = new URLSearchParams(window.location.hash.slice(1));
|
||||
const completionCode = fragment.get("heimdall_completion_code");
|
||||
if (!completionCode) return;
|
||||
const response = await fetch("/api/auth/heimdall/redeem", {
|
||||
method: "POST",
|
||||
headers: { "content-type": "application/json" },
|
||||
body: JSON.stringify({ completion_code: completionCode }),
|
||||
});
|
||||
const body = await decodeResponse(response);
|
||||
history.replaceState(null, "", `${window.location.pathname}${window.location.search}`);
|
||||
if (!response.ok) throw new ServerResponseFailure(responseError(body, "Heimdall sign-in could not be adopted."));
|
||||
}
|
||||
|
||||
async function refresh() {
|
||||
const response = await fetch("/api/surface");
|
||||
if (response.status === 401) { showAuthenticationGate(); return; }
|
||||
|
|
@ -456,4 +483,4 @@ document.querySelector<HTMLButtonElement>("#load-operator")!.addEventListener("c
|
|||
renderEveSurface(surface, document.querySelector<HTMLElement>("#operator-output")!, { body: document.body, clientId: "ghostlight.operator", statusElement: status });
|
||||
});
|
||||
});
|
||||
void refresh().catch(reportClientFailure);
|
||||
void redeemHeimdallReturn().then(refresh).catch(reportClientFailure);
|
||||
|
|
|
|||
Loading…
Reference in a new issue