sourcegraph/doc
Joe Chen b717fd518a
enterprise-portal: implement basic MSP IAM and RPCs (#63173)
Closes CORE-99, closes CORE-176

This PR is based off (and was also served as PoC of) [RFC 962: MSP IAM
framework](https://docs.google.com/document/d/1ItJlQnpR5AHbrfAholZqjH8-8dPF1iQcKh99gE6SSjs/edit).
It comes with two main parts:

1. The initial version of the MSP IAM SDK:
`lib/managedservicesplatform/iam`
- Embeds the [OpenFGA server
implementation](https://github.com/openfga/openfga/tree/main/pkg/server)
and exposes the a `ClientV1` for interacting with it.
- Automagically manages the both MSP IAM's and OpenFGA's database
migrations upon initializing the `ClientV1`.
![CleanShot 2024-06-18 at 15 09
24@2x](https://github.com/sourcegraph/sourcegraph/assets/2946214/387e0e28-a6c2-4664-b946-0ea4a1dd0804)
- Ensures the specified OpenFGA's store and automatization model DSL
exists.
- Utility types and helpers to avoid easy mistakes (i.e. make the
relation tuples a bit more strongly-typed).
- Decided to put all types and pre-defined values together to simulate a
"central registry" and acting as a forcing function for services to form
some sort of convention. Then when we migrate the OpenFGA server to a
separate standalone service, it will be less headache about
consolidating similar meaning types/relations but different string
literals.
1. The first use case of the MSP IAM:
`cmd/enterprise-portal/internal/subscriptionsservice`
	- Added/updated RPCs:
		- Listing enterprise subscriptions via permissions
		- Update enterprise subscriptions to assign instance domains
- Update enterprise subscriptions membership to assign roles (and
permissions)
- A database table for enterprise subscriptions, only storing the extra
instance domains as Enterprise Portal is not the
writeable-source-of-truth.

## Other minor changes

- Moved `internal/redislock` to `lib/redislock` to be used in MSP IAM
SDK.
- Call `createdb ...` as part of `enterprise-portal` install script in
`sg.config.yaml` (`msp_iam` database is a hard requirement of MSP IAM
framework).

## Test plan

Tested with gRPC UI:

- `UpdateEnterpriseSubscription` to assign an instance domain
- `UpdateEnterpriseSubscriptionMembership` to assign roles
- `ListEnterpriseSubscriptions`:
	- List by subscription ID
	- List by instance domain
	- List by view cody analytics permissions

---------

Co-authored-by: Robert Lin <robert@bobheadxi.dev>
2024-06-19 21:46:48 -04:00
..
_resources Chore: remove plausible scripts (#63054) 2024-06-03 17:33:40 -06:00
admin fix(Source): Fix documentation URLs for code hosts help pages (#63274) 2024-06-17 14:32:46 -04:00
cli/references chore(docs): remove outdated content (#61687) 2024-04-08 16:20:45 +02:00
dev chore(ci): disable renovate (#63313) 2024-06-19 13:17:15 +02:00
_generated.push.sh fix(docs): no delivery if triggered without changes (#61578) 2024-04-04 09:08:41 +00:00
BUILD.bazel chore(docs): remove outdated content (#61687) 2024-04-08 16:20:45 +02:00
CHANGELOG.md doc: symlink CHANGELOG.md to docs for better search results (#22918) 2021-07-16 23:25:02 +08:00
CODENOTIFY chore: clean up CODENOTIFY for @sourcegraph/delivery (#57046) 2023-09-26 15:20:42 -04:00
dependency_decisions.yml enterprise-portal: implement basic MSP IAM and RPCs (#63173) 2024-06-19 21:46:48 -04:00
docsite.json insights: re-index docs (#32415) 2022-03-10 10:05:59 -07:00
index.md Fix typo on main docs page (#59104) 2023-12-20 20:09:43 +01:00
KNOWN-ISSUES.md Ajb doc update 23 (#56656) 2023-09-15 17:04:23 +00:00
serve.sh bzl: bazelify docsite and doc/cli/reference generation (#54538) 2023-07-03 16:12:44 +02:00
sidebar.md chore(docs): remove outdated content (#61687) 2024-04-08 16:20:45 +02:00
test.sh bzl: wrap docsite check into //doc:test (#54376) 2023-06-28 21:00:54 +02:00