Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: add support for optional external auth providers#12021

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
aslilac merged 35 commits intomainfromoptional-external-auth
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
35 commits
Select commitHold shift + click to select a range
f9feb97
frontend hacking
aslilacFeb 9, 2024
179adae
pipe through all of the protobuf stuff
aslilacFeb 9, 2024
bdf6142
db migration
aslilacFeb 9, 2024
751400b
💅
aslilacFeb 12, 2024
5068d88
Merge branch 'main' into optional-external-auth
aslilacFeb 12, 2024
eaddb5b
🧹
aslilacFeb 12, 2024
eba3d12
tests!
aslilacFeb 12, 2024
ebb518b
🧪
aslilacFeb 12, 2024
29be417
official release
aslilacFeb 12, 2024
48267a4
add default first in up migration
aslilacFeb 12, 2024
e870667
manually default
aslilacFeb 12, 2024
d58c088
connect with correct version
aslilacFeb 13, 2024
757ea0f
Merge branch 'main' into optional-external-auth
aslilacFeb 14, 2024
79ad9da
land the backend changes separately
aslilacFeb 14, 2024
6746f88
fix migration order
aslilacFeb 14, 2024
cb7ab9a
version.go is not generated
aslilacFeb 14, 2024
3bacc70
it could just all go away
aslilacFeb 15, 2024
28a878d
Revert "it could just all go away"
aslilacFeb 15, 2024
b514292
Merge branch 'main' into optional-external-auth
aslilacFeb 15, 2024
892a79b
change tested version
aslilacFeb 15, 2024
c5e63eb
add `database.ExternalAuthProviders` type
aslilacFeb 15, 2024
6f933b8
Merge branch 'main' into optional-external-auth
aslilacFeb 16, 2024
ea81a1f
`drop` migration functions
aslilacFeb 16, 2024
2376357
`make gen`
aslilacFeb 16, 2024
b9471a5
Merge branch 'main' into optional-external-auth
aslilacFeb 16, 2024
b2b9e95
🆘
aslilacFeb 16, 2024
b159156
Merge branch 'main' into optional-external-auth
aslilacFeb 20, 2024
04579de
no such file
aslilacFeb 20, 2024
7ff56b1
bump version again
aslilacFeb 20, 2024
16ba268
update test
aslilacFeb 20, 2024
bdb875a
Merge branch 'main' into optional-external-auth
aslilacFeb 21, 2024
328202a
fix migration numbers
aslilacFeb 21, 2024
a475ec0
Merge branch 'main' into optional-external-auth
aslilacFeb 21, 2024
353e6a3
`COMMENT ON VIEW`
aslilacFeb 21, 2024
1021bc4
`make gen`
aslilacFeb 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions.gitattributes
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,10 +6,12 @@ coderd/apidoc/swagger.json linguist-generated=true
coderd/database/dump.sqllinguist-generated=true
peerbroker/proto/*.golinguist-generated=true
provisionerd/proto/*.golinguist-generated=true
provisionerd/proto/version.golinguist-generated=false
provisionersdk/proto/*.golinguist-generated=true
*.tfplan.jsonlinguist-generated=true
*.tfstate.jsonlinguist-generated=true
*.tfstate.dotlinguist-generated=true
*.tfplan.dotlinguist-generated=true
site/e2e/provisionerGenerated.tslinguist-generated=true
site/src/api/typesGenerated.tslinguist-generated=true
site/src/pages/SetupPage/countries.tsxlinguist-generated=true
2 changes: 1 addition & 1 deletioncli/create_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -803,7 +803,7 @@ func TestCreateWithGitAuth(t *testing.T) {
{
Type:&proto.Response_Plan{
Plan:&proto.PlanComplete{
ExternalAuthProviders: []string{"github"},
ExternalAuthProviders: []*proto.ExternalAuthProviderResource{{Id:"github"}},
},
},
},
Expand Down
3 changes: 3 additions & 0 deletionscoderd/apidoc/docs.go
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

3 changes: 3 additions & 0 deletionscoderd/apidoc/swagger.json
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

2 changes: 1 addition & 1 deletioncoderd/coderd.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1247,7 +1247,7 @@ func (api *API) CreateInMemoryProvisionerDaemon(dialCtx context.Context, name st
Tags: provisionersdk.MutateTags(uuid.Nil, nil),
LastSeenAt: sql.NullTime{Time: dbtime.Now(), Valid: true},
Version: buildinfo.Version(),
APIVersion: proto.VersionCurrent.String(),
APIVersion: proto.CurrentVersion.String(),
})
if err != nil {
return nil, xerrors.Errorf("failed to create in-memory provisioner daemon: %w", err)
Expand Down
3 changes: 1 addition & 2 deletionscoderd/database/dbauthz/dbauthz_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -928,8 +928,7 @@ func (s *MethodTestSuite) TestTemplate() {
JobID: jobID,
})
check.Args(database.UpdateTemplateVersionExternalAuthProvidersByJobIDParams{
JobID: jobID,
ExternalAuthProviders: []string{},
JobID: jobID,
}).Asserts(t1, rbac.ActionUpdate).Returns()
}))
s.Run("GetTemplateInsights", s.Subtest(func(db database.Store, check *expects) {
Expand Down
8 changes: 4 additions & 4 deletionscoderd/database/dbpurge/dbpurge_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -219,7 +219,7 @@ func TestDeleteOldProvisionerDaemons(t *testing.T) {
CreatedAt: now.Add(-14 * 24 * time.Hour),
LastSeenAt: sql.NullTime{Valid: true, Time: now.Add(-7 * 24 * time.Hour).Add(time.Minute)},
Version: "1.0.0",
APIVersion: proto.VersionCurrent.String(),
APIVersion: proto.CurrentVersion.String(),
})
require.NoError(t, err)
_, err = db.UpsertProvisionerDaemon(ctx, database.UpsertProvisionerDaemonParams{
Expand All@@ -230,7 +230,7 @@ func TestDeleteOldProvisionerDaemons(t *testing.T) {
CreatedAt: now.Add(-8 * 24 * time.Hour),
LastSeenAt: sql.NullTime{Valid: true, Time: now.Add(-8 * 24 * time.Hour).Add(time.Hour)},
Version: "1.0.0",
APIVersion: proto.VersionCurrent.String(),
APIVersion: proto.CurrentVersion.String(),
})
require.NoError(t, err)
_, err = db.UpsertProvisionerDaemon(ctx, database.UpsertProvisionerDaemonParams{
Expand All@@ -243,7 +243,7 @@ func TestDeleteOldProvisionerDaemons(t *testing.T) {
},
CreatedAt: now.Add(-9 * 24 * time.Hour),
Version: "1.0.0",
APIVersion: proto.VersionCurrent.String(),
APIVersion: proto.CurrentVersion.String(),
})
require.NoError(t, err)
_, err = db.UpsertProvisionerDaemon(ctx, database.UpsertProvisionerDaemonParams{
Expand All@@ -257,7 +257,7 @@ func TestDeleteOldProvisionerDaemons(t *testing.T) {
CreatedAt: now.Add(-6 * 24 * time.Hour),
LastSeenAt: sql.NullTime{Valid: true, Time: now.Add(-6 * 24 * time.Hour)},
Version: "1.0.0",
APIVersion: proto.VersionCurrent.String(),
APIVersion: proto.CurrentVersion.String(),
})
require.NoError(t, err)

Expand Down
2 changes: 1 addition & 1 deletioncoderd/database/dump.sql
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
-- We cannot alter the column type while a view depends on it, so we drop it and recreate it.
DROP VIEW template_version_with_user;


-- Does the opposite of `migrate_external_auth_providers_to_jsonb`
-- eg. `'[{"id": "github"}, {"id": "gitlab"}]'::jsonb` would become `'{github,gitlab}'::text[]`
CREATE OR REPLACE FUNCTION revert_migrate_external_auth_providers_to_jsonb(jsonb)
RETURNS text[]
LANGUAGE plpgsql
AS $$
DECLARE
result text[];
BEGIN
SELECT
array_agg(id::text) INTO result
FROM (
SELECT
jsonb_array_elements($1) ->> 'id' AS id) AS external_auth_provider_ids;
RETURN result;
END;
$$;


-- Remove the non-null constraint and default
ALTER TABLE template_versions
ALTER COLUMN external_auth_providers DROP DEFAULT;
ALTER TABLE template_versions
ALTER COLUMN external_auth_providers DROP NOT NULL;


-- Update the column type and migrate the values
ALTER TABLE template_versions
ALTER COLUMN external_auth_providers TYPE text[]
USING revert_migrate_external_auth_providers_to_jsonb(external_auth_providers);


-- Recreate `template_version_with_user` as described in dump.sql
CREATE VIEW template_version_with_user AS
SELECT
template_versions.id,
template_versions.template_id,
template_versions.organization_id,
template_versions.created_at,
template_versions.updated_at,
template_versions.name,
template_versions.readme,
template_versions.job_id,
template_versions.created_by,
template_versions.external_auth_providers,
template_versions.message,
template_versions.archived,
COALESCE(visible_users.avatar_url, ''::text) AS created_by_avatar_url,
COALESCE(visible_users.username, ''::text) AS created_by_username
FROM (public.template_versions
LEFT JOIN visible_users ON (template_versions.created_by = visible_users.id));

COMMENT ON VIEW template_version_with_user IS 'Joins in the username + avatar url of the created by user.';


-- Cleanup
DROP FUNCTION revert_migrate_external_auth_providers_to_jsonb;
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
-- We cannot alter the column type while a view depends on it, so we drop it and recreate it.
DROP VIEW template_version_with_user;


-- Turns the list of provider names into JSONB with the type `Array<{ id: string; optional?: boolean }>`
-- eg. `'{github,gitlab}'::text[]` would become `'[{"id": "github"}, {"id": "gitlab"}]'::jsonb`
CREATE OR REPLACE FUNCTION migrate_external_auth_providers_to_jsonb(text[])
RETURNS jsonb
LANGUAGE plpgsql
AS $$
DECLARE
result jsonb;
BEGIN
SELECT
jsonb_agg(jsonb_build_object('id', value::text)) INTO result
FROM
unnest($1) AS value;
RETURN result;
END;
$$;


-- Update the column type and migrate the values
ALTER TABLE template_versions
ALTER COLUMN external_auth_providers TYPE jsonb
USING migrate_external_auth_providers_to_jsonb(external_auth_providers);


-- Make the column non-nullable to make the types nicer on the Go side
UPDATE template_versions
SET external_auth_providers = '[]'::jsonb
WHERE external_auth_providers IS NULL;
ALTER TABLE template_versions
ALTER COLUMN external_auth_providers SET DEFAULT '[]'::jsonb;
ALTER TABLE template_versions
ALTER COLUMN external_auth_providers SET NOT NULL;


-- Recreate `template_version_with_user` as described in dump.sql
CREATE VIEW template_version_with_user AS
SELECT
template_versions.id,
template_versions.template_id,
template_versions.organization_id,
template_versions.created_at,
template_versions.updated_at,
template_versions.name,
template_versions.readme,
template_versions.job_id,
template_versions.created_by,
template_versions.external_auth_providers,
template_versions.message,
template_versions.archived,
COALESCE(visible_users.avatar_url, ''::text) AS created_by_avatar_url,
COALESCE(visible_users.username, ''::text) AS created_by_username
FROM (public.template_versions
LEFT JOIN visible_users ON (template_versions.created_by = visible_users.id));

COMMENT ON VIEW template_version_with_user IS 'Joins in the username + avatar url of the created by user.';


-- Cleanup
DROP FUNCTION migrate_external_auth_providers_to_jsonb;
30 changes: 15 additions & 15 deletionscoderd/database/models.go
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

22 changes: 11 additions & 11 deletionscoderd/database/queries.sql.go
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

5 changes: 5 additions & 0 deletionscoderd/database/types.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -64,6 +64,11 @@ func (t TemplateACL) Value() (driver.Value, error) {
return json.Marshal(t)
}

type ExternalAuthProvider struct {
ID string `json:"id"`
Optional bool `json:"optional,omitempty"`
}

type StringMap map[string]string

func (m *StringMap) Scan(src interface{}) error {
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp