Acting for a person
Your app's back end reaches people's things, like their files and contacts, by acting for whoever is using the app. It never gets more than that person has, or more than its grants allow.
Naming who it's for
Send the app's token and the person's Solel id with each call to the core:
Authorization: Bearer $SOLEL_APP_TOKEN
X-Solel-Person: <their Solel id>
Your back end is told who's using the app in X-Solel-User on every request Solel passes to it, so pass that on. Check X-Solel-Proxy-Token before you trust it; see Back ends and workers.
func callCore(r *http.Request, person, method, path string, body io.Reader) (*http.Response, error) {
req, err := http.NewRequestWithContext(r.Context(), method, os.Getenv("SOLEL_CORE_URL")+path, body)
if err != nil {
return nil, err
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("SOLEL_APP_TOKEN"))
req.Header.Set("X-Solel-Person", person)
return http.DefaultClient.Do(req)
}
What Solel checks
- The app is on, and installed for everyone or for this person. An app installed for one person can only act for them.
- The person can use Solel: their account is there, isn't turned off, and hasn't expired.
- Both allow it. The app can do what the person may do and its grants allow, never more. An app acting for a child can't change what a child can't, and one with
contacts.readcan't change contacts.
When a check fails, the core answers 400 if X-Solel-Person is missing, 401 for a token it doesn't know, and 403 otherwise, with {"error": "…"} saying why.
Where it works
| Area | Endpoints |
|---|---|
| Files | /api/files/… |
| Calendar | /api/calendar/…. An app installed for one person may leave out X-Solel-Person |
| Contacts | /api/contacts/… |
| Notifications and badges | PUT /api/notifications/badge |
| People and teams | /api/groups, the /api/people endpoints that page lists, GET /api/mailhost and GET /api/audit |
| Sign in with Solel | /api/apps/sign-in and what's under it |
| Asking Jethro | /api/jethro, /api/jethro/face, /api/jethro/ask |
A few endpoints take the token alone, because they aren't about one person: sending notifications to people (POST /api/notifications/app), listing the household's people (GET /api/people/app), the app's own install (GET /api/apps/self), and saying who's signing in (GET /api/apps/sign-in/people/{id}).
Changes show where they came from
What an app changes is marked with it. A contact your app edits says app:<your app's name> in its via, and changes to people go in the activity log under the person the app acted for.