-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[server] move FGA calls into AuthProviderService (#19017)
* [server] move FGA calls into AuthProviderService * split internal upsert method `updateAuthProvider` into create and update * refactor: move `getAuthProviders` logic from gitpod-server-impl to auth-provider-service * adding db tests for auth provider server * use redacted results in service * Fix typos * extract helper functions for scopes * add more tests * as regular member, should find org-level providers if no built-in providers present * as regular member, should find only built-in providers if present --------- Co-authored-by: Huiwen <[email protected]>
- Loading branch information
1 parent
2e3429a
commit b2d5018
Showing
13 changed files
with
768 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* Copyright (c) 2023 Gitpod GmbH. All rights reserved. | ||
* Licensed under the GNU Affero General Public License (AGPL). | ||
* See License.AGPL.txt in the project root for license information. | ||
*/ | ||
|
||
import { AuthProviderEntry } from "@gitpod/gitpod-protocol"; | ||
import { GitHubScope } from "../github/scopes"; | ||
import { GitLabScope } from "../gitlab/scopes"; | ||
import { BitbucketOAuthScopes } from "../bitbucket/bitbucket-oauth-scopes"; | ||
import { BitbucketServerOAuthScopes } from "../bitbucket-server/bitbucket-server-oauth-scopes"; | ||
|
||
export function getRequiredScopes(entry: AuthProviderEntry) { | ||
switch (entry.type) { | ||
case "GitHub": | ||
return { | ||
default: GitHubScope.Requirements.DEFAULT, | ||
publicRepo: GitHubScope.Requirements.PUBLIC_REPO, | ||
privateRepo: GitHubScope.Requirements.PRIVATE_REPO, | ||
}; | ||
case "GitLab": | ||
return { | ||
default: GitLabScope.Requirements.DEFAULT, | ||
publicRepo: GitLabScope.Requirements.DEFAULT, | ||
privateRepo: GitLabScope.Requirements.REPO, | ||
}; | ||
case "Bitbucket": | ||
return { | ||
default: BitbucketOAuthScopes.Requirements.DEFAULT, | ||
publicRepo: BitbucketOAuthScopes.Requirements.DEFAULT, | ||
privateRepo: BitbucketOAuthScopes.Requirements.DEFAULT, | ||
}; | ||
case "BitbucketServer": | ||
return { | ||
default: BitbucketServerOAuthScopes.Requirements.DEFAULT, | ||
publicRepo: BitbucketServerOAuthScopes.Requirements.DEFAULT, | ||
privateRepo: BitbucketServerOAuthScopes.Requirements.DEFAULT, | ||
}; | ||
} | ||
} | ||
export function getScopesOfProvider(entry: AuthProviderEntry) { | ||
switch (entry.type) { | ||
case "GitHub": | ||
return GitHubScope.All; | ||
case "GitLab": | ||
return GitLabScope.All; | ||
case "Bitbucket": | ||
return BitbucketOAuthScopes.ALL; | ||
case "BitbucketServer": | ||
return BitbucketServerOAuthScopes.ALL; | ||
} | ||
} |
Oops, something went wrong.