Skip to content

Commit f347363

Browse files
committed
use can_view_org instead so roles like auditors can view
1 parent 72ce5a2 commit f347363

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

internal/ent/hooks/usersettings.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,11 @@ func allowDefaultOrgUpdate(ctx context.Context, m *generated.UserSettingMutation
8484
SubjectID: owner.ID,
8585
SubjectType: auth.UserSubjectType,
8686
ObjectID: orgID,
87+
Relation: "can_view_org",
8788
Context: utils.NewOrganizationContextKey(usCaller.SubjectEmail),
8889
}
8990

90-
allow, err := m.Authz.CheckOrgReadAccess(ctx, req)
91+
allow, err := m.Authz.CheckOrgAccess(ctx, req)
9192
if err != nil {
9293
return false
9394
}

internal/httpserve/authmanager/authmanager.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,15 +262,16 @@ func (a *Client) authCheck(ctx context.Context, user *generated.User, orgID stri
262262
orgID = caller.OrganizationID
263263
}
264264

265-
// ensure user is already a member of the destination organization
265+
// ensure user can access the destination organization
266266
req := fgax.AccessCheck{
267267
SubjectID: caller.SubjectID,
268268
SubjectType: auth.UserSubjectType,
269269
ObjectID: orgID,
270+
Relation: "can_view_org",
270271
Context: utils.NewOrganizationContextKey(caller.SubjectEmail),
271272
}
272273

273-
allow, err := a.db.Authz.CheckOrgReadAccess(ctx, req)
274+
allow, err := a.db.Authz.CheckOrgAccess(ctx, req)
274275
if err != nil {
275276
logx.FromContext(ctx).Error().Err(err).Str("user_id", caller.SubjectID).Str("org_id", orgID).Msg("unable to check org read access")
276277

0 commit comments

Comments
 (0)