Skip to content

feat: show user-auth provisioners #14883

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 9 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
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
6 changes: 4 additions & 2 deletions enterprise/coderd/provisionerkeys.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,11 @@ func (api *API) provisionerKeyDaemons(rw http.ResponseWriter, r *http.Request) {

pkDaemons := []codersdk.ProvisionerKeyDaemons{}
for _, key := range sdkKeys {
// currently we exclude user-auth from this list
// Currently the user-auth key orgID is hardcoded to the default org.
// This will be changed when we update the `user-auth` keys to be
// directly tied to a user ID.
if key.ID.String() == codersdk.ProvisionerKeyIDUserAuth {
continue
key.OrganizationID = organization.ID
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This says the default org, but the organization could be any org right? The organization.ID comes from the org in the url

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment is confusing and will update it. The user-auth key.OrganizationID is hardcoded to the default org in the database and we are overwriting it here. The organization is valid here because it's the ID we use to query the list to begin with. It's just that for provisioners in the non-default org that use user-auth would have the default org ID returned here, so we edit the fake user-auth key to have the correct org here before returning it.

}
daemons := []codersdk.ProvisionerDaemon{}
for _, daemon := range recentDaemons {
Expand Down
63 changes: 28 additions & 35 deletions site/src/modules/provisioners/ProvisionerGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { createDayString } from "utils/createDayString";
import { docs } from "utils/docs";
import { ProvisionerTag } from "./ProvisionerTag";

type ProvisionerGroupType = "builtin" | "psk" | "key";
type ProvisionerGroupType = "builtin" | "userAuth" | "psk" | "key";

interface ProvisionerGroupProps {
readonly buildInfo: BuildInfoResponse;
Expand Down Expand Up @@ -102,9 +102,6 @@ export const ProvisionerGroup: FC<ProvisionerGroupProps> = ({
? "1 provisioner"
: `${provisionersWithWarnings} provisioners`;

const hasMultipleTagVariants =
type === "psk" && provisioners.some((it) => !isSimpleTagSet(it.tags));

return (
<div
css={[
Expand Down Expand Up @@ -143,6 +140,8 @@ export const ProvisionerGroup: FC<ProvisionerGroupProps> = ({
</>
)}

{type === "userAuth" && <UserAuthProvisionerTitle />}

{type === "psk" && <PskProvisionerTitle />}
{type === "key" && (
<h4 css={styles.groupTitle}>Key group &ndash; {keyName}</h4>
Expand All @@ -167,32 +166,7 @@ export const ProvisionerGroup: FC<ProvisionerGroupProps> = ({
gap: 12,
justifyContent: "right",
}}
>
{!hasMultipleTagVariants ? (
<Tooltip title="Scope">
<Pill
size="lg"
icon={
daemonScope === "organization" ? (
<BusinessIcon />
) : (
<PersonIcon />
)
}
>
<span css={{ textTransform: "capitalize" }}>{daemonScope}</span>
</Pill>
</Tooltip>
) : (
<Pill size="lg" icon={<TagIcon />}>
Multiple tags
</Pill>
)}
{type === "key" &&
extraTags.map(([key, value]) => (
<ProvisionerTag key={key} tagName={key} tagValue={value} />
))}
</div>
></div>
</header>

{showDetails && (
Expand Down Expand Up @@ -248,9 +222,7 @@ export const ProvisionerGroup: FC<ProvisionerGroupProps> = ({
)}
</span>
</div>
{hasMultipleTagVariants && (
<PskProvisionerTags tags={provisioner.tags} />
)}
<ProvisionerTags tags={provisioner.tags} />
</Stack>
</div>
))}
Expand Down Expand Up @@ -335,11 +307,11 @@ const ProvisionerVersionPopover: FC<ProvisionerVersionPopoverProps> = ({
);
};

interface PskProvisionerTagsProps {
interface ProvisionerTagsProps {
tags: Record<string, string>;
}

const PskProvisionerTags: FC<PskProvisionerTagsProps> = ({ tags }) => {
const ProvisionerTags: FC<ProvisionerTagsProps> = ({ tags }) => {
const daemonScope = tags.scope || "organization";
const iconScope =
daemonScope === "organization" ? <BusinessIcon /> : <PersonIcon />;
Expand Down Expand Up @@ -413,6 +385,27 @@ const BuiltinProvisionerTitle: FC = () => {
);
};

const UserAuthProvisionerTitle: FC = () => {
return (
<h4 css={styles.groupTitle}>
<Stack direction="row" alignItems="end" spacing={1}>
<span>User provisioners</span>
<HelpTooltip>
<HelpTooltipTrigger />
<HelpTooltipContent>
<HelpTooltipTitle>User provisioners</HelpTooltipTitle>
<HelpTooltipText>
These provisioners all use user session authentication. User
provisioners can be scoped to the user or organization.{" "}
<Link href={docs("/")}>Learn more&hellip;</Link>
</HelpTooltipText>
</HelpTooltipContent>
</HelpTooltip>
</Stack>
</h4>
);
};

const PskProvisionerTitle: FC = () => {
return (
<h4 css={styles.groupTitle}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,28 +110,16 @@ const ViewContent: FC<ViewContentProps> = ({ buildInfo, provisioners }) => {
</div>
)}
<Stack spacing={4.5}>
{provisioners.map((group) => {
const type = getGroupType(group.key);

// We intentionally hide user-authenticated provisioners for now
// because there are 1. some grouping issues on the backend and 2. we
// should ideally group them by the user who authenticated them, and
// not just lump them all together.
if (type === "userAuth") {
return null;
}

return (
<ProvisionerGroup
key={group.key.id}
buildInfo={buildInfo}
keyName={group.key.name}
keyTags={group.key.tags}
type={type}
provisioners={group.daemons}
/>
);
})}
{provisioners.map((group) => (
<ProvisionerGroup
key={group.key.id}
buildInfo={buildInfo}
keyName={group.key.name}
keyTags={group.key.tags}
type={getGroupType(group.key)}
provisioners={group.daemons}
/>
))}
</Stack>
</>
);
Expand Down
Loading