- Notifications
You must be signed in to change notification settings - Fork925
fix: allow dynamic parameters without requiring org membership#18531
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
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 |
---|---|---|
@@ -243,24 +243,30 @@ func (r *dynamicRenderer) getWorkspaceOwnerData(ctx context.Context, ownerID uui | ||
return nil // already fetched | ||
} | ||
user, err := r.db.GetUserByID(ctx, ownerID) | ||
if err != nil { | ||
// If the user failed to read, we also try to read the user from their | ||
// organization member. You only need to be able to read the organization member | ||
// to get the owner data. | ||
// | ||
// Only the terraform files can therefore leak more information than the | ||
// caller should have access to. All this info should be public assuming you can | ||
// read the user though. | ||
mem, err := database.ExpectOne(r.db.OrganizationMembers(ctx, database.OrganizationMembersParams{ | ||
OrganizationID: r.data.templateVersion.OrganizationID, | ||
UserID: ownerID, | ||
IncludeSystem: true, | ||
})) | ||
if err != nil { | ||
return xerrors.Errorf("fetch user: %w", err) | ||
} | ||
// Org member fetched, so use the provisioner context to fetch the user. | ||
//nolint:gocritic // Has the correct permissions, and matches the provisioning flow. | ||
user, err = r.db.GetUserByID(dbauthz.AsProvisionerd(ctx), mem.OrganizationMember.UserID) | ||
if err != nil { | ||
return xerrors.Errorf("fetch user: %w", err) | ||
} | ||
Comment on lines +246 to +269 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. If the Renderer had the authz object, we could fetch the user with elevated perms, then check the user's perms. Removing 1 sql query round trip 😢 | ||
} | ||
// nolint:gocritic // This is kind of the wrong query to use here, but it | ||
@@ -314,10 +320,10 @@ func (r *dynamicRenderer) getWorkspaceOwnerData(ctx context.Context, ownerID uui | ||
} | ||
r.currentOwner = &previewtypes.WorkspaceOwner{ | ||
ID:user.ID.String(), | ||
Name:user.Username, | ||
FullName:user.Name, | ||
Email:user.Email, | ||
LoginType: string(user.LoginType), | ||
RBACRoles: ownerRoles, | ||
SSHPublicKey: key.PublicKey, | ||
Uh oh!
There was an error while loading.Please reload this page.