Users and access¶
How you and your colleagues get into LeanCPMS Cloud, what each of you may
do, and how you manage that yourselves. It is written for an
organization's administrator: a member with the write role who looks
after the organization's people and keys. You need no programming
experience, only a terminal for the command line.
The examples use a made-up organization acme and addresses at
example.com. Anyone who runs an instance, LeanCPMS Cloud's operator or
someone hosting their own, finds the rest in
Operators and self-hosting.
This describes the code as it is (leancpms-cli 0.1.7).
Contents
- People, organizations and roles
- Logging in to the portal
- Logging in on the command line
- Keys
- Common tasks
1. People, organizations and roles¶
A person is one e-mail address. There are no passwords and no user names. To log in you type your address, LeanCPMS e-mails you a short one-time code, and you type the code. Everything you do, in the portal and on the command line, goes back to that one identity.
Your organization is the company that owns the charging stations: its sites, charge points, price list, sessions, receipts and monthly settlements belong to it, and no other organization can see them.
Nobody signs up. An address can log in only after someone has made it a member of the organization. LeanCPMS Cloud's operator, Forsslund Systems AB, adds your organization's first administrator; from then on your administrators add and remove colleagues themselves. An address that is not a member gets no code at all, not even an error message, so the login page does not reveal who has an account.
A person can be a member of several organizations, acme and globex,
say. Each membership has a role:
| Role | In the portal | On the command line |
|---|---|---|
read (the default) |
sees everything about the organization | may only look |
write |
the same: the portal only reads, whatever the role | may also act: change the price list and sites, manage members and keys, stop sessions |
So the role does not change what you see; it decides whether you may
change things with cpms.
Each membership records who added it. Removing a person does not
remove the members they added: when someone leaves, look at
cpms members list and decide about the people they brought in.
2. Logging in to the portal¶
- Open
https://portal.leancpms.com. - Type your e-mail address. A code is e-mailed to you; type it on the next page. If no mail comes, the address is not a member (or has a typo): ask whoever was to add you.
- With one organization you land on its overview; with several, on a list of them.
A login lasts 90 days on that browser, or until you log out (top right) or your last membership is removed. The portal shows, for each organization: an overview with live state, sessions, receipts and the monthly settlements. It only reads. Its texts follow the browser's language (Swedish or English).
Because the code goes to your e-mail, your mailbox is your password: whoever can read your mail can log in as you.
LeanCPMS Cloud answers on these addresses:
| Address | For whom | What |
|---|---|---|
https://portal.leancpms.com |
people | the portal, and the page where you approve cpms login |
https://api.leancpms.com |
machines | the JSON API (docs at /api/v1/docs) and the command line, which uses it without being told |
wss://ocpp.leancpms.com |
charge points | the OCPP connection |
your own domain, e.g. charge.example.com, or acme.leancpms.com |
drivers | the station list, the QR pages and the driver API |
The portal answers only on portal.leancpms.com. Asked for on any other of
the names, it redirects there, so a driver's domain never shows a login
page.
3. Logging in on the command line¶
cpms is a small program you install on your own computer; it talks to
LeanCPMS Cloud for you. The command line
says how to install it. Then:
cpms login
This is the same "device login" as gh auth login:
cpmsprints a page address and a code, such asKTRW-MZPB, and opens the page in your browser if it can (--no-browseronly prints it, for a server you reach over ssh).- In the browser you land on
portal.leancpms.com/portal/cli/. Log in with your e-mail code if you are not already logged in. - The page shows the code, what asks for the key (
cpms on <your computer's name>), when, and from which internet address. Check that the code is the one in your terminal. Approve only a login you just started yourself: whoever started it gets a key in your name. - Choose the organization and what the key may do. A
writemember sees "may look and act (write)" and "may only look (read)"; areadmember only the latter.--scope readon the command line preselects read. - Approve. The terminal continues by itself and saves the key.
The code is valid for ten minutes and works once. Ten wrong codes in an hour lock the approval page for you for an hour.
The key is saved in ~/.config/cpms/config.toml, readable only by you.
Logging in again replaces it; the old key keeps working until you revoke
it (cpms keys revoke).
$ cpms whoami
anna@example.com: write key 3f9a1c2e (cpms on anna-laptop) for organization acme on LeanCPMS Cloud (https://api.leancpms.com)
$ cpms logout
revoked key 3f9a1c2e
removed profile [default] from /home/anna/.config/cpms/config.toml
whoami says which key is in use: whose, for which organization, read or
write, and on which instance. logout revokes that key on the server and
forgets it.
A member of several organizations logs in once per organization, since a key is for one organization, and gives each login a name of its own (a profile):
cpms login --profile globex
cpms --profile globex sessions
Without --profile, cpms uses the login called [default], the one
plain cpms login saves.
4. Keys¶
Everything that is not a person in a browser, cpms included, talks to
LeanCPMS with an API key. There are two kinds you will meet:
- Your personal key, which
cpms logingets for you. It is yours, for one organization, and named after the computer, such ascpms on anna-laptop. Your role caps it: areadmember gets only keys that may look. - A key for an integration, an organization key that belongs to no
person: for a script, a dashboard, an accounting export or an AI agent.
You make it with
cpms keys issue, and it records who made it.
A key looks like lcp_3f9a1c2e_<43 more characters>. The part after
lcp_, here 3f9a1c2e, is its prefix: it is not secret, it names the
key in lists, and it is what you revoke. The rest is the secret. LeanCPMS
stores only a hash of the key, so a key is shown exactly once, when it is
made. Lose it and you make a new one.
A read key may only look. A write key may also act. Listing and
managing members and keys needs a write key.
Three rules are worth remembering:
- Removing a member revokes their keys, and every key made with them. That includes the integration keys they issued, so nobody leaves behind working keys when they leave.
- Lowering a role from
writetoreaddoes the same for the member'swritekeys and every key made with them. - Revoking one key revokes only that key. Keys issued with it keep working.
The complete rules, and what each kind of key may do, are in Operators and self-hosting.
5. Common tasks¶
Each task here needs your personal write key. cpms <command> --help
lists every option.
Add a colleague¶
cpms members add ben@example.com --org acme # read (the default)
cpms members add carla@example.com --org acme --role write # may also act
--org acme is needed even though your key is already for acme.
Nothing is e-mailed when a member is added. Tell the person yourself to go
to https://portal.leancpms.com and log in with that address, and, if
they will use the command line, to install cpms and run cpms login.
cpms members list shows each member's role, whether the account is
active, when they were added and by whom. You see your own organization's
members only, and nothing about their memberships elsewhere.
Change a role¶
cpms members set-role ben@example.com --org acme --role write
cpms members set-role ben@example.com --org acme --role read
Raised to write, Ben runs cpms login again to get a write key; his
read key stays as it was. Lowered to read, his write keys are revoked
at once, and so is every key issued with them; the output lists their
prefixes. Look at cpms keys list first if he made keys for integrations.
Remove someone¶
cpms keys list # first: which keys did they issue?
cpms members list # and whom did they add?
cpms members remove ben@example.com --org acme
This revokes Ben's personal keys for acme and every key issued with
them, and lists the revoked prefixes. If it was his last membership his
account is switched off and his portal login ends (if he also has a
driver account with some organization, that account stays, and the portal
sends him no more login codes and shows him nothing). The members he added
stay: decide about them separately. Any integration running on a key Ben
issued stops now; give it a new key first.
Use several computers¶
Run cpms login on each computer. Each gets its own personal key, named
after the computer, so you can revoke one without touching the others. Do
not copy the config file between computers: the same key in two places
cannot be revoked in one of them only.
When a computer is lost or stolen¶
The lost computer holds your personal key in ~/.config/cpms/config.toml,
and perhaps a portal login in its browser.
- Secure your e-mail first. Whoever reads your mail can log in as you.
-
Revoke the key. From another computer, log in (
cpms login), then find the key named after the lost computer and revoke it:cpms keys list # prefix organization scope name personal (owner) issued by created ... # 3f9a1c2e acme write cpms on anna-laptop anna@example.com anna@example.com ... cpms keys revoke 3f9a1c2eA
readmember asks a colleague withwrite, or the operator, to do it. -
Integration keys whose secrets were on that computer (in another profile, a script, a
.envfile) must be revoked too: revoking your personal key does not revoke keys issued with it. -
The portal login in its browser lasts up to 90 days and cannot be ended from elsewhere by you. The operator can end it by removing your memberships, which switches the account off, and adding you again. That also revokes your personal keys and every key issued with them, so decide first which integration keys must be issued anew. The portal only reads, but it shows sessions and receipts, which hold drivers' personal data.
A key for an integration¶
cpms keys issue --name dashboard --scope read # prints the secret once
The key is for your own organization. The default scope is write, so
say --scope read when looking is enough. The secret is printed on its
own line, so it can go straight into a file or a secret store:
cpms keys issue --name ci --scope read > ci-key.txt. The integration
then uses it in the environment variable CPMS_API_KEY
(The command line, "Scripts, CI and agents").
A key you issue lives only as long as your membership. For a script
of your own or a test, that is fine. For an integration that must keep
working when people come and go (a dashboard, an accounting export, an
agent), ask the operator for the key instead, saying what it is for and
whether it needs write. It appears in your cpms keys list with
"operator" as its issuer, or none, and your organization can still revoke
it.
Revoke a key¶
cpms keys list # find its prefix
cpms keys revoke 7b2d90aa
It stops working at once. Only that key is revoked: keys issued with it
keep working until revoked themselves, or until their maker's membership
ends. You may revoke any key of the organization: a colleague's personal
key, an integration key, or one the operator issued for it. To revoke the
key you are using yourself, run cpms logout. logout revokes whatever
key the profile holds, so never run it on a profile that holds an
integration's key.