ident
All repositories: gitoria
9.9 KB
# ident: what it is and how it worksident is the sign-in for every WorldAPI app: tickets, notes, calendar, gitoria, tracker and the rest. You sign in to ident once. After that, every app knows you through ident, and you never type a password anywhere.This page is for people who use ident and for people who build an app on it. The creator's own words are in CONCEPT.md in the repository. This page explains them and does not change them.## The idea in one paragraphYou sign in to ident with your email address and a code that ident mails you. There is no registration and no password: the first code you type in creates your account. Inside ident you have one or more identities. When an app asks who you are, you pick one of your identities, and that pick is your sign-in to the app. The app learns the identity's short id and, if you filled them in, its nickname and names. The app never learns your email address.## Your account- **Signing in.** You type your email address. ident mails you a 6-digit code, and you type it in. The code works once and for 10 minutes.- **No registration.** The first right code for a new address creates the account and a first identity called "Default". ident then shows that identity's fields and says that all of them are optional.- **You stay signed in.** A sign-in to ident lasts 99 years, and so does a sign-in to a WorldAPI app. Nothing signs you out on its own, and no update signs you out. You sign out only when you choose to.- **Signing out.** "Sign out everywhere" ends every session of your account on every device at once: open pages switch to signed out without a click. In ident's Inbox, every app has its own page with the button "Sign out of this app". It removes only that app's connection to your identity. If you sign in to the app again later, you get the same id again.- **Time zone.** ident takes your browser's time zone at your first sign-in. You can change it on your account page. Your daily mail of notifications comes at 17:00 in that zone.## IdentitiesAn identity is a face you show to apps. You can have as many as you like, for example one for work and one private.- Every field is optional: identity name, nickname, first name, last name and a picture.- The **identity name** is only for you. It is what you see in ident and in the selector. Apps never get it.- Your **default identity** is your oldest one. If you never make another one, that one is always used.- You cannot delete your last identity.## One id per identity, the same in every appEvery identity has one public short id: 5 characters, for example `a68sz`. It is made with the identity and never changes.The id is **the same in every app**. A person can say it aloud or type it, and others find them by it in any app. Upper and lower case do not matter when it is typed. The letters i, l, o and the digits 0 and 1 are never used, so it cannot be misread on a phone.Only the id is public. Your email address is never handed out. Your names and picture go only where you fill them in and an app asks for them.(An early version gave each identity a different id in every app. That was dropped; every app now uses the one short id.)## How you sign in to an appThere are two ways. They end the same way: the app's server gets a one-time code and swaps it at ident for your identity's id.### 1. The selector at the top rightEvery WorldAPI app shows the ident selector at the top right, both when you are signed in and when you are not.- Signed in to ident already: you open the selector, it lists your identities, and one tap on an identity signs you in to the app. The page does not change.- Not signed in to ident yet: the selector panel shows ident's own sign-in right there, with the email field and the code field and the note "This signs you in to ident." You are not sent to another website. After the code, you pick your identity in the same panel and you are back in the app, signed in.- A brand-new email address: after the code, ident asks you to create your identity. Only then does it take you to ident's website, in the same tab, and it brings you back to the app when you are done.Test hook for app builders: each identity in the choice list is `#chooselist li .choose` (a link in the selector panel, a button on ident's own page). It is a stable hook for app tests; do not remove or rename it.### 2. The "Log in with ident" buttonAn app can also send you to ident with a button. ident signs you in if needed, you pick an identity, and ident sends you straight back to the page you came from.## For people who build an app### Register your appOn ident, open **Apps** and press "Register an app". Give it a name and the web addresses (origins) it runs on, for example `https://notes.worldapi.org`. An app on many subdomains registers one wildcard origin, for example `https://*.example.org`.You get two things:- an **API key** (`pk_…`), which is public and goes into your pages;- a **secret** (`sk_…`), which stays on your server only. ident shows it once. "New secret" makes a new one and kills the old one at once.### Put the selector on your page```html<script src="https://ident.worldapi.org/selector.js"></script><ident-selector key="pk_…" return="https://your.app/login/callback"></ident-selector>```When the person picks an identity, the element fires the event `ident-login` with a one-time code in `event.detail.code`. Send that code to your server. Your server swaps it (see below).Your page tells the selector whether your own site is signed in: set the attribute `logged-in`, or the property `loggedIn = true`. Set it to `false` (or call `reset()`) when the person signs out of your site. The selector sets no cookie of its own.If the person signs in inside the panel, ident sends the whole page to your `return` address with `?ident_code=<code>` added. Your server swaps that code the same way.The selector is plain JavaScript and plain HTTP, so any website can use it, whatever it is built with. You can restyle it with CSS custom properties such as `--ident-accent`, `--ident-background` and `--ident-font`, and with `::part(button)` or `::part(panel)`.### Or use the buttonSend the browser to:```https://ident.worldapi.org/login?key=pk_…&return=https%3A%2F%2Fyour.app%2Flogin%2Fcallback```The return address must be on one of your app's origins, or ident refuses with an error page and does not redirect. When the person has picked an identity, ident sends the browser to your return address with `?ident_code=<code>`.### Swap the code on your serverThe code works once, for 60 seconds, and only for your app. Swap it from your server, never from a page, because the call carries your secret:```POST https://ident.worldapi.org/api/exchange{"key":"pk_…","secret":"sk_…","code":"…"}200 {"identity":"a68sz"}```Store `a68sz` with your own user. That is the person's id, and it is the same id in every app.To also get the names the person filled in, ask for them:```POST https://ident.worldapi.org/api/exchange{"key":"pk_…","secret":"sk_…","code":"…","fields":["nickname","firstname","lastname"]}200 {"identity":"a68sz","nickname":"Caro","firstname":"Caroline","lastname":null}```A field the person left empty comes back as `null`. Later you can ask again for someone who has signed in to your app before (they may have filled in a name since):```POST https://ident.worldapi.org/api/profile{"key":"pk_…","secret":"sk_…","identity":"a68sz","fields":["nickname"]}```Errors: 401 for a wrong key or secret; 400 for a used, expired or unknown code (the message names the problem); 404 from `/api/profile` for an identity that never signed in to your app.If your app needs more about a person, such as a postal address, your app asks for it itself. ident does not hand out more.**Keep the person signed in.** When your callback receives a code, do not sign out the session the browser already has. Put the new identity into that same session. Your own sign-in should also last 99 years.### Send notificationsYour server can send a notification to an identity that has signed in to your app:```POST https://ident.worldapi.org/api/notify{"key":"pk_…","secret":"sk_…","identity":"a68sz","name":"New comment","text":"Bea commented on your post","link":"https://your.app/post/7","urgent":false}200 {"id":"…"}```- `name` is the kind of notification, for example "New comment". `text` is up to 2000 characters. `icon` and `link` are optional web addresses.- By default a notification goes into the person's ident inbox and into one daily mail at 17:00 in their time zone.- `"urgent": true` mails it at once (and will push it to the phone once push exists).- Before ident can push a kind, register it with its default channels: `POST /api/kinds {"key","secret","kinds":[{"name":"New comment","push":true,"email":false}]}`.- The person decides in the end. In ident's **Inbox**, every app has its own page with a push switch and an email switch per kind, and one switch that overrides all of them.### Invite people to a projectYour server can make an invitation link: `POST /api/invites {key, secret, project, role, return}`. ident can also mail it for you if you add `email`. Whoever opens the link signs in to ident, picks an identity and lands at your `return` address with a code. The repository's README has the details.## What ident never does- It never gives an app your email address.- Its API never gives an app's server your identity name. The selector shows your identity names on the app's page only so that you can pick one.- It never signs you out on its own. Logins last 99 years.- It never shows your email sign-in code to an app. That code goes to your mailbox only.- It never answers the selector for a website that is not registered with the key it uses.## Where to look next- **CONCEPT.md** in the repository: the creator's concept, the source of truth.- **README.md** in the repository: how ident itself is built, run, tested and deployed.- **Tickets:** https://tickets.worldapi.org/ident.worldapi.org
Branches
Latest commits
- 0f6d1592Merge branch 'f18b-shell-session' into mainIdent
- 19868218|||PR ident#39 shell reads its session member instead of a cross-file emitmre
- 5d1b3fedMerge branch 'v61-day61' into mainIdent
- 83faeb15|||PR ident: vendor Hybriel day61mre
- b2572b34Merge branch 'v59-day59' into mainIdent
- 67cf016d|||PR ident: vendor Hybriel day59mre
- 600c043dMerge branch 'v58-day58' into mainIdent
- 365f8c80|||PR ident: vendor Hybriel day58mre
- 585126e5Merge branch 'f16-setf' into mainIdent
- 953bf03a|||PR ident setF mirror dropped (hybriel#370)mre
- a1419d9cMerge branch 'f15-navigate' into mainIdent
- 3b3e451f|||PR ident#36 navigate to the app instead of location.assignmre
- e36f4516Merge branch 'f14-online' into mainIdent
- 2c5eac91|||PR ident#38 online state without probe timermre
- bf1980f2Merge branch 'v56-day56' into mainIdent
- 62ae0adf|||PR ident: vendor Hybriel day56mre
- 0d18abc4Merge branch 'f13-avatar' into mainIdent
- 2a99730a|||PR ident#37 avatar in hlmre
- fa4ed25bMerge branch 'f11-upsert' into mainIdent
- 8f3d9bc9|||PR ident#42 keyed upsert and removemre