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: bypass built-in CORS handling for workspace apps#17596

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

Closed
Emyrk wants to merge19 commits intomainfromstevenmasley/cors
Closed
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
19 commits
Select commitHold shift + click to select a range
0dc7ca3
Working implementation
dannykoppingNov 21, 2024
3c0e33a
Rename CorsBehavior to CORSBehavior
dannykoppingNov 26, 2024
a4d3c8d
Hard & simplify CORORS handling logic
dannykoppingNov 27, 2024
873c3e4
Minor fixes
dannykoppingNov 27, 2024
65f984f
Appeasing the linter
dannykoppingNov 27, 2024
1f0b34c
Move type def to codersdk
dannykoppingNov 27, 2024
5be5477
Appease the linter, again
dannykoppingNov 27, 2024
ddbbaa9
Fix migration num
dannykoppingNov 28, 2024
63c1852
Removing unnecessary header check
dannykoppingNov 28, 2024
976cd78
Improve tests
dannykoppingNov 28, 2024
9f9068f
Merge branch 'main' of https://github.com/coder/coder into dk/cors
dannykoppingNov 29, 2024
3dc00e1
Comprehensive CORS test suite for both request & response
dannykoppingNov 29, 2024
5e1c6eb
Merge remote-tracking branch 'origin/main' into stevenmasley/cors
EmyrkApr 28, 2025
3266967
make gen
EmyrkApr 28, 2025
9065623
formatting
EmyrkApr 28, 2025
991d285
move cors to after app handling
EmyrkApr 29, 2025
5ba7b82
gen
EmyrkApr 29, 2025
bc8cce3
chore: work on template to test cors
EmyrkApr 29, 2025
de30a29
chore: add template to test cors behavior
EmyrkApr 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
1 change: 1 addition & 0 deletionscoderd/database/dbauthz/dbauthz_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3997,6 +3997,7 @@ func (s *MethodTestSuite) TestSystemFunctions() {
Health: database.WorkspaceAppHealthDisabled,
SharingLevel: database.AppSharingLevelOwner,
OpenIn: database.WorkspaceAppOpenInSlimWindow,
CORSBehavior: database.AppCorsBehaviorSimple,
}).Asserts(rbac.ResourceSystem, policy.ActionCreate)
}))
s.Run("InsertWorkspaceResourceMetadata", 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@@ -723,6 +723,7 @@ func WorkspaceApp(t testing.TB, db database.Store, orig database.WorkspaceApp) d
DisplayOrder: takeFirst(orig.DisplayOrder, 1),
Hidden: orig.Hidden,
OpenIn: takeFirst(orig.OpenIn, database.WorkspaceAppOpenInSlimWindow),
CORSBehavior: takeFirst(orig.CORSBehavior, database.AppCorsBehaviorSimple),
})
require.NoError(t, err, "insert app")
return resource
Expand Down
5 changes: 5 additions & 0 deletionscoderd/database/dbmem/dbmem.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9701,6 +9701,10 @@ func (q *FakeQuerier) InsertWorkspaceApp(_ context.Context, arg database.InsertW
arg.OpenIn = database.WorkspaceAppOpenInSlimWindow
}

if arg.CORSBehavior == "" {
arg.CORSBehavior = database.AppCorsBehaviorSimple
}

// nolint:gosimple
workspaceApp := database.WorkspaceApp{
ID: arg.ID,
Expand All@@ -9721,6 +9725,7 @@ func (q *FakeQuerier) InsertWorkspaceApp(_ context.Context, arg database.InsertW
Hidden: arg.Hidden,
DisplayOrder: arg.DisplayOrder,
OpenIn: arg.OpenIn,
CORSBehavior: arg.CORSBehavior,
}
q.workspaceApps = append(q.workspaceApps, workspaceApp)
return workspaceApp, nil
Expand Down
8 changes: 7 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,4 @@
ALTER TABLE workspace_apps
DROP COLUMN IF EXISTS cors_behavior;

DROP TYPE IF EXISTS app_cors_behavior;
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
CREATE TYPE app_cors_behavior AS ENUM (
'simple',
'passthru'
);

-- https://www.postgresql.org/docs/16/sql-altertable.html
-- When a column is added with ADD COLUMN and a non-volatile DEFAULT is specified, the default is evaluated at the time
-- of the statement and the result stored in the table's metadata. That value will be used for the column for all existing rows.
ALTER TABLE workspace_apps
ADD COLUMN cors_behavior app_cors_behavior NOT NULL DEFAULT 'simple'::app_cors_behavior;
63 changes: 61 additions & 2 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.

18 changes: 13 additions & 5 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.

3 changes: 2 additions & 1 deletioncoderd/database/queries/workspaceapps.sql
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,6 +24,7 @@ INSERT INTO
external,
subdomain,
sharing_level,
cors_behavior,
healthcheck_url,
healthcheck_interval,
healthcheck_threshold,
Expand All@@ -33,7 +34,7 @@ INSERT INTO
open_in
)
VALUES
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18) RETURNING *;
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19) RETURNING *;

-- name: UpdateWorkspaceAppHealthByID :exec
UPDATE
Expand Down
2 changes: 2 additions & 0 deletionscoderd/database/sqlc.yaml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -147,6 +147,8 @@ sql:
crypto_key_feature_workspace_apps_api_key: CryptoKeyFeatureWorkspaceAppsAPIKey
crypto_key_feature_oidc_convert: CryptoKeyFeatureOIDCConvert
stale_interval_ms: StaleIntervalMS
app_cors_behavior: AppCORSBehavior
cors_behavior: CORSBehavior
rules:
- name: do-not-use-public-schema-in-queries
message: "do not use public schema in queries"
Expand Down
9 changes: 9 additions & 0 deletionscoderd/provisionerdserver/provisionerdserver.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2225,6 +2225,14 @@ func InsertWorkspaceResource(ctx context.Context, db database.Store, jobID uuid.
openIn = database.WorkspaceAppOpenInSlimWindow
}

var corsBehavior database.AppCORSBehavior
switch app.CorsBehavior {
case sdkproto.AppCORSBehavior_PASSTHRU:
corsBehavior = database.AppCorsBehaviorPassthru
default:
corsBehavior = database.AppCorsBehaviorSimple
}

dbApp, err := db.InsertWorkspaceApp(ctx, database.InsertWorkspaceAppParams{
ID: uuid.New(),
CreatedAt: dbtime.Now(),
Expand All@@ -2251,6 +2259,7 @@ func InsertWorkspaceResource(ctx context.Context, db database.Store, jobID uuid.
DisplayOrder: int32(app.Order),
Hidden: app.Hidden,
OpenIn: openIn,
CORSBehavior: corsBehavior,
})
if err != nil {
return xerrors.Errorf("insert app: %w", err)
Expand Down
Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp