Code AI platform with Code Search & Cody
Go to file
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
.apko Build images end-to-end using Bazel v2 (#61845) 2024-04-12 16:18:43 +01:00
.aspect fix(local): disable bazel remote cache (#63203) 2024-06-11 14:30:29 +00:00
.buildkite chore(ci): remove backcompat mitigation (#62658) 2024-05-14 11:00:35 +01:00
.github chore(ci): remove buildchecker sunday summary posts (#63289) 2024-06-17 13:05:39 +00:00
.vscode bazel: transcribe test ownership to bazel tags (#62664) 2024-05-16 15:51:16 +01:00
client Search: surface pattern type in query input (#63326) 2024-06-19 14:24:10 -07:00
cmd enterprise-portal: implement basic MSP IAM and RPCs (#63173) 2024-06-19 21:46:48 -04:00
dev enterprise-portal: implement basic MSP IAM and RPCs (#63173) 2024-06-19 21:46:48 -04:00
doc enterprise-portal: implement basic MSP IAM and RPCs (#63173) 2024-06-19 21:46:48 -04:00
docker-images chore/deps: upgrade alertmanager package dependency, improve logs and tests (#63329) 2024-06-19 13:46:30 -07:00
internal enterprise-portal: implement basic MSP IAM and RPCs (#63173) 2024-06-19 21:46:48 -04:00
lib enterprise-portal: implement basic MSP IAM and RPCs (#63173) 2024-06-19 21:46:48 -04:00
migrations scim: Fix user updates when SCIM was previously enabled (#63135) 2024-06-06 22:24:00 +02:00
monitoring enterprise-portal: implement basic MSP IAM and RPCs (#63173) 2024-06-19 21:46:48 -04:00
schema Chore: remove search console (#63322) 2024-06-19 11:05:03 -06:00
testing feat/bazel: //cmd/{frontend,server} targets that don't include client bundle for backend integration tests (#62877) 2024-05-28 14:32:48 +01:00
third_party enterprise-portal: implement basic MSP IAM and RPCs (#63173) 2024-06-19 21:46:48 -04:00
third-party-licenses chore: Completely sunset qdrant (#62018) 2024-04-22 18:00:57 +02:00
tools feat(release): allow creation of multiple patch release events (#63034) 2024-06-03 11:14:24 -04:00
ui/assets feat/bazel: //cmd/{frontend,server} targets that don't include client bundle for backend integration tests (#62877) 2024-05-28 14:32:48 +01:00
wolfi-images security: Auto-update package lockfiles for Sourcegraph base images (#63104) 2024-06-05 16:04:36 +00:00
wolfi-packages s3proxy: Fix permissions on s3proxy package binary (#62907) 2024-05-24 15:55:00 +00:00
.bazel_fix_commands.json SG Start Bazel Improvements Take 2 (#60687) 2024-03-05 01:44:21 -08:00
.bazelignore Create a shared Cody Ignore dataset (#61968) 2024-05-09 13:18:35 +00:00
.bazeliskrc chore: upgrade to Aspect CLI 5.8.19 (#59203) 2024-01-02 15:13:24 +01:00
.bazelrc feat(ci): Adds playwright tests for sveltekit to bazel (#62560) 2024-06-06 12:45:05 -06:00
.bazelversion chore(bazel): bump to 7.2.0 (#63226) 2024-06-12 13:25:18 +00:00
.dockerignore use esbuild for client/web builds (#57365) 2023-10-23 10:59:06 -07:00
.editorconfig proto: Add editorconfig to ident using two spaces (#57281) 2023-10-03 00:39:42 +00:00
.eslintrc.js Revert vs-code extension deleting (#61258) 2024-03-20 13:53:27 +01:00
.gitattributes dev/linearhooks: add POC (#62367) 2024-05-07 00:14:05 -07:00
.gitignore chore(codenav): Resolve repo and commit in common code (#63072) 2024-06-07 21:58:36 +08:00
.graphqlrc.yml
.hadolint.yaml
.mailmap
.mocharc.js reapply "switch from jest to vitest for faster, simpler tests (#57886)" (#58145) 2023-11-07 12:00:18 +02:00
.npmrc
.percy.yml
.pre-commit-config.yaml exclude pnpm-lock.yaml from precommit (#61158) 2024-03-14 15:35:14 +00:00
.prettierignore feat/release: appliance setup workflow and ui (#63291) 2024-06-19 16:21:13 +01:00
.stylelintignore
.stylelintrc.json
.swcrc use swc instead of babel for faster bazel typescript transpilation (#57912) 2023-11-02 22:49:03 -07:00
.tool-versions chore(tooling): bump Go version to 1.22.4 (#63124) 2024-06-06 15:19:03 +00:00
.trivyignore
BUILD.bazel feat/bazel: //cmd/{frontend,server} targets that don't include client bundle for backend integration tests (#62877) 2024-05-28 14:32:48 +01:00
CHANGELOG.md fix(Source): Fix documentation URLs for code hosts help pages (#63274) 2024-06-17 14:32:46 -04:00
CODENOTIFY
CONTRIBUTING.md fix: update links for dev docs (#62758) 2024-05-17 13:47:34 +02:00
deps.bzl enterprise-portal: implement basic MSP IAM and RPCs (#63173) 2024-06-19 21:46:48 -04:00
doc.go
eslint-relative-formatter.js
flake.lock nix: bump to bazel 7.1 (#61326) 2024-03-22 16:57:50 +00:00
flake.nix nix: build pg-utils with nix [static edition] (#61734) 2024-04-09 20:24:19 +01:00
gen.go chore: fixup go-mockgen run statement (#61028) 2024-03-12 13:06:36 +00:00
go.mod enterprise-portal: implement basic MSP IAM and RPCs (#63173) 2024-06-19 21:46:48 -04:00
go.sum enterprise-portal: implement basic MSP IAM and RPCs (#63173) 2024-06-19 21:46:48 -04:00
graphql-schema-linter.config.js
LICENSE
LICENSE.enterprise Update Enterprise license copyright notice (#62467) 2024-05-06 17:35:32 +00:00
linter_deps.bzl chore: Remove redundant loop captures (#62264) 2024-04-30 07:57:21 -06:00
mockgen.temp.yaml gitserver: Sunset Exec endpoint (#62774) 2024-06-06 14:36:22 +02:00
mockgen.test.yaml enterprise-portal: implement basic MSP IAM and RPCs (#63173) 2024-06-19 21:46:48 -04:00
mockgen.yaml bazel: native go-mockgen in Bazel (#60386) 2024-02-16 13:26:48 +00:00
nogo_config.json chore: Remove redundant loop captures (#62264) 2024-04-30 07:57:21 -06:00
package.json feat(ci): Adds playwright tests for sveltekit to bazel (#62560) 2024-06-06 12:45:05 -06:00
pnpm-lock.yaml chore(svelte): Migrate all icons to Lucide/custom icons (#63246) 2024-06-13 18:49:03 +02:00
pnpm-workspace.yaml Create a shared Cody Ignore dataset (#61968) 2024-05-09 13:18:35 +00:00
postcss.config.js
prettier.config.js
README.md chore: remove broken link in README (#63256) 2024-06-13 22:22:56 +00:00
release.yaml feat(ci): Trigger security scanner from release pipeline (#63280) 2024-06-19 19:16:36 +00:00
renovate.json chore(ci): disable renovate (#63313) 2024-06-19 13:17:15 +02:00
SECURITY.md
service-catalog.yaml
sg.config.yaml enterprise-portal: implement basic MSP IAM and RPCs (#63173) 2024-06-19 21:46:48 -04:00
shell.nix bazel: use pgutil binaries from GCS instead of from the host (#61741) 2024-04-11 18:00:21 +01:00
stamp_tags.bzl
tsconfig.base.json
tsconfig.json release: drop legacy release tooling (#61220) 2024-04-09 14:29:35 -05:00
vitest.shared.ts code intel: Don't rely on URL polyfill to correctly parse git: URIs (#58258) 2023-11-17 19:32:46 +01:00
vitest.workspace.ts vitest: Fix workspace config wrt client/web/ (#58397) 2023-11-17 08:22:46 +00:00
WORKSPACE Revert "refactor: upgrade to rules_oci 2.0" (#63200) 2024-06-11 14:23:53 +02:00

DocsContributingTwitterDiscord

Build status Scorecard Latest release Discord Contributors


Sourcegraph makes it easy to read, write, and fix code—even in big, complex codebases.

  • Code search: Search all of your repositories across all branches and all code hosts.
  • Code intelligence: Navigate code, find references, see code owners, trace history, and more.
  • Fix and refactor: Roll out large-scale changes to many repositories at once and track big migrations.

Getting started



Development

Refer to the Developing Sourcegraph guide to get started.

Documentation

The doc directory has additional documentation for developing and understanding Sourcegraph:

License

This repository contains primarily non-OSS-licensed files. See LICENSE.

Copyright (c) 2018-present Sourcegraph Inc.