- Notifications
You must be signed in to change notification settings - Fork928
feat: Allow admins to access member workspace terminals#2114
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
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
b0e8f65
edf985b
ec4fccc
b10545e
4e69393
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -37,11 +37,11 @@ type userRolesKey struct{} | ||
// AuthorizationUserRoles returns the roles used for authorization. | ||
// Comes from the ExtractAPIKey handler. | ||
func AuthorizationUserRoles(r *http.Request) database.GetAuthorizationUserRolesRow { | ||
userRoles, ok := r.Context().Value(userRolesKey{}).(database.GetAuthorizationUserRolesRow) | ||
if !ok { | ||
panic("developer error: user roles middleware not provided") | ||
} | ||
returnuserRoles | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Fixing previous debt! | ||
} | ||
// OAuth2Configs is a collection of configurations for OAuth-based authentication. | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -6,6 +6,8 @@ import ( | ||
"errors" | ||
"net/http" | ||
"github.com/go-chi/chi/v5" | ||
"github.com/coder/coder/coderd/database" | ||
"github.com/coder/coder/coderd/httpapi" | ||
) | ||
@@ -74,24 +76,9 @@ func ExtractWorkspaceAgentParam(db database.Store) func(http.Handler) http.Handl | ||
}) | ||
return | ||
} | ||
ctx := context.WithValue(r.Context(), workspaceAgentParamContextKey{}, agent) | ||
chi.RouteContext(ctx).URLParams.Add("workspace", build.WorkspaceID.String()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Adding the workspace param here to check RBAC in the actual call. | ||
next.ServeHTTP(rw, r.WithContext(ctx)) | ||
}) | ||
} | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -63,9 +63,10 @@ interface ResourcesProps { | ||
resources?: WorkspaceResource[] | ||
getResourcesError?: Error | ||
workspace: Workspace | ||
canUpdateWorkspace: boolean | ||
} | ||
export const Resources: FC<ResourcesProps> = ({ resources, getResourcesError, workspace, canUpdateWorkspace }) => { | ||
const styles = useStyles() | ||
const theme: Theme = useTheme() | ||
@@ -89,7 +90,7 @@ export const Resources: FC<ResourcesProps> = ({ resources, getResourcesError, wo | ||
<AgentHelpTooltip /> | ||
</Stack> | ||
</TableCell> | ||
{canUpdateWorkspace &&<TableCell>{Language.accessLabel}</TableCell>} | ||
<TableCell>{Language.statusLabel}</TableCell> | ||
</TableHeaderRow> | ||
</TableHead> | ||
@@ -130,28 +131,30 @@ export const Resources: FC<ResourcesProps> = ({ resources, getResourcesError, wo | ||
{agent.name} | ||
<span className={styles.operatingSystem}>{agent.operating_system}</span> | ||
</TableCell> | ||
{canUpdateWorkspace && ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I could see this living in its own component given the length of the file. | ||
<TableCell> | ||
<Stack> | ||
{agent.status === "connected" && ( | ||
AbhineetJain marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
<TerminalLink | ||
className={styles.accessLink} | ||
workspaceName={workspace.name} | ||
agentName={agent.name} | ||
userName={workspace.owner_name} | ||
/> | ||
)} | ||
{agent.status === "connected" && | ||
agent.apps.map((app) => ( | ||
<AppLink | ||
key={app.name} | ||
appIcon={app.icon} | ||
appName={app.name} | ||
userName={workspace.owner_name} | ||
workspaceName={workspace.name} | ||
/> | ||
))} | ||
</Stack> | ||
</TableCell> | ||
)} | ||
<TableCell> | ||
<span style={{ color: getDisplayAgentStatus(theme, agent).color }}> | ||
{getDisplayAgentStatus(theme, agent).status} | ||
Uh oh!
There was an error while loading.Please reload this page.