SleekSky Developers

Sign in with the platform

Any app on the platform can let people sign in with their platform account instead of building its own login. The platform only says who someone is. Your app decides what they may do, and keeps its own session.

It's opt-in. An app turns it on in its sleeksky.json:

{ "id": "myapp", "name": "My App", "platform_signin": true, "signin_path": "/login", … }

signin_path is optional: the path on your app that starts signing in (step 1 below). With it, your app appears in each person's Your apps list in the console, and opening it there signs them straight in.

Like the rest of the manifest, it takes effect once it's reviewed and approved. Without it, /auth shows "This app doesn't use SleekSky sign-in", and the code exchange answers 403. An app that doesn't opt in runs its own sign-in (it can still send its email codes through POST https://sky/api/app/mail/signin-code over env.SKY).

The console's Open app button just opens your app's address. If the person isn't signed in to your app, send them to /auth. Account owners, and people your app has already accepted, come straight back without seeing a page if they're signed in to the platform, so opening the app takes one click.

Who can sign in

By default anyone with an email address can sign in. An account's owners can limit this for each app under the app's Settings → Sign-in: only people with an email at listed domains (for example acme.com), plus any exception addresses they add. Each app has its own rule. The account's owners and SleekSky support can always sign in.

Someone outside the rule sees a message on the sign-in page and never gets a code, and /auth/token answers 403 for them. The rule doesn't end sessions your app already started: it applies the next time someone signs in.

How it works

Open the app (not signed in)302 to /auth?app&redirect&stateGET /auth303 to your redirect?code&stateGET redirect?code&statePOST https://sky/auth/token {code, redirect} (over env.SKY){email, name, owner, staff}Signed inSign-in page, branded as your product.Skipped if already signed in to the platform.Check state, start your own sessionBrowserYour appPlatformBrowserYour appPlatform

Integrate it in two steps (after opting in)

1. Send the person to sign in

GET {CONSOLE_URL}/auth?app={APP_ID}&redirect={your callback URL}&state={random}
Parameter
app Your instance id: the APP_ID you were deployed with.
redirect The full URL to send them back to. It must be https and on one of your own addresses: <sub>.<platform domain>, <sub>--<label>.<platform domain>, or one of your verified custom domains. Anything else is refused. Use the host the person is on, so your session cookie lands there.
state A random value. Store it in a short-lived cookie, and check it when they come back. Up to 512 characters.
prompt=login Optional. Always show the sign-in form, even if they're already signed in to the platform (for example, a "switch account" link).
login_hint Optional. An email address to fill in.

2. Handle the callback

They come back to redirect?code=…&state=…:

  1. Check that state matches your cookie, then clear the cookie.
  2. From your server, exchange the code over your SKY binding. Send it within 60 seconds; it works only once and only for your app. The binding tells the platform which app is calling, so there's no token:
env.SKY.fetch("https://sky/auth/token")
POST, Content-Type: application/json

{ "code": "<code>", "redirect": "<exactly the redirect you sent>" }
{ "email": "ana@acme.com", "name": "Ana", "owner": true, "staff": false }
Field Meaning
email Verified: they proved they can read this mailbox.
owner They are an owner of the account that has your app. Usually this means "admin" in your app. The platform doesn't send you a list of owners: make someone an owner (one your own admins can't remove) when they sign in with owner: true, and stop treating them as one when a later sign-in says false.
staff Platform support staff. The platform logs this on your app's activity. Give them access only if your app supports that, and log it where the owners can see it.
  1. Map them to your own users and roles, then start your own session. People who are neither owner nor staff are just verified emails: let them in only if they're users of your app (for example, someone an owner invited).

An error is 4xx with { "error": "…" }: the code expired, was already used, belongs to another app, or the redirect doesn't match. Send the person to sign in again.

3. Tell the platform when you remove someone (optional)

When your app removes or disables one of its users, or turns away someone who just signed in (they're not one of your users), report it from your server:

env.SKY.fetch("https://sky/api/app/signins/remove")
POST, Content-Type: application/json

{ "email": "ana@acme.com" }

→ { "ok": true, "removed": true }. It takes your app off their Your apps list, and their next sign-in to your app asks them to continue again. It doesn't affect their platform account or other apps, and it doesn't end sessions: those are yours to end. If they come back and your app accepts them, the next exchange adds the app back.

Without this call, a removed person keeps a tile that opens your app, which then turns them away.

Your apps

The console lists, for each person, the apps that use platform sign-in with a signin_path and that they own or have signed in to (counted when your server exchanges a code, so it means your app accepted them). Each tile opens https://<your address><signin_path>. Tiles are ordered by when each app was last used (a sign-in, or opening it from the list), which the tile shows. People can remove an app from their own list. Only they see their list: owners never see which other apps their users use.

Icons

Each tile shows the app's own icon when it has one, otherwise its first letter on the product's colour. Once a day (and right after an app is set up) the platform looks for it:

  1. the manifest's icon path, if the app sets one ("icon": "/logo.png"), else
  2. the app's home page: its <link rel="apple-touch-icon">, then its largest <link rel="icon">, then /apple-touch-icon.png and /favicon.ico. Not og:image: that's a share picture, not a logo.

Only PNG, JPEG, WebP, GIF, ICO or SVG up to 200 KB, from the app's own host (pictures are preferred over SVG). The platform keeps a copy and serves it from the console, so people's consoles never load images from your app. Set icon when your home page isn't public or shows your product's icon rather than the customer's: serve the customer's logo at that path. Staff can fetch it again at once from sudo admin (Refresh icon).

Example (Cloudflare Worker)

const CB = "/auth/callback";

if (url.pathname === "/login") {
  const state = crypto.randomUUID();
  const to = new URL("/auth", env.CONSOLE_URL);
  to.search = new URLSearchParams({ app: env.APP_ID, redirect: url.origin + CB, state }).toString();
  return new Response(null, { status: 302, headers: {
    location: to.toString(),
    "set-cookie": `auth_state=${state}; Path=${CB}; HttpOnly; Secure; SameSite=Lax; Max-Age=600`,
  } });
}

if (url.pathname === CB) {
  const cookie = /(?:^|;\s*)auth_state=([^;]+)/.exec(req.headers.get("cookie") || "")?.[1];
  if (!cookie || cookie !== url.searchParams.get("state")) return new Response("Please sign in again.", { status: 400 });
  const res = await env.SKY.fetch("https://sky/auth/token", {
    method: "POST", headers: { "content-type": "application/json" },
    body: JSON.stringify({ code: url.searchParams.get("code"), redirect: url.origin + CB }),
  });
  const who = await res.json(); // → { email, name, owner, staff }
  const user = await findOrCreateUser(who);   // your rules
  return startSession(user);                  // your session cookie
}

SleekSite's own version is in sleeksite-app/src/index.ts (/_admin/auth/start and /_admin/auth/callback).

The sign-in page

The page is on the console's domain, so platform cookies never reach tenant hosts. It's branded from your product, as data only:

  • the app's name ("Sign in to Acme Bakery"), and the product's name underneath
  • the product's colour (color in sleeksky.json: ember, cobalt, lagoon, grape, teal, gray)
  • the product's terms and privacy links, in the footer
  • "You'll return to <your host>", so people can see where they're going

Apps can't add HTML, CSS or scripts to the page. To change how it looks, change the product in sleeksky.json.

People sign in with an emailed 6-digit code, the same as the console. That also signs them in to the platform, so the next app they open asks only for a click. Someone who is signed in but isn't an owner of your app's account always sees Continue as … first. The platform never tells an app who a visitor is without them choosing to.

Notes

  • Sessions are yours. After the exchange, the platform isn't involved in your requests. Signing out of your app doesn't sign them out of the platform, and signing out of the platform doesn't sign them out of your app.
  • Deep links: if a signed-out person opens any page, send them to /auth, keep the page they wanted in your state cookie, and return them there after the callback. Check that it's a path on your own host.
  • Local development: with APP_URL_TEMPLATE set, the app's local origin (for example http://localhost:8799) is also accepted as a redirect.