Skip to content
PolyPack
Docs: Tokens

Tokens

The credentials package managers use, who issues them, and what each can do.

A Token looks like polypack_ followed by 38 characters: 32 random ones and a checksum. The prefix and checksum let secret scanners recognise a leaked one. PolyPack shows a Token once, when it is issued, and stores only a hash of it: if you lose it, issue a new one.

Kinds

  • Member Token: yours, issued under My Tokens. Read, and optionally publish. It stops working when you leave the Team.
  • Team Token: the Team's, issued by an Admin, for CI. Read, and optionally publish.
  • Client Token: a customer's, issued by an Admin. Read only, and only the Packs granted to that Client. See Clients and Grants.
  • Publisher Token: a GitHub Actions workflow's, issued by nobody. A workflow a Pack trusts exchanges GitHub's ID token for one: it publishes only that Pack, and lasts 15 minutes. See Trusted publishing.

On your own machine, polypack login issues you a read-only Member Token through the browser and sets up your package managers with it.

Abilities

  • read: install every Pack the holder may see. Every Token can read.
  • publish: publish npm versions and change npm dist-tags. Composer versions come from GitHub, not from Tokens.

Limiting a Token to some Packs

A Member or Team Token reaches every Pack of the Team unless you limit it. When you issue one, turn off All Packs and choose the Packs it needs: a CI pipeline that builds one project then holds a Token for that project only.

  • It installs the chosen Packs, and the Team's public Packs, and nothing else.
  • With publish, it publishes and changes only the chosen Packs. It can never create a new Pack: publish a new package with a Token that is not limited.
  • The Packs are fixed when the Token is issued. To change them, issue a new Token and revoke the old one.

Limiting a Token to some addresses

You can pin a Token to the addresses it is used from: your office, your CI runners' IPs. Add addresses or ranges such as 203.0.113.0/24 (IPv4 or IPv6) when you issue it, or later with Addresses; empty means anywhere. From any other address the Token is refused with a message that names the address, so a leaked Token is useless elsewhere. Each Token shows the last address it was refused from. A Client's Tokens follow the addresses set on the Client.

Where a Token works

On its own Team's host and nowhere else. A Token for hopper.pkg.polypack.io is refused on any other Team's host, as if it were wrong.

Expiry, last use and revoking

  • A Token can expire at the end of a chosen day, or never. PolyPack emails 14 days before and the day before it expires: a Member Token's owner, or the Team's Admins for a Team or Client Token.
  • PolyPack shows when each Token was last used, and from which IP address.
  • Admins see every Token nobody has used for 90 days under Stale Tokens. A stale Token still works for anyone who has it: revoke the ones nothing needs.
  • Revoking takes effect on the next request. Revoke a Token the moment it might have leaked, then issue a new one.