8000 feat: app sharing (now open source!) by deansheather · Pull Request #4378 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

feat: app sharing (now open source!) #4378

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Next Next commit
feat: app sharing pt.1
  • Loading branch information
deansheather committed Oct 5, 2022
commit 6b68642355cbb36a332205e45817b36e1dbe2ee9
9 changes: 9 additions & 0 deletions coderd/coderd.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type Options struct {

Auditor audit.Auditor
WorkspaceQuotaEnforcer workspacequota.Enforcer
AppAuthorizer AppAuthorizer
AgentConnectionUpdateFrequency time.Duration
AgentInactiveDisconnectTimeout time.Duration
// APIRateLimit is the minutely throughput rate limit per user or ip.
Expand Down Expand Up @@ -126,6 +127,11 @@ func New(options *Options) *API {
if options.WorkspaceQuotaEnforcer == nil {
options.WorkspaceQuotaEnforcer = workspacequota.NewNop()
}
if options.AppAuthorizer == nil {
options.AppAuthorizer = &AGPLAppAuthorizer{
RBAC: options.Authorizer,
}
}

siteCacheDir := options.CacheDir
if siteCacheDir != "" {
Expand Down Expand Up @@ -154,9 +160,11 @@ func New(options *Options) *API {
metricsCache: metricsCache,
Auditor: atomic.Pointer[audit.Auditor]{},
WorkspaceQuotaEnforcer: atomic.Pointer[workspacequota.Enforcer]{},
AppAuthorizer: atomic.Pointer[AppAuthorizer]{},
}
api.Auditor.Store(&options.Auditor)
api.WorkspaceQuotaEnforcer.Store(&options.WorkspaceQuotaEnforcer)
api.AppAuthorizer.Store(&options.AppAuthorizer)
api.workspaceAgentCache = wsconncache.New(api.dialWorkspaceAgentTailnet, 0)
api.derpServer = derp.NewServer(key.NewNode(), tailnet.Logger(options.Logger))
oauthConfigs := &httpmw.OAuth2Configs{
Expand Down Expand Up @@ -517,6 +525,7 @@ type API struct {
Auditor atomic.Pointer[audit.Auditor]
WorkspaceClientCoordinateOverride atomic.Pointer[func(rw http.ResponseWriter) bool]
WorkspaceQuotaEnforcer atomic.Pointer[workspacequota.Enforcer]
AppAuthorizer atomic.Pointer[AppAuthorizer]
HTTPAuth *HTTPAuthorizer

// APIHandler serves "/api/v2"
Expand Down
10 changes: 9 additions & 1 deletion coderd/database/dump.sql

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

5 changes: 5 additions & 0 deletions coderd/database/migrations/000055_app_share_level.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- Drop column share_level from workspace_apps
ALTER TABLE workspace_apps DROP COLUMN share_level;

-- Drop type app_share_level
DROP TYPE app_share_level;
15 changes: 15 additions & 0 deletions coderd/database/migrations/000055_app_share_level.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-- Add enum app_share_level
CREATE TYPE app_share_level AS ENUM (
-- only the workspace owner can access the app
'owner',
-- the workspace owner and other users that can read the workspace template
-- can access the app
'template',
-- any authenticated user on the site can access the app
'authenticated',
-- any user can access the app even if they are not authenticated
'public'
);

-- Add share_level column to workspace_apps table
ALTER TABLE workspace_apps ADD COLUMN share_level app_share_level NOT NULL DEFAULT 'owner'::app_share_level;
22 changes: 22 additions & 0 deletions coderd/database/models.go

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

15 changes: 10 additions & 5 deletions coderd/database/queries.sql.go

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

Loading
0