本篇参考: https://help.salesforce.com/s/articleView?id=sf.enhanced_transaction_security_policy_types.htm&type=5

https://developer.salesforce.com/docs/atlas.en-us.224.0.apexcode.meta/apexcode/apex_interface_TxnSecurity_EventCondition.htm

https://help.salesforce.com/s/articleView?id=sf.enhanced_transaction_security_policy_apex_examples.htm&type=5

我们先想一个客户是否提过以下类似的场景:

  1. 当前的公司对数据的隐私管理的相对严格,针对报表,尽管允许数据导出,但是当指定的profile进行导出的功能,不希望这个profile的user导出过多的数量,比如 sales rep在使用report的时候允许查看数据,但是使用导出功能时,导出account的数据禁止超过10条。
  2. 当前公司对浏览器要求很严格,必须要求指定浏览器指定版本才可以登录。
  3. 客户对于用户权限管理特别严格,使用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 浅入浅出的更多相关文章

  1. salesforce 零基础学习(二十三)数据记录导出至excel(自定义报表导出)

    我们都知道,报表有个功能为导出excel,但是有的时候客户需求往往标准的报表达不到,比如导出excel,其中本月修改的数据字段标红,如下图所示. 这就需要我们去写VF来实现此功能. 需求:将数据表记录 ...

  2. salesforce零基础学习(七十三)ProcessInstanceWorkItem/ProcessInstanceStep/ProcessInstanceHistory浅谈

    对于审批流中,通过apex代码进行审批操作一般都需要获取当前记录对应的ProcessInstanceWorkitem或者ProcessInstanceStep然后执行Approval.process操 ...

  3. salesforce零基础学习(九十三)Email To Case的简单实现

    Salesforce提供了标准的功能来实现通过Email 创建 Case.我们可以设置指定的路由的地址,指定条件的邮件会自动生成到目标salesforce系统的Case数据.Salesforce提供了 ...

  4. salesforce 零基础学习(二十二)Test简单使用

    本篇内容只是本人简单的mark开发中常出现的一些疑问,方便后期项目使用时奠定基础,如果对Test零基础童鞋,欢迎查看Test官方的使用介绍: https://help.salesforce.com/a ...

  5. salesforce 零基础学习(五十三)多个文件生成一个zip文件(使用git上封装的代码)

    此篇参考git代码:https://github.com/pdalcol/Zippex 学习salesforce可以访问一个朋友的网站:https://www.xgeek.net 首先感谢git上提供 ...

  6. salesforce 零基础学习(二十)简单APP制作

    本篇参考链接:https://developer.salesforce.com/trailhead/project/salesforce_developer_workshop 本篇讲述的是最简单的AP ...

  7. salesforce 零基础学习(三十三)通过REST方式访问外部数据以及JAVA通过rest方式访问salesforce

    本篇参考Trail教程: https://developer.salesforce.com/trailhead/force_com_dev_intermediate/apex_integration_ ...

  8. salesforce 零基础学习(二十八)使用ajax方式实现联动

    之前的一篇介绍过关于salesforce手动配置关联关系实现PickList的联动效果,但是现实的开发中,很多数据不是定死的,应该通过ajax来动态获取,本篇讲述通过JavaScript Remoti ...

  9. salesforce 零基础学习(二十四)解析csv格式内容

    salesforce中支持对csv格式的内容批量导入,可以使用dataloader,然而有些情况下,当用户没有相关权限使用dataloader导入情况下,就的需要使用VF和apex代码来搞定. 基本想 ...

  10. salesforce 零基础学习(二十九)Record Types简单介绍

    在项目中我们可能会遇见这种情况,不同的Profile拥有不同的页面,页面中的PickList标签可能显示不同的值.这个时候,使用Record Types可以很便捷的搞定需求. Record Types ...

随机推荐

  1. nginx+gunicorn部署Django项目

    实际采用的nginx.conf文件内容: server { charset utf-8; listen 80; server_name ip; access_log /webapps/project/ ...

  2. POJ2104 K-th number (整体二分)

    刚学了整体二分,用这种解法来解决这道题. 首先对于每个询问时可以二分解决的,这也是可以使用整体二分的前提.将原来的序列看成是插入操作,和询问操作和在一起根据值域进行二分.用树状数组来检验二分值. 1 ...

  3. Js实现一键复制小功能

    function copyToClipboard(textToCopy) { // navigator clipboard 需要https等安全上下文 if (navigator.clipboard ...

  4. ASP.NET Core :缓存系列(四):内存缓存 MemoryCache

    System.Runtime.Caching/MemoryCache ICacheEntry 接口中的属性:具体设置过期时间 可以参考:微软文档ICacheEntry 接口 缓存基本使用 (一) 绝对 ...

  5. Persistent data structure 不可变数据结构

    持久性变数据不要和持久储存相混淆 在计算机中持久性数据或非临时数据是一种数据结构,在修改时始终保持其自身的先前版本.这些数据实际上是不可变的,因为对这类数据操作不会明显的改变数据结构,而是始终产生新的 ...

  6. 使用@Param标识参数

    可以通过@Param注解标识mapper接口中的方法参数 此时,会将这些参数放在map集合中,以@Param注解的value属性值为键,以参数为值: 以 param1,param2...为键,以参数为 ...

  7. .net lambda表达式合并

    事情的起因是公司一个小伙子问了我个问题 "海哥,来帮我看下这段代码怎么不行" Func<Report,bool> nameFilter = x=>x.Name = ...

  8. Ansible 批处理实战

    软件简介 Ansible 是一款自动化运维工具,基于 Python 开发,集合了众多运维工具(puppet.chef.func.fabric)的优点,实现了批量系统配置.批量程序部署.批量运行命令等功 ...

  9. C#-等待异步函数执行结果-将调用异步方法的函数变成非异步执行

    先来简单了解一下async.await 使用async await 的前提条件:需要C# 5.0以上版本 .NET Framework 4.5以上 Visual Studio 2012以上. asyn ...

  10. stm32h750移植lvgl

    之前没做过ui,只用过lcd画几条线写点字,如果按键.菜单什么的全用线画也太麻烦了,所以需要一个ui库. 听说lvgl用的人很多,就打算裸机移植一下用用.本文移植的lvgl版本是lvgl6.2,也移植 ...