salesforce零基础学习(一百二十三)Transaction Security 浅入浅出
我们先想一个客户是否提过以下类似的场景:
- 当前的公司对数据的隐私管理的相对严格,针对报表,尽管允许数据导出,但是当指定的profile进行导出的功能,不希望这个profile的user导出过多的数量,比如 sales rep在使用report的时候允许查看数据,但是使用导出功能时,导出account的数据禁止超过10条。
- 当前公司对浏览器要求很严格,必须要求指定浏览器指定版本才可以登录。
- 客户对于用户权限管理特别严格,使用permission set进行管理并且不允许任意的分配到指定的 permission set,需要基于指定的规则来弄,不满足规则的不允许放在这个permission set中。
这种需求是可能出现的,如果客户提出了这种要求,那么 salesforce是否能实现呢? 答案是可以的,接下来就引出我们今天的内容, transaction security.
注意:如果想使用Transaction Security, 首先需要去购买 Salesforce Shield 或者 Salesforce Shield Event Monitoring 附加的license/subscription.
Transaction Security是一个拦截实时事件并应用适当操作来监视和控制用户活动的框架。每个Transaction Security Policy都有评估事件和满足这些条件后触发的实时操作的条件。这些操作包括block当前行为、MFA和通知。Transaction Security可以基于Condition Builder或者 Apex方式来配置。其中
- Condition Builder用于基于 no code点击配置的方式来实现基于条件的监控操作。
- Apex用于基于code方式来实现复杂场景的监控操作。
接下来基于三方面来讲 Transaction Security Policy: Type / Action & Notification / Content Builder & Apex方式配置。
一. Transaction Security Policy Type
我们可以在这些实时事件监视事件上创建我们的 Transaction Security Policy.
|
Event Type |
Type Short Description |
Conditions Available in Condition Builder |
Actions |
Considerations |
|
ApiEvent |
API events monitor API transactions, such as SOQL queries and data exports. |
API Type, API Version, Application, Client, Elapsed Time, Operation, Platform, Queried Entities, Query, Rows Processed, Session Level, Source IP, User Agent, User ID, Username |
Block, Notifications |
Multi-factor authentication isn’t supported. |
|
ApiAnomalyEventStore |
API anomaly event policies monitor anomalies in how users make API calls. |
User, Username, SourceIp, Score, QueriedEntities, Operation, RowsProcessed, UserAgent |
Notifications |
|
|
BulkApiResultEventStore |
Bulk API Result Event policies detect when a user downloads the results of a Bulk API request. |
Query, SessionLevel, SourceIp, UserId, Username |
Block, Notifications |
|
|
CredentialStuffingEventStore |
Credential stuffing event policies monitor when a user successfully logs into Salesforce during an identified credential stuffing attack. Credential stuffing refers to large-scale automated login requests using stolen user credentials. |
AcceptLanguage, LoginUrl, Score, SourceIp, UserAgent, UserId, Username |
Notifications |
|
|
ListViewEvent |
List View event policies monitor when data is viewed or downloaded from your list views using Salesforce Classic, Lightning Experience, or the API. |
Application Name, Developer Name, Event Source, List View ID, Name, Name of Columns, Number of Columns, Order By, Owner ID, Queried Entities, Rows Processed, Scope, Session Level, Source IP, User ID, Username |
Block, Notifications, Multi-Factor Authentication (for UI logins) Multi-factor authentication is not supported for list views in Lightning pages, so the action is upgraded to Block. |
|
|
LoginEvent |
Login event policies track login activity and enforce your org’s login requirements. |
API Type, API Version, Application, Browser, Country, Login URL, Platform, Session Level, Source IP, TLS Protocol, User ID, User Type, Username |
Block, Notifications, Multi-Factor Authentication (for UI logins) |
|
|
PermissionSetEventStore |
Permission set event policies monitor when users are assigned critical permissions in a permission set. |
Event Source, Operation, Permission Type, User Count, User ID, Username |
Block, Notifications |
|
|
ReportAnomalyEventStore |
Report anomaly event policies monitor anomalies in how users run or export reports. |
Report, Score, SourceIp, UserId, Username |
Notifications |
|
|
ReportEvent |
Report event policies monitor when data is viewed or downloaded from your reports. |
Dashboard ID, Dashboard Name, Description, Event Source, Format, Is Scheduled, Name, Name of Columns, Number of Columns, Operation, Owner ID, Queried Entities, Report ID, Rows Processed, Scope, Session Level, Source IP, User ID, Username |
Block, Notifications, Multi-Factor Authentication (for UI logins) |
|
|
SessionHijackingEventStore |
Session hijacking event policies monitor when unauthorized users gain ownership of a Salesforce user’s session with a stolen session identifier. |
CurrentUserAgent, CurrentIp, CurrentPlatform, CurrentScreen, CurrentWindow, PreviousUserAgent, PreviousIp, PreviousPlatform, PreviousScreen, PreviousWindow, Score, SourceIp, UserId, Username |
Notifications |
我们项目中常用的可能会用到LoginEvent / ListViewEvent / ReportEvent。其他的使用到再自行查阅。
二. Action & Notification
当一个实时的事件触发了我们配置的 policy,我们可以进行什么样的行为呢?目前可以实现阻止当前用户的行为或者强制让用户MFA去授权继续操作。除此以外,可选项还包括 接收事件的应用内通知或电子邮件通知。
三. Content Builder & Apex方式配置
上述讲了 Transaction Security Type以及 Action,本块内容讲一下具体的实操方式。首先我们需要先启用这个功能

1. Content Builder: 基于可视化无代码点击配置方式来搞定。





2. Apex方式配置:当我们需要一些复杂逻辑时,Content Builder便无法实现,这个时候我们就需要使用 Apex方式来配置。


第三步和上面的Content Builder操作相同,区别是暂时先别启用。

系统会自动生成这个Condition类

针对这个类实现了 TxnSecurity.EventCondition这个接口,好处是 salesforce已经给了很多的 example,所以不需要从0开始造车,复制粘贴修改很快便可以实现。核心的方法就是 evaluate,当为true,则代表着满足了当前的 transaction policy,系统便会执行我们配置的action。下方的demo为,除管理员外,不允许用户导出超过10条的数据
global class BlockLargeDataExportEventCondition implements TxnSecurity.EventCondition {
public boolean evaluate(SObject event) {
switch on event{
when ReportEvent reportEvent {
return evaluate(reportEvent);
}
when null {
// Don't take policy action when event is null
return false;
}
when else{
// Don't take policy action when event is not handled
return false;
}
}
}
/**
* Handle evaluating ReportEvent
*/
private boolean evaluate(ReportEvent reportEvent){
Profile profile = [SELECT Name FROM Profile WHERE Id IN
(SELECT profileId FROM User WHERE Id = :reportEvent.UserId)];
// Take policy action only if the user profile is not 'System Administrator' and
// RowsProcessed greater than 10.
if (!profile.Name.equals('System Administrator')
&& reportEvent.RowsProcessed >= 10 && reportEvent.Operation== 'ReportExported') {
return true;
}
return false;
}
}
执行效果: 管理员导出数据

使用非admin账号登录操作。


