File tree 2 files changed +28
-0
lines changed
2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -930,6 +930,25 @@ func New(options *Options) *API {
930
930
r .Route ("/audit" , func (r chi.Router ) {
931
931
r .Use (
932
932
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
+ return http .HandlerFunc (func (rw http.ResponseWriter , r * http.Request ) {
939
+ if api .Authorize (r , policy .ActionRead , rbac .ResourceAuditLog ) {
940
+ next .ServeHTTP (rw , r )
941
+ return
942
+ }
943
+
944
+ if api .Authorize (r , policy .ActionRead , rbac .ResourceAuditLog .AnyOrganization ()) {
945
+ next .ServeHTTP (rw , r )
946
+ return
947
+ }
948
+
949
+ httpapi .Forbidden (rw )
950
+ })
951
+ },
933
952
)
934
953
935
954
r .Get ("/" , api .auditLogs )
Original file line number Diff line number Diff line change 1
1
import { paginatedAudits } from "api/queries/audits" ;
2
+ import { ErrorAlert } from "components/Alert/ErrorAlert" ;
2
3
import { useFilter } from "components/Filter/Filter" ;
3
4
import { useUserFilterMenu } from "components/Filter/UserFilter" ;
4
5
import { isNonInitialPage } from "components/PaginationWidget/utils" ;
@@ -67,6 +68,14 @@ const AuditPage: FC = () => {
67
68
} ) ,
68
69
} ) ;
69
70
71
+ if ( auditsQuery . error ) {
72
+ return (
73
+ < div className = "p-6" >
74
+ < ErrorAlert error = { auditsQuery . error } />
75
+ </ div >
76
+ ) ;
77
+ }
78
+
70
79
return (
71
80
< >
72
81
< Helmet >
You can’t perform that action at this time.
0 commit comments