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

Commit54b09d9

Browse files
authored
fix: show an error banner if the user does not have permission to view the audit page (#16637)
1 parentf670559 commit54b09d9

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

‎coderd/coderd.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,25 @@ func New(options *Options) *API {
930930
r.Route("/audit",func(r chi.Router) {
931931
r.Use(
932932
apiKeyMiddleware,
933+
// This middleware only checks the site and orgs for the audit_log read
934+
// permission.
935+
// In the future if it makes sense to have this permission on the user as
936+
// well we will need to update this middleware to include that check.
937+
func(next http.Handler) http.Handler {
938+
returnhttp.HandlerFunc(func(rw http.ResponseWriter,r*http.Request) {
939+
ifapi.Authorize(r,policy.ActionRead,rbac.ResourceAuditLog) {
940+
next.ServeHTTP(rw,r)
941+
return
942+
}
943+
944+
ifapi.Authorize(r,policy.ActionRead,rbac.ResourceAuditLog.AnyOrganization()) {
945+
next.ServeHTTP(rw,r)
946+
return
947+
}
948+
949+
httpapi.Forbidden(rw)
950+
})
951+
},
933952
)
934953

935954
r.Get("/",api.auditLogs)

‎site/src/pages/AuditPage/AuditPage.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import{paginatedAudits}from"api/queries/audits";
2+
import{ErrorAlert}from"components/Alert/ErrorAlert";
23
import{useFilter}from"components/Filter/Filter";
34
import{useUserFilterMenu}from"components/Filter/UserFilter";
45
import{isNonInitialPage}from"components/PaginationWidget/utils";
@@ -67,6 +68,14 @@ const AuditPage: FC = () => {
6768
}),
6869
});
6970

71+
if(auditsQuery.error){
72+
return(
73+
<divclassName="p-6">
74+
<ErrorAlerterror={auditsQuery.error}/>
75+
</div>
76+
);
77+
}
78+
7079
return(
7180
<>
7281
<Helmet>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp