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: allow bypassing current CORS magic based on template config#18706

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
cstyan merged 23 commits intomainfromcallum-cors
Jul 30, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
23 commits
Select commitHold shift + click to select a range
94e423b
wip
cstyanJul 3, 2025
b2e9c6d
wip 2
cstyanJul 3, 2025
5b2b80e
fix broken build and tests
cstyanJul 7, 2025
1af9d2f
rename sql files
cstyanJul 7, 2025
6c136cf
fix TS files for tests/linting
cstyanJul 7, 2025
8b21d0c
wip proxy changes, still broken
cstyanJul 8, 2025
20c3ffd
commit cors package
cstyanJul 8, 2025
20dbf97
port test
cstyanJul 8, 2025
432aff6
this should fix most tests, thanks blink
cstyanJul 8, 2025
e75fb3b
Merge branch 'main' into callum-cors
cstyanJul 9, 2025
5b5e766
move cors mw after app handle subdomain
cstyanJul 9, 2025
039240b
Merge branch 'main' into callum-cors
cstyanJul 9, 2025
8251d8e
merge missed removing dbmem
cstyanJul 9, 2025
22c0711
fix leftover merge conflict
cstyanJul 9, 2025
a5ad58b
fix linting
cstyanJul 9, 2025
e6afe73
address review comments related to valid/validate functions
cstyanJul 29, 2025
9aa5bdb
Merge branch 'main' into callum-cors
cstyanJul 29, 2025
bc41ed4
move cors DB migration and re-make gen
cstyanJul 29, 2025
6a62419
fix mistaken change in dbgen
cstyanJul 29, 2025
fa93b9b
fix lint erro
cstyanJul 29, 2025
4d498c6
somehow make gen doesn't fix this file?
cstyanJul 29, 2025
a41dbcc
again, make gen doesn't seem to fix the required formatting here
cstyanJul 29, 2025
92b6e20
address more review feedback
cstyanJul 29, 2025
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
22 changes: 22 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.

16 changes: 16 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: 2 additions & 0 deletionscoderd/database/dbauthz/dbauthz_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1462,6 +1462,7 @@ func (s *MethodTestSuite) TestTemplate() {
Provisioner: "echo",
OrganizationID: orgID,
MaxPortSharingLevel: database.AppSharingLevelOwner,
CorsBehavior: database.CorsBehaviorSimple,
}).Asserts(rbac.ResourceTemplate.InOrg(orgID), policy.ActionCreate)
}))
s.Run("InsertTemplateVersion", s.Subtest(func(db database.Store, check *expects) {
Expand DownExpand Up@@ -1582,6 +1583,7 @@ func (s *MethodTestSuite) TestTemplate() {
check.Args(database.UpdateTemplateMetaByIDParams{
ID: t1.ID,
MaxPortSharingLevel: "owner",
CorsBehavior: database.CorsBehaviorSimple,
}).Asserts(t1, policy.ActionUpdate)
}))
s.Run("UpdateTemplateVersionByID", s.Subtest(func(db database.Store, check *expects) {
Expand Down
1 change: 1 addition & 0 deletionscoderd/database/dbgen/dbgen.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -148,6 +148,7 @@ func Template(t testing.TB, db database.Store, seed database.Template) database.
AllowUserCancelWorkspaceJobs: seed.AllowUserCancelWorkspaceJobs,
MaxPortSharingLevel: takeFirst(seed.MaxPortSharingLevel, database.AppSharingLevelOwner),
UseClassicParameterFlow: takeFirst(seed.UseClassicParameterFlow, false),
CorsBehavior: takeFirst(seed.CorsBehavior, database.CorsBehaviorSimple),
})
require.NoError(t, err, "insert template")

Expand Down
9 changes: 8 additions & 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,46 @@
DROP VIEW IF EXISTS template_with_names;
CREATE VIEW template_with_names AS
SELECT templates.id,
templates.created_at,
templates.updated_at,
templates.organization_id,
templates.deleted,
templates.name,
templates.provisioner,
templates.active_version_id,
templates.description,
templates.default_ttl,
templates.created_by,
templates.icon,
templates.user_acl,
templates.group_acl,
templates.display_name,
templates.allow_user_cancel_workspace_jobs,
templates.allow_user_autostart,
templates.allow_user_autostop,
templates.failure_ttl,
templates.time_til_dormant,
templates.time_til_dormant_autodelete,
templates.autostop_requirement_days_of_week,
templates.autostop_requirement_weeks,
templates.autostart_block_days_of_week,
templates.require_active_version,
templates.deprecated,
templates.activity_bump,
templates.max_port_sharing_level,
templates.use_classic_parameter_flow,
COALESCE(visible_users.avatar_url, ''::text) AS created_by_avatar_url,
COALESCE(visible_users.username, ''::text) AS created_by_username,
COALESCE(visible_users.name, ''::text) AS created_by_name,
COALESCE(organizations.name, ''::text) AS organization_name,
COALESCE(organizations.display_name, ''::text) AS organization_display_name,
COALESCE(organizations.icon, ''::text) AS organization_icon
FROM ((templates
LEFT JOIN visible_users ON ((templates.created_by = visible_users.id)))
LEFT JOIN organizations ON ((templates.organization_id = organizations.id)));

COMMENT ON VIEW template_with_names IS 'Joins in the display name information such as username, avatar, and organization name.';

ALTER TABLE templates DROP COLUMN cors_behavior;

DROP TYPE IF EXISTS cors_behavior;
52 changes: 52 additions & 0 deletionscoderd/database/migrations/000353_template_level_cors.up.sql
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
CREATE TYPE cors_behavior AS ENUM (
'simple',
'passthru'
);

ALTER TABLE templates
ADD COLUMN cors_behavior cors_behavior NOT NULL DEFAULT 'simple'::cors_behavior;

-- Update the template_with_users view by recreating it.
DROP VIEW IF EXISTS template_with_names;
CREATE VIEW template_with_names AS
SELECT templates.id,
templates.created_at,
templates.updated_at,
templates.organization_id,
templates.deleted,
templates.name,
templates.provisioner,
templates.active_version_id,
templates.description,
templates.default_ttl,
templates.created_by,
templates.icon,
templates.user_acl,
templates.group_acl,
templates.display_name,
templates.allow_user_cancel_workspace_jobs,
templates.allow_user_autostart,
templates.allow_user_autostop,
templates.failure_ttl,
templates.time_til_dormant,
templates.time_til_dormant_autodelete,
templates.autostop_requirement_days_of_week,
templates.autostop_requirement_weeks,
templates.autostart_block_days_of_week,
templates.require_active_version,
templates.deprecated,
templates.activity_bump,
templates.max_port_sharing_level,
templates.use_classic_parameter_flow,
templates.cors_behavior, -- <--- adding this column
COALESCE(visible_users.avatar_url, ''::text) AS created_by_avatar_url,
COALESCE(visible_users.username, ''::text) AS created_by_username,
COALESCE(visible_users.name, ''::text) AS created_by_name,
COALESCE(organizations.name, ''::text) AS organization_name,
COALESCE(organizations.display_name, ''::text) AS organization_display_name,
COALESCE(organizations.icon, ''::text) AS organization_icon
FROM ((templates
LEFT JOIN visible_users ON ((templates.created_by = visible_users.id)))
LEFT JOIN organizations ON ((templates.organization_id = organizations.id)));

COMMENT ON VIEW template_with_names IS 'Joins in the display name information such as username, avatar, and organization name.';
1 change: 1 addition & 0 deletionscoderd/database/modelqueries.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -120,6 +120,7 @@ func (q *sqlQuerier) GetAuthorizedTemplates(ctx context.Context, arg GetTemplate
&i.ActivityBump,
&i.MaxPortSharingLevel,
&i.UseClassicParameterFlow,
&i.CorsBehavior,
&i.CreatedByAvatarURL,
&i.CreatedByUsername,
&i.CreatedByName,
Expand Down
62 changes: 61 additions & 1 deletioncoderd/database/models.go
View file
Open in desktop

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

Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp