mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: rename git_auth to external_auth in our schema (#9935)
* chore: rename `git_auth` to `external_auth` in our schema We're changing Git auth to be external auth. It will support any OAuth2 or OIDC provider. To split up the larger change I want to contribute the schema changes first, and I'll add the feature itself in another PR. * Fix names * Fix outdated view * Rename some additional places * Fix sort order * Fix template versions auth route * Fix types * Fix dbauthz
This commit is contained in:
@@ -94,7 +94,7 @@ export interface InstanceIdentityAuth {
|
||||
instanceId: string;
|
||||
}
|
||||
|
||||
export interface GitAuthProvider {
|
||||
export interface ExternalAuthProvider {
|
||||
id: string;
|
||||
accessToken: string;
|
||||
}
|
||||
@@ -241,7 +241,7 @@ export interface PlanRequest {
|
||||
metadata: Metadata | undefined;
|
||||
richParameterValues: RichParameterValue[];
|
||||
variableValues: VariableValue[];
|
||||
gitAuthProviders: GitAuthProvider[];
|
||||
externalAuthProviders: ExternalAuthProvider[];
|
||||
}
|
||||
|
||||
/** PlanComplete indicates a request to plan completed. */
|
||||
@@ -455,9 +455,9 @@ export const InstanceIdentityAuth = {
|
||||
},
|
||||
};
|
||||
|
||||
export const GitAuthProvider = {
|
||||
export const ExternalAuthProvider = {
|
||||
encode(
|
||||
message: GitAuthProvider,
|
||||
message: ExternalAuthProvider,
|
||||
writer: _m0.Writer = _m0.Writer.create(),
|
||||
): _m0.Writer {
|
||||
if (message.id !== "") {
|
||||
@@ -838,8 +838,8 @@ export const PlanRequest = {
|
||||
for (const v of message.variableValues) {
|
||||
VariableValue.encode(v!, writer.uint32(26).fork()).ldelim();
|
||||
}
|
||||
for (const v of message.gitAuthProviders) {
|
||||
GitAuthProvider.encode(v!, writer.uint32(34).fork()).ldelim();
|
||||
for (const v of message.externalAuthProviders) {
|
||||
ExternalAuthProvider.encode(v!, writer.uint32(34).fork()).ldelim();
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
+1
-1
@@ -333,7 +333,7 @@ export const createTemplateVersion = async (
|
||||
|
||||
export const getTemplateVersionGitAuth = async (
|
||||
versionId: string,
|
||||
): Promise<TypesGen.TemplateVersionGitAuth[]> => {
|
||||
): Promise<TypesGen.TemplateVersionExternalAuth[]> => {
|
||||
const response = await axios.get(
|
||||
`/api/v2/templateversions/${versionId}/gitauth`,
|
||||
);
|
||||
|
||||
Generated
+17
-11
@@ -1010,9 +1010,9 @@ export interface TemplateVersion {
|
||||
}
|
||||
|
||||
// From codersdk/templateversions.go
|
||||
export interface TemplateVersionGitAuth {
|
||||
export interface TemplateVersionExternalAuth {
|
||||
readonly id: string;
|
||||
readonly type: GitProvider;
|
||||
readonly type: ExternalAuthProvider;
|
||||
readonly authenticate_url: string;
|
||||
readonly authenticated: boolean;
|
||||
}
|
||||
@@ -1655,6 +1655,21 @@ export const Experiments: Experiment[] = [
|
||||
"workspace_actions",
|
||||
];
|
||||
|
||||
// From codersdk/workspaceagents.go
|
||||
export type ExternalAuthProvider =
|
||||
| "azure-devops"
|
||||
| "bitbucket"
|
||||
| "github"
|
||||
| "gitlab"
|
||||
| "openid-connect";
|
||||
export const ExternalAuthProviders: ExternalAuthProvider[] = [
|
||||
"azure-devops",
|
||||
"bitbucket",
|
||||
"github",
|
||||
"gitlab",
|
||||
"openid-connect",
|
||||
];
|
||||
|
||||
// From codersdk/deployment.go
|
||||
export type FeatureName =
|
||||
| "advanced_template_scheduling"
|
||||
@@ -1690,15 +1705,6 @@ export const FeatureNames: FeatureName[] = [
|
||||
"workspace_proxy",
|
||||
];
|
||||
|
||||
// From codersdk/workspaceagents.go
|
||||
export type GitProvider = "azure-devops" | "bitbucket" | "github" | "gitlab";
|
||||
export const GitProviders: GitProvider[] = [
|
||||
"azure-devops",
|
||||
"bitbucket",
|
||||
"github",
|
||||
"gitlab",
|
||||
];
|
||||
|
||||
// From codersdk/groups.go
|
||||
export type GroupSource = "oidc" | "user";
|
||||
export const GroupSources: GroupSource[] = ["oidc", "user"];
|
||||
|
||||
@@ -11,9 +11,9 @@ import {
|
||||
MockTemplateVersionParameter1,
|
||||
MockTemplateVersionParameter2,
|
||||
MockTemplateVersionParameter3,
|
||||
MockTemplateVersionGitAuth,
|
||||
MockTemplateVersionExternalAuthGithub,
|
||||
MockOrganization,
|
||||
MockTemplateVersionGitAuthAuthenticated,
|
||||
MockTemplateVersionExternalAuthGithubAuthenticated,
|
||||
} from "testHelpers/entities";
|
||||
import {
|
||||
renderWithAuth,
|
||||
@@ -166,7 +166,7 @@ describe("CreateWorkspacePage", () => {
|
||||
jest.spyOn(API, "createWorkspace").mockResolvedValueOnce(MockWorkspace);
|
||||
jest
|
||||
.spyOn(API, "getTemplateVersionGitAuth")
|
||||
.mockResolvedValue([MockTemplateVersionGitAuth]);
|
||||
.mockResolvedValue([MockTemplateVersionExternalAuthGithub]);
|
||||
|
||||
renderCreateWorkspacePage();
|
||||
await waitForLoaderToBeRemoved();
|
||||
@@ -182,7 +182,7 @@ describe("CreateWorkspacePage", () => {
|
||||
|
||||
jest
|
||||
.spyOn(API, "getTemplateVersionGitAuth")
|
||||
.mockResolvedValue([MockTemplateVersionGitAuthAuthenticated]);
|
||||
.mockResolvedValue([MockTemplateVersionExternalAuthGithubAuthenticated]);
|
||||
|
||||
await screen.findByText("Authenticated with GitHub");
|
||||
|
||||
@@ -203,7 +203,7 @@ describe("CreateWorkspacePage", () => {
|
||||
it("gitauth: errors if unauthenticated and submits", async () => {
|
||||
jest
|
||||
.spyOn(API, "getTemplateVersionGitAuth")
|
||||
.mockResolvedValueOnce([MockTemplateVersionGitAuth]);
|
||||
.mockResolvedValueOnce([MockTemplateVersionExternalAuthGithub]);
|
||||
|
||||
renderCreateWorkspacePage();
|
||||
await waitForLoaderToBeRemoved();
|
||||
|
||||
@@ -38,7 +38,7 @@ export interface CreateWorkspacePageViewProps {
|
||||
defaultOwner: TypesGen.User;
|
||||
template: TypesGen.Template;
|
||||
versionId?: string;
|
||||
gitAuth: TypesGen.TemplateVersionGitAuth[];
|
||||
gitAuth: TypesGen.TemplateVersionExternalAuth[];
|
||||
gitAuthPollingState: GitAuthPollingState;
|
||||
startPollingGitAuth: () => void;
|
||||
parameters: TypesGen.TemplateVersionParameter[];
|
||||
@@ -233,7 +233,9 @@ export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = ({
|
||||
|
||||
type GitAuthErrors = Record<string, string>;
|
||||
|
||||
const useGitAuthVerification = (gitAuth: TypesGen.TemplateVersionGitAuth[]) => {
|
||||
const useGitAuthVerification = (
|
||||
gitAuth: TypesGen.TemplateVersionExternalAuth[],
|
||||
) => {
|
||||
const [gitAuthErrors, setGitAuthErrors] = useState<GitAuthErrors>({});
|
||||
|
||||
// Clear errors when gitAuth is refreshed
|
||||
|
||||
@@ -15,7 +15,7 @@ import ReplayIcon from "@mui/icons-material/Replay";
|
||||
import { LoadingButton } from "components/LoadingButton/LoadingButton";
|
||||
|
||||
export interface GitAuthProps {
|
||||
type: TypesGen.GitProvider;
|
||||
type: TypesGen.ExternalAuthProvider;
|
||||
authenticated: boolean;
|
||||
authenticateURL: string;
|
||||
gitAuthPollingState: GitAuthPollingState;
|
||||
|
||||
@@ -2184,14 +2184,15 @@ export const MockWorkspaceBuildParameter5: TypesGen.WorkspaceBuildParameter = {
|
||||
value: "5",
|
||||
};
|
||||
|
||||
export const MockTemplateVersionGitAuth: TypesGen.TemplateVersionGitAuth = {
|
||||
id: "github",
|
||||
type: "github",
|
||||
authenticate_url: "https://example.com/gitauth/github",
|
||||
authenticated: false,
|
||||
};
|
||||
export const MockTemplateVersionExternalAuthGithub: TypesGen.TemplateVersionExternalAuth =
|
||||
{
|
||||
id: "github",
|
||||
type: "github",
|
||||
authenticate_url: "https://example.com/gitauth/github",
|
||||
authenticated: false,
|
||||
};
|
||||
|
||||
export const MockTemplateVersionGitAuthAuthenticated: TypesGen.TemplateVersionGitAuth =
|
||||
export const MockTemplateVersionExternalAuthGithubAuthenticated: TypesGen.TemplateVersionExternalAuth =
|
||||
{
|
||||
id: "github",
|
||||
type: "github",
|
||||
|
||||
Reference in New Issue
Block a user