workspace

package
v0.0.0-...-b112479 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 18, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

AuthZProvider providers WorkspaceAuthZ implementations.

Functions

func ProjectIDByName

func ProjectIDByName(ctx context.Context, workspaceID int, projectName string) (*int, error)

ProjectIDByName returns a project's ID if it exists in the given workspace.

func WorkspaceByName

func WorkspaceByName(ctx context.Context, workspaceName string) (*model.Workspace, error)

WorkspaceByName returns a workspace given it's name.

Types

type WorkspaceAuthZ

type WorkspaceAuthZ interface {
	// GET /api/v1/workspaces/:workspace_id
	CanGetWorkspace(
		ctx context.Context, curUser model.User, workspace *workspacev1.Workspace,
	) (canGetWorkspace bool, serverError error)

	// GET /api/v1/workspaces/:workspace_id/projects
	FilterWorkspaceProjects(
		ctx context.Context, curUser model.User, projects []*projectv1.Project,
	) ([]*projectv1.Project, error)

	// GET /api/v1/workspaces
	FilterWorkspaces(
		ctx context.Context, curUser model.User, workspaces []*workspacev1.Workspace,
	) ([]*workspacev1.Workspace, error)

	// POST /api/v1/workspaces
	CanCreateWorkspace(ctx context.Context, curUser model.User) error
	CanCreateWorkspaceWithAgentUserGroup(ctx context.Context, curUser model.User) error
	CanCreateWorkspaceWithCheckpointStorageConfig(ctx context.Context, curUser model.User) error

	// PATCH /api/v1/workspaces/:workspace_id
	CanSetWorkspacesName(
		ctx context.Context, curUser model.User, workspace *workspacev1.Workspace,
	) error
	CanSetWorkspacesAgentUserGroup(
		ctx context.Context, curUser model.User, workspace *workspacev1.Workspace,
	) error
	CanSetWorkspacesCheckpointStorageConfig(
		ctx context.Context, curUser model.User, workspace *workspacev1.Workspace,
	) error

	// DELETE /api/v1/workspaces/:workspace_id
	CanDeleteWorkspace(
		ctx context.Context, curUser model.User, workspace *workspacev1.Workspace,
	) error

	// POST /api/v1/workspaces/:workspace_id/archive
	CanArchiveWorkspace(
		ctx context.Context, curUser model.User, workspace *workspacev1.Workspace,
	) error
	// POST /api/v1/workspaces/:workspace_id/unarchive
	CanUnarchiveWorkspace(
		ctx context.Context, curUser model.User, workspace *workspacev1.Workspace,
	) error

	// POST /api/v1/workspaces/:workspace_id/pin
	CanPinWorkspace(
		ctx context.Context, curUser model.User, workspace *workspacev1.Workspace,
	) error
	// POST /api/v1/workspaces/:workspace_id/unpin
	CanUnpinWorkspace(
		ctx context.Context, curUser model.User, workspace *workspacev1.Workspace,
	) error
}

WorkspaceAuthZ is the interface for workspace authorization.

type WorkspaceAuthZBasic

type WorkspaceAuthZBasic struct{}

WorkspaceAuthZBasic is classic OSS Determined authentication for workspaces.

func (*WorkspaceAuthZBasic) CanArchiveWorkspace

func (a *WorkspaceAuthZBasic) CanArchiveWorkspace(
	ctx context.Context, curUser model.User, workspace *workspacev1.Workspace,
) error

CanArchiveWorkspace returns an error if the user is not an admin or not the owner of the workspace.

func (*WorkspaceAuthZBasic) CanCreateWorkspace

func (a *WorkspaceAuthZBasic) CanCreateWorkspace(ctx context.Context, curUser model.User) error

CanCreateWorkspace always returns a nil error.

func (*WorkspaceAuthZBasic) CanCreateWorkspaceWithAgentUserGroup

func (a *WorkspaceAuthZBasic) CanCreateWorkspaceWithAgentUserGroup(
	ctx context.Context, curUser model.User,
) error

CanCreateWorkspaceWithAgentUserGroup requires user to be an admin.

func (*WorkspaceAuthZBasic) CanCreateWorkspaceWithCheckpointStorageConfig

func (a *WorkspaceAuthZBasic) CanCreateWorkspaceWithCheckpointStorageConfig(
	ctx context.Context, curUser model.User,
) error

CanCreateWorkspaceWithCheckpointStorageConfig returns an nil error.

func (*WorkspaceAuthZBasic) CanDeleteWorkspace

func (a *WorkspaceAuthZBasic) CanDeleteWorkspace(
	ctx context.Context, curUser model.User, workspace *workspacev1.Workspace,
) error

CanDeleteWorkspace returns an error if the user is not an admin or not the owner of the workspace.

func (*WorkspaceAuthZBasic) CanGetWorkspace

func (a *WorkspaceAuthZBasic) CanGetWorkspace(
	ctx context.Context, curUser model.User, workspace *workspacev1.Workspace,
) (canGetWorkspace bool, serverError error)

CanGetWorkspace always return true and a nil error.

func (*WorkspaceAuthZBasic) CanPinWorkspace

func (a *WorkspaceAuthZBasic) CanPinWorkspace(
	ctx context.Context, curUser model.User, workspace *workspacev1.Workspace,
) error

CanPinWorkspace always returns a nil error.

func (*WorkspaceAuthZBasic) CanSetWorkspacesAgentUserGroup

func (a *WorkspaceAuthZBasic) CanSetWorkspacesAgentUserGroup(
	ctx context.Context, curUser model.User, workspace *workspacev1.Workspace,
) error

CanSetWorkspacesAgentUserGroup can only be done by admins.

func (*WorkspaceAuthZBasic) CanSetWorkspacesCheckpointStorageConfig

func (a *WorkspaceAuthZBasic) CanSetWorkspacesCheckpointStorageConfig(
	ctx context.Context, curUser model.User, workspace *workspacev1.Workspace,
) error

CanSetWorkspacesCheckpointStorageConfig returns an error if the user is not an admin or owner of the workspace.

func (*WorkspaceAuthZBasic) CanSetWorkspacesName

func (a *WorkspaceAuthZBasic) CanSetWorkspacesName(
	ctx context.Context, curUser model.User, workspace *workspacev1.Workspace,
) error

CanSetWorkspacesName returns an error if the user is not an admin or not the owner of the workspace.

func (*WorkspaceAuthZBasic) CanUnarchiveWorkspace

func (a *WorkspaceAuthZBasic) CanUnarchiveWorkspace(
	ctx context.Context, curUser model.User, workspace *workspacev1.Workspace,
) error

CanUnarchiveWorkspace returns an error if the user is not an admin or not the owner of the workspace.

func (*WorkspaceAuthZBasic) CanUnpinWorkspace

func (a *WorkspaceAuthZBasic) CanUnpinWorkspace(
	ctx context.Context, curUser model.User, workspace *workspacev1.Workspace,
) error

CanUnpinWorkspace always returns a nil error.

func (*WorkspaceAuthZBasic) FilterWorkspaceProjects

func (a *WorkspaceAuthZBasic) FilterWorkspaceProjects(
	ctx context.Context, curUser model.User, projects []*projectv1.Project,
) ([]*projectv1.Project, error)

FilterWorkspaceProjects always returns the list provided and a nil error.

func (*WorkspaceAuthZBasic) FilterWorkspaces

func (a *WorkspaceAuthZBasic) FilterWorkspaces(
	ctx context.Context, curUser model.User, workspaces []*workspacev1.Workspace,
) ([]*workspacev1.Workspace, error)

FilterWorkspaces always returns provided list and a nil errir.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL