Zoo

staging

← back to the zoo

1. One sign-in, every app

Sign in once at account, and every app knows who you are without asking again.

Sign-in is one call: rc.me() in a wasm app (auth_user() through account's shim in PHP). A signed-in browser is silently handed a token for that app; there is no sign-in page per app and no password anywhere.

This is the code serving the zoo right now: the bytes this very program was built from (each file is embedded when the zoo is compiled), at commit 55c71513c5 (staging). The zoo's own self-check fetches this page and compares it byte for byte with the file it runs.

e01_one_sign_in.odin sha256 c879db2fbcff · raw

1package main
2
3// Exhibit 1. The whole of sign-in, for any app, is one call: `me, signed_in := rc.me()` (a User, or
4// a visitor). The second app here is the sample `zoo-broken`, plain PHP on php-fpm signing in through
5// account's shim, while the zoo is Odin compiled to wasm signing in through the host's port of it:
6// so this card shows one sign-in across both runtimes.
7
8import "ratcloud:rc"
9
10e01 :: proc() -> Exhibit {
11	return {
12		n = 1, wing = "Identity", kind = "human",
13		title = "One sign-in, every app",
14		promise = "Sign in once at account, and every app knows who you are without asking again.",
15		block = "Sign-in is one call: rc.me() in a wasm app (auth_user() through account's shim in PHP). A signed-in browser is silently handed a token for that app; there is no sign-in page per app and no password anywhere.",
16		src = {"e01_one_sign_in.odin", #load("e01_one_sign_in.odin", string)},
17		show = proc(me: ^rc.User) -> string {
18			return cat(`<p>Who am I, here on the zoo:</p>`, person(me),
19				`<p>Now open <a href="`, h(rc.app_url("zoo-broken")), `/" target="_blank" rel="noopener">a second app on its own address</a> (zoo-broken, a PHP app; the zoo itself is compiled to wasm): it should show the same card, with no prompt.</p>`,
20				seen_button(1, me, "Both cards showed me"))
21		},
22	}
23}