总结:Transaction Security虽然是付费的功能,但是好多涉及到用户隐私/权限进行一定的监控和增强。篇中有错误地方欢迎指出,有不懂欢迎留言。
salesforce零基础学习(一百二十三)Transaction Security 浅入浅出的更多相关文章
- salesforce 零基础学习(二十三)数据记录导出至excel(自定义报表导出)
我们都知道,报表有个功能为导出excel,但是有的时候客户需求往往标准的报表达不到,比如导出excel,其中本月修改的数据字段标红,如下图所示. 这就需要我们去写VF来实现此功能. 需求:将数据表记录 ...
- salesforce零基础学习(七十三)ProcessInstanceWorkItem/ProcessInstanceStep/ProcessInstanceHistory浅谈
对于审批流中,通过apex代码进行审批操作一般都需要获取当前记录对应的ProcessInstanceWorkitem或者ProcessInstanceStep然后执行Approval.process操 ...
- salesforce零基础学习(九十三)Email To Case的简单实现
Salesforce提供了标准的功能来实现通过Email 创建 Case.我们可以设置指定的路由的地址,指定条件的邮件会自动生成到目标salesforce系统的Case数据.Salesforce提供了 ...
- salesforce 零基础学习(二十二)Test简单使用
本篇内容只是本人简单的mark开发中常出现的一些疑问,方便后期项目使用时奠定基础,如果对Test零基础童鞋,欢迎查看Test官方的使用介绍: https://help.salesforce.com/a ...
- salesforce 零基础学习(五十三)多个文件生成一个zip文件(使用git上封装的代码)
此篇参考git代码:https://github.com/pdalcol/Zippex 学习salesforce可以访问一个朋友的网站:https://www.xgeek.net 首先感谢git上提供 ...
- salesforce 零基础学习(二十)简单APP制作
本篇参考链接:https://developer.salesforce.com/trailhead/project/salesforce_developer_workshop 本篇讲述的是最简单的AP ...
- salesforce 零基础学习(三十三)通过REST方式访问外部数据以及JAVA通过rest方式访问salesforce
本篇参考Trail教程: https://developer.salesforce.com/trailhead/force_com_dev_intermediate/apex_integration_ ...
- salesforce 零基础学习(二十八)使用ajax方式实现联动
之前的一篇介绍过关于salesforce手动配置关联关系实现PickList的联动效果,但是现实的开发中,很多数据不是定死的,应该通过ajax来动态获取,本篇讲述通过JavaScript Remoti ...
- salesforce 零基础学习(二十四)解析csv格式内容
salesforce中支持对csv格式的内容批量导入,可以使用dataloader,然而有些情况下,当用户没有相关权限使用dataloader导入情况下,就的需要使用VF和apex代码来搞定. 基本想 ...
- salesforce 零基础学习(二十九)Record Types简单介绍
在项目中我们可能会遇见这种情况,不同的Profile拥有不同的页面,页面中的PickList标签可能显示不同的值.这个时候,使用Record Types可以很便捷的搞定需求. Record Types ...
随机推荐
- k8s控制器理解
DaemonSet 一个DaemonSet对象能确保其创建的Pod在集群中的每一台(或指定)Node上都运行一个副本.如果集群中动态加入了新的Node,DaemonSet中的Pod也会被添加在新加入N ...
- Intellij IDEA个人常用快捷键
分享一下个人常用快捷键. 说明:字母排序规则遵循字母表(a->z) 快捷键 介绍 ctrl+b 快速打开当前光标处的类或方法 ctrl+d 复制当前光标所在行至下一行 ctrl+e 打开最近的文 ...
- python_flask开发环境设置
flask开发环境设置,在powershell终端窗口,可以通过一下方式设置: # 设置当前app实例 $env:FLASK_APP="app:create_app()" #将当前 ...
- 改善C#程序的方法-3 比较器和LINQ排序
一 创建对象时考虑实现比较器 假设有这样的场景,有一个40个人的学生列表,业务中需针对学生的成绩来进行排序. 可以考虑用IComparable接口和ICompare接口实现: class Progra ...
- ArcMap布局添加图表问题
在ArcMap分析制图过程中,经常会产生一些图表,然而在布局中添加这些图表会发现一些意想不到的问题. 问题重现 将图表直接添加到布局会发现图表有黑底,这在我们布局出图中是十分不美观的,这该如何解决呢? ...
- 华为网关交换机开启DHCP server服务
华为网关交换机可以配置基于全局地址池的DHCP服务器,也可以配置基于接口地址池的DHCP服务器,本人比较倾向于配置基于接口地址池的DHCP服务器,因此在这里只介绍后者. 第一步:开启DHCP功能 [S ...
- 洛谷P1884 [USACO12FEB]Overplanting S (矩形切割)
一种矩形切割的做法: 1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long LL; 4 const in ...
- 利用Java集合实现学生信息的”增删查“
之前学了Java中的集合,打算写一个小程序来消化一下! 那么我们知道,集合相比数组的优点就是可以动态的增加元素,这对比数组来说,十分的便捷: 并且集合为我们封装好一些方法,可以更好的做一些数据操作! ...
- 【机器学习】利用 Python 进行数据分析的环境配置 Windows(Jupyter,Matplotlib,Pandas)
环境配置 安装 python 博主使用的版本是 3.10.6 在 Windows 系统上使用 Virtualenv 搭建虚拟环境 安装 Virtualenv 打开 cmd 输入并执行 pip inst ...
- React魔法堂:echarts-for-react源码略读
前言 在当前工业4.0和智能制造的产业升级浪潮当中,智慧大屏无疑是展示企业IT成果的最有效方式之一.然而其背后怎么能缺少ECharts的身影呢?对于React应用而言,直接使用ECharts并不是最高 ...