Skip to content

Commit

Permalink
chore(CE): add audit logs serializer and audit log permission (#426)
Browse files Browse the repository at this point in the history
Co-authored-by: TivonB-AI2 <[email protected]>
  • Loading branch information
github-actions[bot] and TivonB-AI2 authored Oct 24, 2024
1 parent d7ec9c9 commit 7a2fdfa
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 1 deletion.
7 changes: 7 additions & 0 deletions server/app/serializers/audit_logs_serializer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

# app/serializers/audit_logs_serializer.rb
class AuditLogsSerializer < ActiveModel::Serializer
attributes :id, :user_id, :action, :resource_type, :resource_id, :resource, :workspace_id,
:metadata
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# frozen_string_literal: true

class AddAuditLogsPermissionToRoles < ActiveRecord::Migration[7.1]
def change # rubocop:disable Metrics/MethodLength
admin_role = Role.find_by(role_name: "Admin")
member_role = Role.find_by(role_name: "Member")
viewer_role = Role.find_by(role_name: "Viewer")

admin_role&.update!(
policies: {
permissions: {
connector_definition: { create: true, read: true, update: true, delete: true },
connector: { create: true, read: true, update: true, delete: true },
model: { create: true, read: true, update: true, delete: true },
report: { create: true, read: true, update: true, delete: true },
sync_record: { create: true, read: true, update: true, delete: true },
sync_run: { create: true, read: true, update: true, delete: true },
sync: { create: true, read: true, update: true, delete: true },
user: { create: true, read: true, update: true, delete: true },
workspace: { create: true, read: true, update: true, delete: true },
data_app: { create: true, read: true, update: true, delete: true },
audit_logs: { create: true, read: true, update: true, delete: true }
}
}
)

member_role&.update!(
policies: {
permissions: {
connector_definition: { create: true, read: true, update: true, delete: true },
connector: { create: true, read: true, update: true, delete: true },
model: { create: true, read: true, update: true, delete: true },
report: { create: true, read: true, update: true, delete: true },
sync_record: { create: true, read: true, update: true, delete: true },
sync_run: { create: true, read: true, update: true, delete: true },
sync: { create: true, read: true, update: true, delete: true },
user: { create: false, read: true, update: false, delete: false },
workspace: { create: false, read: true, update: false, delete: false },
data_app: { create: true, read: true, update: true, delete: true },
audit_logs: { create: true, read: true, update: true, delete: true }
}
}
)

viewer_role&.update!(
policies: {
permissions: {
connector_definition: { create: false, read: true, update: false, delete: false },
connector: { create: false, read: true, update: false, delete: false },
model: { create: false, read: true, update: false, delete: false },
report: { create: false, read: true, update: false, delete: false },
sync_record: { create: false, read: true, update: false, delete: false },
sync_run: { create: false, read: true, update: false, delete: false },
sync: { create: false, read: true, update: false, delete: false },
user: { create: false, read: true, update: false, delete: false },
workspace: { create: false, read: true, update: false, delete: false },
data_app: { create: false, read: true, update: false, delete: false },
audit_logs: { create: false, read: false, update: false, delete: false }
}
}
)
end
end
2 changes: 1 addition & 1 deletion server/db/data_schema.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# frozen_string_literal: true

DataMigrate::Data.define(version: 20_240_903_055_705)
DataMigrate::Data.define(version: 20_241_022_143_042)

0 comments on commit 7a2fdfa

Please sign in to comment.