- Notifications
You must be signed in to change notification settings - Fork1k
feat: add user_secrets table#19162
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
104bf21
b677273
a826dd3
540f2e2
363173c
e152648
49ac807
85b4f4c
3f04a15
d7605f6
b55be78
3090d52
789a5eb
12b6c2e
317708b
72faf7a
a715310
8ea3cda
b21f07c
0f47bae
1d6f2fa
b24599c
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
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1387,6 +1387,14 @@ func (q *querier) CountUnreadInboxNotificationsByUserID(ctx context.Context, use | ||
return q.db.CountUnreadInboxNotificationsByUserID(ctx, userID) | ||
} | ||
func (q *querier) CreateUserSecret(ctx context.Context, arg database.CreateUserSecretParams) (database.UserSecret, error) { | ||
obj := rbac.ResourceUserSecret.WithOwner(arg.UserID.String()) | ||
if err := q.authorizeContext(ctx, policy.ActionCreate, obj); err != nil { | ||
return database.UserSecret{}, err | ||
} | ||
return q.db.CreateUserSecret(ctx, arg) | ||
} | ||
// TODO: Handle org scoped lookups | ||
func (q *querier) CustomRoles(ctx context.Context, arg database.CustomRolesParams) ([]database.CustomRole, error) { | ||
roleObject := rbac.ResourceAssignRole | ||
@@ -1657,6 +1665,19 @@ func (q *querier) DeleteTailnetTunnel(ctx context.Context, arg database.DeleteTa | ||
return q.db.DeleteTailnetTunnel(ctx, arg) | ||
} | ||
func (q *querier) DeleteUserSecret(ctx context.Context, id uuid.UUID) error { | ||
// First get the secret to check ownership | ||
secret, err := q.GetUserSecret(ctx, id) | ||
if err != nil { | ||
return err | ||
} | ||
if err := q.authorizeContext(ctx, policy.ActionDelete, secret); err != nil { | ||
return err | ||
} | ||
return q.db.DeleteUserSecret(ctx, id) | ||
} | ||
func (q *querier) DeleteWebpushSubscriptionByUserIDAndEndpoint(ctx context.Context, arg database.DeleteWebpushSubscriptionByUserIDAndEndpointParams) error { | ||
if err := q.authorizeContext(ctx, policy.ActionDelete, rbac.ResourceWebpushSubscription.WithOwner(arg.UserID.String())); err != nil { | ||
return err | ||
@@ -3075,6 +3096,28 @@ func (q *querier) GetUserNotificationPreferences(ctx context.Context, userID uui | ||
return q.db.GetUserNotificationPreferences(ctx, userID) | ||
} | ||
func (q *querier) GetUserSecret(ctx context.Context, id uuid.UUID) (database.UserSecret, error) { | ||
// First get the secret to check ownership | ||
secret, err := q.db.GetUserSecret(ctx, id) | ||
if err != nil { | ||
return database.UserSecret{}, err | ||
} | ||
if err := q.authorizeContext(ctx, policy.ActionRead, secret); err != nil { | ||
return database.UserSecret{}, err | ||
} | ||
return secret, nil | ||
} | ||
func (q *querier) GetUserSecretByUserIDAndName(ctx context.Context, arg database.GetUserSecretByUserIDAndNameParams) (database.UserSecret, error) { | ||
obj := rbac.ResourceUserSecret.WithOwner(arg.UserID.String()) | ||
if err := q.authorizeContext(ctx, policy.ActionRead, obj); err != nil { | ||
return database.UserSecret{}, err | ||
} | ||
return q.db.GetUserSecretByUserIDAndName(ctx, arg) | ||
} | ||
func (q *querier) GetUserStatusCounts(ctx context.Context, arg database.GetUserStatusCountsParams) ([]database.GetUserStatusCountsRow, error) { | ||
if err := q.authorizeContext(ctx, policy.ActionRead, rbac.ResourceUser); err != nil { | ||
return nil, err | ||
@@ -4153,6 +4196,14 @@ func (q *querier) ListProvisionerKeysByOrganizationExcludeReserved(ctx context.C | ||
return fetchWithPostFilter(q.auth, policy.ActionRead, q.db.ListProvisionerKeysByOrganizationExcludeReserved)(ctx, organizationID) | ||
} | ||
func (q *querier) ListUserSecrets(ctx context.Context, userID uuid.UUID) ([]database.UserSecret, error) { | ||
obj := rbac.ResourceUserSecret.WithOwner(userID.String()) | ||
if err := q.authorizeContext(ctx, policy.ActionRead, obj); err != nil { | ||
return nil, err | ||
} | ||
return q.db.ListUserSecrets(ctx, userID) | ||
Emyrk marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
} | ||
func (q *querier) ListWorkspaceAgentPortShares(ctx context.Context, workspaceID uuid.UUID) ([]database.WorkspaceAgentPortShare, error) { | ||
workspace, err := q.db.GetWorkspaceByID(ctx, workspaceID) | ||
if err != nil { | ||
@@ -4866,6 +4917,19 @@ func (q *querier) UpdateUserRoles(ctx context.Context, arg database.UpdateUserRo | ||
return q.db.UpdateUserRoles(ctx, arg) | ||
} | ||
func (q *querier) UpdateUserSecret(ctx context.Context, arg database.UpdateUserSecretParams) (database.UserSecret, error) { | ||
// First get the secret to check ownership | ||
secret, err := q.db.GetUserSecret(ctx, arg.ID) | ||
evgeniy-scherbina marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
if err != nil { | ||
return database.UserSecret{}, err | ||
} | ||
if err := q.authorizeContext(ctx, policy.ActionUpdate, secret); err != nil { | ||
return database.UserSecret{}, err | ||
} | ||
return q.db.UpdateUserSecret(ctx, arg) | ||
} | ||
func (q *querier) UpdateUserStatus(ctx context.Context, arg database.UpdateUserStatusParams) (database.User, error) { | ||
fetch := func(ctx context.Context, arg database.UpdateUserStatusParams) (database.User, error) { | ||
return q.db.GetUserByID(ctx, arg.ID) | ||
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.