Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit21917b2

Browse files
committed
work on dbauthz
1 parent5e5d641 commit21917b2

File tree

17 files changed

+113
-7
lines changed

17 files changed

+113
-7
lines changed

‎coderd/apidoc/docs.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/apidoc/swagger.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/dbauthz/dbauthz.go

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,11 +1418,11 @@ func (q *querier) FavoriteWorkspace(ctx context.Context, id uuid.UUID) error {
14181418
}
14191419

14201420
func (q*querier)FetchInboxNotificationsByUserID(ctx context.Context,userID uuid.UUID) ([]database.NotificationsInbox,error) {
1421-
panic("not implemented")
1421+
returnfetchWithPostFilter(q.auth,policy.ActionRead,q.db.FetchInboxNotificationsByUserID)(ctx,userID)
14221422
}
14231423

14241424
func (q*querier)FetchInboxNotificationsByUserIDAndTemplateIDAndTargetID(ctx context.Context,arg database.FetchInboxNotificationsByUserIDAndTemplateIDAndTargetIDParams) ([]database.NotificationsInbox,error) {
1425-
panic("not implemented")
1425+
returnfetchWithPostFilter(q.auth,policy.ActionRead,q.db.FetchInboxNotificationsByUserIDAndTemplateIDAndTargetID)(ctx,arg)
14261426
}
14271427

14281428
func (q*querier)FetchMemoryResourceMonitorsByAgentID(ctx context.Context,agentID uuid.UUID) (database.WorkspaceAgentMemoryResourceMonitor,error) {
@@ -1447,11 +1447,11 @@ func (q *querier) FetchNewMessageMetadata(ctx context.Context, arg database.Fetc
14471447
}
14481448

14491449
func (q*querier)FetchUnreadInboxNotificationsByUserID(ctx context.Context,userID uuid.UUID) ([]database.NotificationsInbox,error) {
1450-
panic("not implemented")
1450+
returnfetchWithPostFilter(q.auth,policy.ActionRead,q.db.FetchUnreadInboxNotificationsByUserID)(ctx,userID)
14511451
}
14521452

14531453
func (q*querier)FetchUnreadInboxNotificationsByUserIDAndTemplateIDAndTargetID(ctx context.Context,arg database.FetchUnreadInboxNotificationsByUserIDAndTemplateIDAndTargetIDParams) ([]database.NotificationsInbox,error) {
1454-
panic("not implemented")
1454+
returnfetchWithPostFilter(q.auth,policy.ActionRead,q.db.FetchUnreadInboxNotificationsByUserIDAndTemplateIDAndTargetID)(ctx,arg)
14551455
}
14561456

14571457
func (q*querier)FetchVolumesResourceMonitorsByAgentID(ctx context.Context,agentID uuid.UUID) ([]database.WorkspaceAgentVolumeResourceMonitor,error) {
@@ -1766,6 +1766,10 @@ func (q *querier) GetHungProvisionerJobs(ctx context.Context, hungSince time.Tim
17661766
returnq.db.GetHungProvisionerJobs(ctx,hungSince)
17671767
}
17681768

1769+
func (q*querier)GetInboxNotificationByID(ctx context.Context,id uuid.UUID) (database.NotificationsInbox,error) {
1770+
returnfetchWithAction(q.log,q.auth,policy.ActionRead,q.db.GetInboxNotificationByID)(ctx,id)
1771+
}
1772+
17691773
func (q*querier)GetJFrogXrayScanByWorkspaceAndAgentID(ctx context.Context,arg database.GetJFrogXrayScanByWorkspaceAndAgentIDParams) (database.JfrogXrayScan,error) {
17701774
if_,err:=fetch(q.log,q.auth,q.db.GetWorkspaceByID)(ctx,arg.WorkspaceID);err!=nil {
17711775
return database.JfrogXrayScan{},err
@@ -3094,7 +3098,7 @@ func (q *querier) InsertGroupMember(ctx context.Context, arg database.InsertGrou
30943098
}
30953099

30963100
func (q*querier)InsertInboxNotification(ctx context.Context,arg database.InsertInboxNotificationParams) (database.NotificationsInbox,error) {
3097-
panic("not implemented")
3101+
returninsert(q.log,q.auth,rbac.ResourceNotificationInbox.WithOwner(arg.UserID.String()),q.db.InsertInboxNotification)(ctx,arg)
30983102
}
30993103

31003104
func (q*querier)InsertLicense(ctx context.Context,arg database.InsertLicenseParams) (database.License,error) {
@@ -3585,7 +3589,15 @@ func (q *querier) RevokeDBCryptKey(ctx context.Context, activeKeyDigest string)
35853589
}
35863590

35873591
func (q*querier)SetInboxNotificationAsRead(ctx context.Context,arg database.SetInboxNotificationAsReadParams)error {
3588-
panic("not implemented")
3592+
fetch:=func(ctx context.Context,id uuid.UUID) (database.NotificationsInbox,error) {
3593+
returnq.db.GetInboxNotificationByID(ctx,id)
3594+
}
3595+
3596+
update:=func(ctx context.Context,arg database.SetInboxNotificationAsReadParams)error {
3597+
returnq.db.SetInboxNotificationAsRead(ctx,arg)
3598+
}
3599+
3600+
returnupdate(q.log,q.auth,policy.ActionUpdate,fetch,update)(ctx,arg)
35893601
}
35903602

35913603
func (q*querier)TryAcquireLock(ctx context.Context,idint64) (bool,error) {

‎coderd/database/dbmem/dbmem.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3358,6 +3358,10 @@ func (q *FakeQuerier) GetHungProvisionerJobs(_ context.Context, hungSince time.T
33583358
returnhungJobs,nil
33593359
}
33603360

3361+
func (q*FakeQuerier)GetInboxNotificationByID(ctx context.Context,id uuid.UUID) (database.NotificationsInbox,error) {
3362+
panic("not implemented")
3363+
}
3364+
33613365
func (q*FakeQuerier)GetJFrogXrayScanByWorkspaceAndAgentID(_ context.Context,arg database.GetJFrogXrayScanByWorkspaceAndAgentIDParams) (database.JfrogXrayScan,error) {
33623366
err:=validateDatabaseType(arg)
33633367
iferr!=nil {

‎coderd/database/dbmetrics/querymetrics.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/dbmock/dbmock.go

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/modelmethods.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,12 @@ func (TemplateVersion) RBACObject(template Template) rbac.Object {
168168
returntemplate.RBACObject()
169169
}
170170

171+
func (iNotificationsInbox)RBACObject() rbac.Object {
172+
returnrbac.ResourceNotificationInbox.
173+
WithID(i.ID).
174+
WithOwner(i.UserID.String())
175+
}
176+
171177
// RBACObjectNoTemplate is for orphaned template versions.
172178
func (vTemplateVersion)RBACObjectNoTemplate() rbac.Object {
173179
returnrbac.ResourceTemplate.InOrg(v.OrganizationID)

‎coderd/database/querier.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/queries.sql.go

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/queries/notificationsinbox.sql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ SELECT * FROM notifications_inbox WHERE user_id = $1 AND template_id = $2 AND ta
1010
-- name: FetchUnreadInboxNotificationsByUserIDAndTemplateIDAndTargetID :many
1111
SELECT*FROM notifications_inboxWHERE user_id= $1AND template_id= $2AND target_id= $3AND read_at ISNULLORDER BY created_atDESC;
1212

13+
-- name: GetInboxNotificationByID :one
14+
SELECT*FROM notifications_inboxWHERE id= $1;
15+
1316
-- name: InsertInboxNotification :one
1417
INSERT INTO
1518
notifications_inbox (
@@ -32,4 +35,4 @@ UPDATE
3235
SET
3336
read_at= $1
3437
WHERE
35-
id=$2;
38+
id=@id;

‎coderd/rbac/object_gen.go

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/rbac/policy/policy.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,13 @@ var RBACPermissions = map[string]PermissionDefinition{
287287
ActionUpdate:actDef("update notification preferences"),
288288
},
289289
},
290+
"notification_inbox": {
291+
Actions:map[Action]ActionDefinition{
292+
ActionCreate:actDef("create notifications inbox"),
293+
ActionRead:actDef("read notifications inbox"),
294+
ActionUpdate:actDef("update notifications inbox"),
295+
},
296+
},
290297
"crypto_key": {
291298
Actions:map[Action]ActionDefinition{
292299
ActionRead:actDef("read crypto keys"),

‎codersdk/rbacresources_gen.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎docs/reference/api/members.md

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎docs/reference/api/schemas.md

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎site/src/api/rbacresourcesGenerated.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ export const RBACResourceActions: Partial<
7070
delete:"delete license",
7171
read:"read licenses",
7272
},
73+
notification_inbox:{
74+
create:"create notifications inbox",
75+
read:"read notifications inbox",
76+
update:"update notifications inbox",
77+
},
7378
notification_message:{
7479
create:"create notification messages",
7580
delete:"delete notification messages",

‎site/src/api/typesGenerated.ts

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp