Skip to content

Authorize a team

Give a team a role on a node of the tenancy tree: every member gets it by joining and loses it by leaving, and the Nereus API asks the authorization reef before every read and write.

Before you start

  • A cluster from Prepare the cluster with --profile internal-developer-platform: it brings the teams reef, the authorization reef and its Nereid openfga with the default Mandate that turns the check on. Before that Mandate exists, only nereus-admins passes.
  • A Project to own the team, from Know whose each thing is: project/payments below.
  • Tenancy and access tells a User, a Team, a Role and a Binding apart.

Steps

1. Register the people

nereus user create records the e-mail the person's first sign-in is matched with. A login with no User may do nothing.

nereus user create ana --email ana@example.com
output
✓ core/users/ana created
nereus user create bruno --email bruno@example.com
output
✓ core/users/bruno created

Next steps:

  nereus teams create <team> --owner project/<project>

2. Make the team and name its tech lead

nereus teams create makes the team under its Project; nereus teams member create adds a member, here with the position tech-lead.

nereus teams create payments --owner project/payments
output
✓ teams/teams/payments created

Next steps:

  nereus teams member create <user> --team payments
nereus teams member create ana \
  --team payments \
  --position tech-lead
output
✓ teams/teams/payments/members/ana created

Next steps:

  nereus teams get payments

3. Give the team a role

nereus authorization role list shows the roles: administrator is built in and cannot change; viewer, developer and team-lead are examples to edit. nereus authorization binding create makes every member a developer of the Project.

nereus authorization binding create payments-developers \
  --role developer \
  --team payments \
  --owner project/payments
output
✓ authorization/bindings/payments-developers created

Next steps:

  nereus authorization binding list --owner project/payments

4. Give one position a role

With --position, only the team's tech lead gets team-lead, which may create Environments.

nereus authorization binding create payments-leads \
  --role team-lead \
  --team payments \
  --position tech-lead \
  --owner project/payments
output
✓ authorization/bindings/payments-leads created

Next steps:

  nereus authorization binding list --owner project/payments

Check it worked

nereus authorization binding list shows who holds what on the Project.

nereus authorization binding list --owner project/payments
output
NAME                 SUBJECT                         ROLE       OWNER
mobile-leads         team/payments-mobile/tech-lead  team-lead  project/payments
payments-developers  team/payments                   developer  project/payments
payments-leads       team/payments/tech-lead         team-lead  project/payments

nereus authorization can-i answers with the binding that allows it. With no --user it asks about you.

nereus authorization can-i create environment/environments \
  --owner project/payments \
  --user ana
output
yes: authorization/bindings/payments-leads gives team-lead to team/payments/tech-lead at project/payments

Signed in as Bruno, creating an Environment there is refused, and nothing changes:

nereus environment create staging --owner project/payments
output
✗ environment/environments/staging: bruno may not create environment/environments at project/payments. To see who may, run:
  nereus authorization binding list --owner project/payments
  Nothing was changed.

Next

Learn more